From: Peng Yu <pen...@gm...> - 2019-02-18 02:51:49
|
Hi, I have the follow flex code using Boehm garbage collector. http://www.hboehm.info/gc/gcinterface.html The program is compiled with the following commands. $ flex -o main.l.c main.l $ clang -I. -DGC_DEBUG -Wall -pedantic -g -c -o main.l.o main.l.c # rapidstring.h is in . $ clang main.l.o -lgc -lfl -o main.l.exe $ dsymutil main.l.exe rapidstring.h can be downloaded here. https://raw.githubusercontent.com/boyerjohn/rapidstring/master/include/rapidstring.h The following commands show that without using valgrind, the program runs OK. But if valgrind is used, the program will cause a segmentation fault. Is it because valgrind does not work with a garbage collector? $ ./main.l.exe <<EOF 1a23b 456c EOF tok = 1000, yylval= 1 tok = 1001, yylval= a tok = 1000, yylval= 23 tok = 1001, yylval= b tok = 1000, yylval= 456 tok = 1001, yylval= c $ valgrind ./main.l.exe <<EOF 1a23b 456c EOF ==44938== Memcheck, a memory error detector ==44938== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==44938== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==44938== Command: ./main.l.exe ==44938== ==44938== Syscall param __pthread_sigmask(set) points to uninitialised byte(s) ==44938== at 0x10068CB96: __pthread_sigmask (in /usr/lib/system/libsystem_kernel.dylib) ==44938== by 0x1006C3674: pthread_sigmask (in /usr/lib/system/libsystem_pthread.dylib) ==44938== by 0x1000D0225: GC_start_mark_threads_inner (in /usr/local/Cellar/bdw-gc/8.0.2/lib/libgc.1.dylib) ==44938== by 0x1000C0060: GC_init (in /usr/local/Cellar/bdw-gc/8.0.2/lib/libgc.1.dylib) ==44938== by 0x100003133: main (main.l:33) ==44938== Address 0x1048a42e4 is on thread 1's stack ==44938== in frame #2, created by GC_start_mark_threads_inner (???:) ==44938== ==44938== Thread 2: ==44938== Invalid read of size 4 ==44938== at 0x1006C35BA: _pthread_body (in /usr/lib/system/libsystem_pthread.dylib) ==44938== by 0x1006C350C: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib) ==44938== by 0x1006C2BF8: thread_start (in /usr/lib/system/libsystem_pthread.dylib) ==44938== Address 0x18 is not stack'd, malloc'd or (recently) free'd ==44938== ==44938== ==44938== Process terminating with default action of signal 11 (SIGSEGV) ==44938== Access not within mapped region at address 0x18 ==44938== at 0x1006C35BA: _pthread_body (in /usr/lib/system/libsystem_pthread.dylib) ==44938== by 0x1006C350C: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib) ==44938== by 0x1006C2BF8: thread_start (in /usr/lib/system/libsystem_pthread.dylib) ==44938== If you believe this happened as a result of a stack ==44938== overflow in your program's main thread (unlikely but ==44938== possible), you can try to increase the size of the ==44938== main thread stack using the --main-stacksize= flag. ==44938== The main thread stack size used in this run was 8388608. ==44938== ==44938== HEAP SUMMARY: ==44938== in use at exit: 19,932 bytes in 162 blocks ==44938== total heap usage: 183 allocs, 21 frees, 28,380 bytes allocated ==44938== ==44938== LEAK SUMMARY: ==44938== definitely lost: 0 bytes in 0 blocks ==44938== indirectly lost: 2,064 bytes in 1 blocks ==44938== possibly lost: 0 bytes in 0 blocks ==44938== still reachable: 200 bytes in 6 blocks ==44938== suppressed: 17,668 bytes in 155 blocks ==44938== Rerun with --leak-check=full to see details of leaked memory ==44938== ==44938== For counts of detected and suppressed errors, rerun with: -v ==44938== Use --track-origins=yes to see where uninitialised values come from ==44938== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4) Segmentation fault: 11 $ cat main.l // clang-format off %{ // clang-format on #define TOK_NUMBER 1000 #define TOK_STRING 1001 #include <gc.h> #define RS_MALLOC GC_MALLOC #define RS_REALLOC GC_REALLOC #define RS_FREE GC_FREE #include <rapidstring.h> typedef struct { int num; rapidstring str; } YYSTYPE; // clang-format off %} %option nodefault noinput nounput %option reentrant bison-bridge %% [[:digit:]]+ yylval->num=atoi(yytext); return TOK_NUMBER; [[:alpha:]]+ { // clang-format on rs_cpy(&yylval->str, yytext); return TOK_STRING; // clang-format off } .|\n %% int main() { // clang-format on GC_INIT(); yyscan_t scanner; yylex_init(&scanner); int tok; YYSTYPE lval; rs_init(&lval.str); while ((tok = yylex(&lval, scanner))) { if (tok == TOK_NUMBER) { printf("tok = %d, yylval= %d\n", tok, yyget_lval(scanner)->num); } else if (tok == TOK_STRING) { printf("tok = %d, yylval= %s\n", tok, rs_data(&yyget_lval(scanner)->str)); } } yylex_destroy(scanner); return 0; } -- Regards, Peng |
From: Philippe W. <phi...@sk...> - 2019-02-18 22:42:45
|
On Sun, 2019-02-17 at 20:51 -0600, Peng Yu wrote: > Hi, > > I have the follow flex code using Boehm garbage collector. > http://www.hboehm.info/gc/gcinterface.html > > The program is compiled with the following commands. > > $ flex -o main.l.c main.l > $ clang -I. -DGC_DEBUG -Wall -pedantic -g -c -o main.l.o main.l.c # > rapidstring.h is in . > $ clang main.l.o -lgc -lfl -o main.l.exe > $ dsymutil main.l.exe > > rapidstring.h can be downloaded here. > > https://raw.githubusercontent.com/boyerjohn/rapidstring/master/include/rapidstring.h > > The following commands show that without using valgrind, the program > runs OK. But if valgrind is used, the program will cause a > segmentation fault. > > Is it because valgrind does not work with a garbage collector? It would not be very amasing that memcheck (that replaces malloc) would conflict with something like Boehm gc, that for sure does strange things with malloc replacement itself. You might first try with --tool=none to see if the basis of valgrind+boehm gc works. Philippe |
From: Peng Yu <pen...@gm...> - 2019-02-18 23:06:06
|
Here is the output. It still fails. So I am not supposed to use valgrind when I use boehm gc? $ valgrind --tool=none ./main.l.exe <<EOF 1a23b 10.8 456c EOF ==47141== Nulgrind, the minimal Valgrind tool ==47141== Copyright (C) 2002-2017, and GNU GPL'd, by Nicholas Nethercote. ==47141== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==47141== Command: ./main.l.exe ==47141== ==47141== ==47141== Process terminating with default action of signal 11 (SIGSEGV) ==47141== Access not within mapped region at address 0x18 ==47141== at 0x1006B55BA: _pthread_body (in /usr/lib/system/libsystem_pthread.dylib) ==47141== by 0x1006B550C: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib) ==47141== by 0x1006B4BF8: thread_start (in /usr/lib/system/libsystem_pthread.dylib) ==47141== If you believe this happened as a result of a stack ==47141== overflow in your program's main thread (unlikely but ==47141== possible), you can try to increase the size of the ==47141== main thread stack using the --main-stacksize= flag. ==47141== The main thread stack size used in this run was 8388608. ==47141== Segmentation fault: 11 > You might first try with --tool=none to see if the basis of valgrind+boehm > gc works. -- Regards, Peng |
From: John R. <jr...@bi...> - 2019-02-19 01:06:15
|
On 2/17/19, Peng Yu wrote: > $ flex -o main.l.c main.l > $ clang -I. -DGC_DEBUG -Wall -pedantic -g -c -o main.l.o main.l.c # > rapidstring.h is in . > $ clang main.l.o -lgc -lfl -o main.l.exe > $ dsymutil main.l.exe What is 'dsymutil', where did you get it, what version? What is the hardware architecture? The execution recipe works for me on Fedora 28 using valgrind-3.14.0-7.fc28.x86_64. I omitted dsymutil. Why is it essential for you? $ ldd main.l.exe linux-vdso.so.1 (0x00007fffa7d9f000) libgc.so.1 => /lib64/libgc.so.1 (0x00007f255ef81000) libc.so.6 => /lib64/libc.so.6 (0x00007f255ebc2000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f255e9a3000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f255e79f000) libatomic_ops.so.1 => /lib64/libatomic_ops.so.1 (0x00007f255e59c000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f255e384000) /lib64/ld-linux-x86-64.so.2 (0x00007f255f2de000) $ rpm -qf /lib64/libgc.so.1 gc-7.6.4-3.fc28.x86_64 $ rpm -qf /usr/bin/flex flex-2.6.1-7.fc28.x86_64 $ rpm -q clang clang-6.0.1-2.fc28.x86_64 $ valgrind ./main.l.exe <input.txt ==23299== Memcheck, a memory error detector ==23299== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==23299== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==23299== Command: ./main.l.exe ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E4D166: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E4D16B: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E4CF57: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E4CF66: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E4CF9A: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E491AA: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E491B9: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E491E7: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E44733: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E4D166: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E4D16B: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E4CF57: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E4CF66: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E4CF9A: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E491AA: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Conditional jump or move depends on uninitialised value(s) ==23299== at 0x4E491B9: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E491E7: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== ==23299== Use of uninitialised value of size 8 ==23299== at 0x4E44733: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) ==23299== by 0x403203: main (main.l:34) ==23299== tok = 1000, yylval= 1 tok = 1001, yylval= a tok = 1000, yylval= 23 tok = 1001, yylval= b tok = 1000, yylval= 456 tok = 1001, yylval= c ==23299== ==23299== HEAP SUMMARY: ==23299== in use at exit: 864 bytes in 3 blocks ==23299== total heap usage: 14 allocs, 11 frees, 24,562 bytes allocated ==23299== ==23299== LEAK SUMMARY: ==23299== definitely lost: 0 bytes in 0 blocks ==23299== indirectly lost: 0 bytes in 0 blocks ==23299== possibly lost: 864 bytes in 3 blocks ==23299== still reachable: 0 bytes in 0 blocks ==23299== suppressed: 0 bytes in 0 blocks ==23299== Rerun with --leak-check=full to see details of leaked memory ==23299== ==23299== For counts of detected and suppressed errors, rerun with: -v ==23299== Use --track-origins=yes to see where uninitialised values come from ==23299== ERROR SUMMARY: 390 errors from 18 contexts (suppressed: 0 from 0) $ |
From: John R. <jr...@bi...> - 2019-02-19 01:19:34
|
> ==23299== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info > ==23299== Command: ./main.l.exe > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E4D166: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) After $ sudo dnf debuginfo-install /usr/lib64/libgc.so.1.3.2 then the messages look like: ==23530== Command: ./main.l.exe ==23530== ==23530== Conditional jump or move depends on uninitialised value(s) ==23530== at 0x4E4D166: GC_push_all_eager (mark.c:1583) ==23530== by 0x4E49D21: GC_with_callee_saves_pushed (mach_dep.c:322) ==23530== by 0x4E4E786: GC_push_regs_and_stack (mark_rts.c:772) ==23530== by 0x4E4E786: GC_push_roots (mark_rts.c:845) ==23530== by 0x4E4D896: GC_mark_some (mark.c:415) ==23530== by 0x4E42C44: GC_stopped_mark (alloc.c:702) ==23530== by 0x4E43348: GC_try_to_collect_inner (alloc.c:488) ==23530== by 0x4E5043B: GC_init (misc.c:1292) ==23530== by 0x403203: main (main.l:34) |
From: Peng Yu <pen...@gm...> - 2019-02-19 01:29:21
|
On Mon, Feb 18, 2019 at 7:07 PM John Reiser <jr...@bi...> wrote: > On 2/17/19, Peng Yu wrote: > > $ flex -o main.l.c main.l > > $ clang -I. -DGC_DEBUG -Wall -pedantic -g -c -o main.l.o main.l.c # > > rapidstring.h is in . > > $ clang main.l.o -lgc -lfl -o main.l.exe > > $ dsymutil main.l.exe > > What is 'dsymutil', where did you get it, what version? > What is the hardware architecture? That is just the command on Mac to generate the debug symbols. > > > The execution recipe works for me on Fedora 28 using > valgrind-3.14.0-7.fc28.x86_64. > I omitted dsymutil. Why is it essential for you? It is not essential. > > > $ ldd main.l.exe > linux-vdso.so.1 (0x00007fffa7d9f000) > libgc.so.1 => /lib64/libgc.so.1 (0x00007f255ef81000) > libc.so.6 => /lib64/libc.so.6 (0x00007f255ebc2000) > libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f255e9a3000) > libdl.so.2 => /lib64/libdl.so.2 (0x00007f255e79f000) > libatomic_ops.so.1 => /lib64/libatomic_ops.so.1 > (0x00007f255e59c000) > libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f255e384000) > /lib64/ld-linux-x86-64.so.2 (0x00007f255f2de000) > > $ rpm -qf /lib64/libgc.so.1 > gc-7.6.4-3.fc28.x86_64 > $ rpm -qf /usr/bin/flex > flex-2.6.1-7.fc28.x86_64 > $ rpm -q clang > clang-6.0.1-2.fc28.x86_64 Why there is no segmentation fault in your run? > > > $ valgrind ./main.l.exe <input.txt > ==23299== Memcheck, a memory error detector > ==23299== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. > ==23299== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright > info > ==23299== Command: ./main.l.exe > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E4D166: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E4D16B: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E4CF57: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E4CF66: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E4CF9A: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E491AA: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E491B9: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E491E7: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E44733: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E49D21: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4E786: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E4D166: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E4D16B: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E4CF57: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E4CF66: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E4CF9A: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E491AA: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Conditional jump or move depends on uninitialised value(s) > ==23299== at 0x4E491B9: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E491E7: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E446F6: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > ==23299== Use of uninitialised value of size 8 > ==23299== at 0x4E44733: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D171: GC_push_all_eager (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E57F2C: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E4D896: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E42C44: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E43348: ??? (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x4E5043B: GC_init (in /usr/lib64/libgc.so.1.3.2) > ==23299== by 0x403203: main (main.l:34) > ==23299== > tok = 1000, yylval= 1 > tok = 1001, yylval= a > tok = 1000, yylval= 23 > tok = 1001, yylval= b > tok = 1000, yylval= 456 > tok = 1001, yylval= c > ==23299== > ==23299== HEAP SUMMARY: > ==23299== in use at exit: 864 bytes in 3 blocks > ==23299== total heap usage: 14 allocs, 11 frees, 24,562 bytes allocated > ==23299== > ==23299== LEAK SUMMARY: > ==23299== definitely lost: 0 bytes in 0 blocks > ==23299== indirectly lost: 0 bytes in 0 blocks > ==23299== possibly lost: 864 bytes in 3 blocks > ==23299== still reachable: 0 bytes in 0 blocks > ==23299== suppressed: 0 bytes in 0 blocks > ==23299== Rerun with --leak-check=full to see details of leaked memory > ==23299== > ==23299== For counts of detected and suppressed errors, rerun with: -v > ==23299== Use --track-origins=yes to see where uninitialised values come > from > ==23299== ERROR SUMMARY: 390 errors from 18 contexts (suppressed: 0 from 0) > $ > > > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users > -- Regards, Peng |
From: John R. <jr...@bi...> - 2019-02-19 02:18:31
|
> The execution recipe works for me on Fedora 28 using valgrind-3.14.0-7.fc28.x86_64. > I omitted dsymutil. Why is it essential for you? > > > It is not essential. Therefore omitting dsymutil will narrow the search for the problem(s). > $ rpm -q clang > clang-6.0.1-2.fc28.x86_64 > Why there is no segmentation fault in your run? What version of clang? I showed that I used clang-6.0.1-2.fc28.x86_64. Also, the default on Mac is to use addresses greater than (1ul<<32). This catches some errors of storing an address in a 32-bit variable. The default on Fedora is to start using addresses at 4MiB, which saves 4 bytes of space in several important places, but in many cases avoids noticing the problem of storing an address in 32 bits. |
From: John R. <jr...@bi...> - 2019-02-19 02:54:07
|
>> The execution recipe works for me on Fedora 28 using valgrind-3.14.0-7.fc28.x86_64. > Also, the default on Mac is to use addresses greater than (1ul<<32). Because the program works when _not_ run under valgrind, then the conclusion is that valgrind-3.14.0-7 has a bug where it stores an address in 32 bits. To find the bug in valgrind: invoke a debug version of valgrind-3.14 under lldb on Mac, and then invoke main.l.exe under that valgrind. The SIGSEGV should happen inside valgrind itself, so use lldb to find the bug. |