[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] cex: fix a crash
From: |
Akim Demaille |
Subject: |
Re: [PATCH] cex: fix a crash |
Date: |
Sun, 17 May 2020 12:17:16 +0200 |
Hi Vincent,
> Le 17 mai 2020 à 04:19, Vincent Imbimbo <address@hidden> a écrit :
>
> Hey Akim,
>
>> This does not seem right. You should try to use clang with address
>> sanitizer (see .travis.yml for one way to set it up). For instance, that's
>> one failure on my machine, caused by this commit.
>
> This turned out to be pretty simple (I hope). I just needed to add a break
> statement to make the sanitizer happy.
>
> @ -199,6 +199,7 @@ free_parse_state (parse_state *original_ps)
> {
> free (ps);
> ++frees;
> + break;
> }
> }
> }
Great, you are right, it fixed the issue!
We are super close to being done, I think, and I expect I will be able to merge
into master super soon.
However, we still have memory leaks. I believe it won't be too hard to address.
See below what I get using clang's address sanitizer.
I have again pushed -f the cex branch. Please start from there. You can have
a look at the CI here: https://travis-ci.org/github/akimd/bison/builds/687993664
Cheers!
akim@io ~bison $ ASAN_OPTIONS=detect_leaks=1 lldb -- ./_build/c9a/src/bison
-Wcoun src/parse-gram.y
(lldb) target create "./_build/c9a/src/bison"
Current executable set to './_build/c9a/src/bison' (x86_64).
(lldb) settings set -- target.run-args "-Wcoun" "src/parse-gram.y"
(lldb) r
Process 14081 launched: '/Users/akim/src/gnu/bison/_build/c9a/src/bison'
(x86_64)
=================================================================
==14081==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 30800 byte(s) in 385 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x1001c9204 in xmalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9204)
#2 0x10014fc88 in state_sym_lookup
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014fc88)
#3 0x10014ac83 in init_trans
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014ac83)
#4 0x100148aae in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148aae)
#5 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#6 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#7 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Direct leak of 13360 byte(s) in 167 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x10019afd4 in hash_initialize
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10019afd4)
#2 0x10014b446 in init_prods
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014b446)
#3 0x100148ab3 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148ab3)
#4 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#5 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#6 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Direct leak of 13360 byte(s) in 167 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x10019afd4 in hash_initialize
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10019afd4)
#2 0x10014a806 in init_trans
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014a806)
#3 0x100148aae in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148aae)
#4 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#5 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#6 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Direct leak of 10696 byte(s) in 1 object(s) allocated from:
#0 0x10050d302 in wrap_calloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x45302)
#1 0x1001c9498 in xcalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9498)
#2 0x1001c9459 in xzalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9459)
#3 0x100191812 in bitsetv_alloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100191812)
#4 0x100191981 in bitsetv_create
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100191981)
#5 0x100148db0 in init_state_items
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148db0)
#6 0x100148aa9 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148aa9)
#7 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#8 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#9 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Direct leak of 4912 byte(s) in 307 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x1001c9204 in xmalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9204)
#2 0x100147318 in hash_pair_lookup
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100147318)
#3 0x10014b7a9 in init_prods
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014b7a9)
#4 0x100148ab3 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148ab3)
#5 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#6 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#7 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Direct leak of 2704 byte(s) in 169 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x1001c9204 in xmalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9204)
#2 0x100147318 in hash_pair_lookup
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100147318)
#3 0x10014bb9e in init_prods
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014bb9e)
#4 0x100148ab3 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148ab3)
#5 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#6 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#7 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Direct leak of 2160 byte(s) in 30 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x1001a07a8 in gl_linked_nx_create
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001a07a8)
#2 0x10015030e in gl_list_nx_create
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10015030e)
#3 0x100150038 in gl_list_create
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100150038)
#4 0x10014c797 in gen_lookaheads
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014c797)
#5 0x100148ab8 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148ab8)
#6 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#7 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#8 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Direct leak of 1920 byte(s) in 1 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x1003cbed6 in libtextstyle_xnmalloc
(/opt/gostai/lib/libtextstyle.0.dylib:x86_64+0xfed6)
#2 0x1003c4620 in term_ostream_create
(/opt/gostai/lib/libtextstyle.0.dylib:x86_64+0x8620)
#3 0x1003ca538 in term_styled_ostream_create
(/opt/gostai/lib/libtextstyle.0.dylib:x86_64+0xe538)
#4 0x1003cdde8 in styled_ostream_create
(/opt/gostai/lib/libtextstyle.0.dylib:x86_64+0x11de8)
#5 0x100013944 in complain_init_color
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100013944)
#6 0x10003bab4 in getargs_colors
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10003bab4)
#7 0x100039248 in getargs
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100039248)
#8 0x10006d903 in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006d903)
#9 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Indirect leak of 141616 byte(s) in 167 object(s) allocated from:
#0 0x10050d302 in wrap_calloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x45302)
#1 0x10019b151 in hash_initialize
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10019b151)
#2 0x10014b446 in init_prods
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014b446)
#3 0x100148ab3 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148ab3)
#4 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#5 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#6 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Indirect leak of 31184 byte(s) in 167 object(s) allocated from:
#0 0x10050d302 in wrap_calloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x45302)
#1 0x10019b151 in hash_initialize
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10019b151)
#2 0x10014a806 in init_trans
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014a806)
#3 0x100148aae in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148aae)
#4 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#5 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#6 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Indirect leak of 7336 byte(s) in 131 object(s) allocated from:
#0 0x10050d302 in wrap_calloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x45302)
#1 0x1001c9498 in xcalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9498)
#2 0x1001c9459 in xzalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9459)
#3 0x10016dea7 in bitset_alloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10016dea7)
#4 0x10016e5a9 in bitset_create
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10016e5a9)
#5 0x10014b801 in init_prods
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014b801)
#6 0x100148ab3 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148ab3)
#7 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#8 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#9 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Indirect leak of 2096 byte(s) in 131 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x1001c9204 in xmalloc
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x1001c9204)
#2 0x10014feec in hash_pair_insert
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014feec)
#3 0x10014b821 in init_prods
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014b821)
#4 0x100148ab3 in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148ab3)
#5 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#6 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#7 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
Indirect leak of 816 byte(s) in 51 object(s) allocated from:
#0 0x10050cf2d in wrap_malloc
(/opt/local/libexec/llvm-9.0/lib/clang/9.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x44f2d)
#1 0x10019f383 in allocate_entry
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10019f383)
#2 0x10019e77f in hash_insert_if_absent
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10019e77f)
#3 0x10019f49c in hash_insert
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10019f49c)
#4 0x10014a94e in init_trans
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10014a94e)
#5 0x100148aae in state_items_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100148aae)
#6 0x100027c48 in counterexample_init
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x100027c48)
#7 0x10006dc8b in main
(/Users/akim/src/gnu/bison/_build/c9a/src/bison:x86_64+0x10006dc8b)
#8 0x7fff6df8d3d4 in start (/usr/lib/system/libdyld.dylib:x86_64+0x163d4)
SUMMARY: AddressSanitizer: 262960 byte(s) leaked in 1874 allocation(s).
Process 14081 exited with status = 1 (0x00000001)