How to find the line where the error occurs?

Hello.

Run the program:
the lua script.lua < input.txt


I get this error:
spoiler
*** Error in `lua': corrupted double-linked list: 0x00000000027fed10 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bfb)[0x7fe8b9f8bbfb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76fc6)[0x7fe8b9f91fc6]
/lib/x86_64-linux-gnu/libc.so.6(+0x7964c)[0x7fe8b9f9464c]
/lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7fe8b9f95f64]
lua[0x449a41]
lua[0x453e09]
lua[0x454236]
lua[0x453bde]
lua(lua_rawseti+0x29)[0x440079]
lua[0x475572]
lua(getcaptures+0x80)[0x475980]
lua[0x45dc6b]
lua[0x444880]
lua[0x457c65]
lua[0x444b5f]
lua[0x444bb1]
lua[0x443fef]
lua[0x444e9d]
lua(lua_pcallk+0x73)[0x4403c3]
lua[0x43da0b]
lua[0x43e60b]
lua[0x444880]
lua[0x444b53]
lua[0x444bb1]
lua[0x443fef]
lua[0x444e9d]
lua(lua_pcallk+0x73)[0x4403c3]
lua(main+0x68)[0x43d798]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7fe8b9f3b2e1]
lua(_start+0x2a)[0x43d85a]
======= Memory map: ========
00400000-00671000 r-xp 00000000 103:02 12321265 /usr/local/bin/lua
00871000-00890000 r--p 00271000 103:02 12321265 /usr/local/bin/lua
00890000-008a2000 rw-p 00290000 103:02 12321265 /usr/local/bin/lua
008a2000-008a9000 rw-p 00000000 00:00 0
0263f000-02a7b000 rw-p 00000000 00:00 0 [heap]
7fe8b4000000-7fe8b4021000 rw-p 00000000 00:00 0
7fe8b4021000-7fe8b8000000 ---p 00000000 00:00 0
7fe8b9a59000-7fe8b9a6f000 r-xp 00000000 103:02 5377777 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe8b9a6f000-7fe8b9c6e000 ---p 00016000 103:02 5377777 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe8b9c6e000-7fe8b9c6f000 r--p 00015000 103:02 5377777 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe8b9c6f000-7fe8b9c70000 rw-p 00016000 103:02 5377777 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fe8b9c70000-7fe8b9cf1000 rw-p 00000000 00:00 0
7fe8b9cf1000-7fe8b9d17000 r-xp 00000000 103:02 5377844 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fe8b9d17000-7fe8b9f16000 ---p 00026000 103:02 5377844 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fe8b9f16000-7fe8b9f1a000 r--p 00025000 103:02 5377844 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fe8b9f1a000-7fe8b9f1b000 rw-p 00029000 103:02 5377844 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fe8b9f1b000-7fe8ba0b0000 r-xp 00000000 103:02 5375306 /lib/x86_64-linux-gnu/libc-2.24.so
7fe8ba0b0000-7fe8ba2b0000 ---p 00195000 103:02 5375306 /lib/x86_64-linux-gnu/libc-2.24.so
7fe8ba2b0000-7fe8ba2b4000 r--p 00195000 103:02 5375306 /lib/x86_64-linux-gnu/libc-2.24.so
7fe8ba2b4000-7fe8ba2b6000 rw-p 00199000 103:02 5375306 /lib/x86_64-linux-gnu/libc-2.24.so
7fe8ba2b6000-7fe8ba2ba000 rw-p 00000000 00:00 0
7fe8ba2ba000-7fe8ba2fe000 r-xp 00000000 103:02 5377833 /lib/x86_64-linux-gnu/libreadline.so.7.0
7fe8ba2fe000-7fe8ba4fd000 ---p 00044000 103:02 5377833 /lib/x86_64-linux-gnu/libreadline.so.7.0
7fe8ba4fd000-7fe8ba4ff000 r--p 00043000 103:02 5377833 /lib/x86_64-linux-gnu/libreadline.so.7.0
7fe8ba4ff000-7fe8ba505000 rw-p 00045000 103:02 5377833 /lib/x86_64-linux-gnu/libreadline.so.7.0
7fe8ba505000-7fe8ba507000 rw-p 00000000 00:00 0
7fe8ba507000-7fe8ba50a000 r-xp 00000000 103:02 5375309 /lib/x86_64-linux-gnu/libdl-2.24.so
7fe8ba50a000-7fe8ba709000 ---p 00003000 103:02 5375309 /lib/x86_64-linux-gnu/libdl-2.24.so
7fe8ba709000-7fe8ba70a000 r--p 00002000 103:02 5375309 /lib/x86_64-linux-gnu/libdl-2.24.so
7fe8ba70a000-7fe8ba70b000 rw-p 00003000 103:02 5375309 /lib/x86_64-linux-gnu/libdl-2.24.so
7fe8ba70b000-7fe8ba80e000 r-xp 00000000 103:02 5375310 /lib/x86_64-linux-gnu/libm-2.24.so
7fe8ba80e000-7fe8baa0d000 ---p 00103000 103:02 5375310 /lib/x86_64-linux-gnu/libm-2.24.so
7fe8baa0d000-7fe8baa0e000 r--p 00102000 103:02 5375310 /lib/x86_64-linux-gnu/libm-2.24.so
7fe8baa0e000-7fe8baa0f000 rw-p 00103000 103:02 5375310 /lib/x86_64-linux-gnu/libm-2.24.so
7fe8baa0f000-7fe8baa32000 r-xp 00000000 103:02 5375302 /lib/x86_64-linux-gnu/ld-2.24.so
7fe8baaf2000-7fe8bab73000 rw-p 00000000 00:00 0
7fe8babb4000-7fe8babf5000 rw-p 00000000 00:00 0
7fe8bac16000-7fe8bac1a000 rw-p 00000000 00:00 0
7fe8bac31000-7fe8bac32000 rw-p 00000000 00:00 0
7fe8bac32000-7fe8bac33000 r--p 00023000 103:02 5375302 /lib/x86_64-linux-gnu/ld-2.24.so
7fe8bac33000-7fe8bac34000 rw-p 00024000 103:02 5375302 /lib/x86_64-linux-gnu/ld-2.24.so
7fe8bac34000-7fe8bac35000 rw-p 00000000 00:00 0
7ffd6f6e0000-7ffd6f747000 rw-p 00000000 00:00 0 [stack]
7ffd6f789000-7ffd6f78b000 r--p 00000000 00:00 0 [vvar]
7ffd6f78b000-7ffd6f78d000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted


How to find the line where the error occurs, provided that all source codes are available?
March 23rd 20 at 18:48
1 answer
March 23rd 20 at 18:50
Solution
Collect lua with debugging symbols and then run this command under the debugger.
to run the command under a debugger

better under valgrind'Ohm, because judging by the trace, the error occurs when you call malloc, it means someone broke a bunch somewhere before. - Alden_Padberg commented on March 23rd 20 at 18:53

Find more questions by tags CLinux