Debug: Empty line detected! *** buffer overflow detected ***: terminated when trying to compile test.tib
Closed this issue · 4 comments
OS: GNU/Linux
I'm trying to compile the test.tib file and it is giving me the error in the title.
The output with the -v option is below.
Info: Verbose Mode successfully activated
Debug: 'Disp '
Debug: '"'
Debug: 'H'
Debug: 'I'
Debug: '!'
Debug: '"'
Debug: ':'
Debug: 'Disp '
Debug: '"'
Debug: 'W'
Debug: 'O'
Debug: 'O'
Debug: 'T'
Debug: '"'
Debug: 'If '
Debug: '1'
Debug: '='
Debug: '1'
Debug: ':'
Debug: 'Then'
Debug: 'Disp '
Debug: '"'
Debug: 'T'
Debug: 'E'
Debug: 'S'
Debug: 'T'
Debug: '"'
Debug: 'End'
Debug: Empty line detected!
Debug: 'If '
Debug: '-'
Debug: '5'
Debug: '0'
Debug: ' '
Debug: '<'
Debug: ' '
Debug: '-'
Debug: '3'
Debug: '0'
Debug: ':'
Debug: 'Then'
Debug: 'Disp '
Debug: '"'
Debug: 'h'
Debug: 'e'
Debug: 'l'
Debug: 'l'
Debug: 'o'
Debug: '?'
Debug: '"'
Debug: 'End'
Debug: Empty line detected!
*** buffer overflow detected ***: terminated
fish: “tibasicc -v test.tib” terminated by signal SIGABRT (Abort)
Any help is appreciated.
I think it would be best if you provided more information to make the bug more reproducible. Running the fish shell on my GNU/Linux System didn't cause this error, so are here some questions:
- Were you able to get a
test.8xp
output file (Note: without using the-o
flag when compiling, the output will not be in your current working directory, but instead wheretest.tib
is located) ? - What GNU/Linux Distribution did you use?
- What C++ libraries and compiler did you use?
- Do you have proper rw permissions for the directory where test.tib is located?
- Or maybe you have some things that could be worth mentioning... ?
I also think it would be good the see some information about the building process. To do so, follow these steps:
- Add
-v
at the end of line 16 in theMakefile
to the CXX compile options - Now change to the root directory of the
tibasicc
repository, runmake clean && make
and paste its output in this conversation
This is the output of make with verbose enabled on x86_64 MANJARO GNU/Linux 5.13.19-2 (I am also having this issue)
`rm -f src/tokens.o src/main.o src/tibasic.o/*.o
g++ -g -Wall -pedantic -O -v -c -o src/tokens.o src/tokens.cpp
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/tokens.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/cc1plus -quiet -v -D_GNU_SOURCE src/tokens.cpp -quiet -dumpdir src/ -dumpbase tokens.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g -O -Wall -Wpedantic -version -o /tmp/ccdHdmhB.s
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP
warning: MPFR header version 4.1.0 differs from library version 4.1.0-p13.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed
/usr/include
End of search list.
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP
warning: MPFR header version 4.1.0 differs from library version 4.1.0-p13.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 45eb9a71cc15bfdc579557bea4b77e51
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/tokens.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/'
as -v --gdwarf-5 --64 -o src/tokens.o /tmp/ccdHdmhB.s
GNU assembler version 2.36.1 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.36.1
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/tokens.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/tokens.'
g++ -g -Wall -pedantic -O -v -c -o src/main.o src/main.cpp
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/main.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/cc1plus -quiet -v -D_GNU_SOURCE src/main.cpp -quiet -dumpdir src/ -dumpbase main.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g -O -Wall -Wpedantic -version -o /tmp/cc0UjGwa.s
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP
warning: MPFR header version 4.1.0 differs from library version 4.1.0-p13.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed
/usr/include
End of search list.
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP
warning: MPFR header version 4.1.0 differs from library version 4.1.0-p13.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 45eb9a71cc15bfdc579557bea4b77e51
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/main.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/'
as -v --gdwarf-5 --64 -o src/main.o /tmp/cc0UjGwa.s
GNU assembler version 2.36.1 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.36.1
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/main.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/main.'
g++ -g -Wall -pedantic -O -v -c -o src/tibasic.o src/tibasic.cpp
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/tibasic.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/cc1plus -quiet -v -D_GNU_SOURCE src/tibasic.cpp -quiet -dumpdir src/ -dumpbase tibasic.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g -O -Wall -Wpedantic -version -o /tmp/ccVWCmP0.s
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP
warning: MPFR header version 4.1.0 differs from library version 4.1.0-p13.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed
/usr/include
End of search list.
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP
warning: MPFR header version 4.1.0 differs from library version 4.1.0-p13.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 45eb9a71cc15bfdc579557bea4b77e51
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/tibasic.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/'
as -v --gdwarf-5 --64 -o src/tibasic.o /tmp/ccVWCmP0.s
GNU assembler version 2.36.1 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.36.1
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-Wall' '-Wpedantic' '-O' '-v' '-c' '-o' 'src/tibasic.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'src/tibasic.'
g++ -o tibasicc src/tokens.o src/main.o src/tibasic.o`
Alright, now some updates on this issue:
I found out today that on line 154 in src/tibasic.cpp
, the program tries to assign 9 bytes into phdr.sig, while this char array only has a defined length of 8 characters. This should cause an overflow when assigning. So in this commit I changed its length to 9 bytes.
On my systems this never caused an error (even though it theoretically could), but when I added the gcc -D_FORTIFY_SOURCE=2
compile flag, the error I got looked identical to the one you got in this issue (only showing the tail of the output as only this is relevant) when running ./tibasicc -v tests/test.tib
:
Debug: 'o'
Debug: '?'
Debug: '"'
Debug: 'End'
Debug: Empty line detected!
*** buffer overflow detected ***: terminated
zsh: abort (core dumped) ./tibasicc -v tests/test.tib
But with the above mentioned commit, this did not show up again after recompiling. So I advice you to pull the new changes from this repo and try to recompile both with and without adding the -D_FORTIFY_SOURCE=2
flag to CXXFLAGS in the Makefile.
Hope this helps.
Works great now. Happy Holidays!! :D