Skip to content

fix segfault on element removal #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dcaratti
Copy link

@dcaratti dcaratti commented Nov 3, 2022

seems related to issue #42.

when elements' lifetime reaches 0, and program is compiled with debug, bmon
gets a segmentation fault:

 Program received signal SIGSEGV, Segmentation fault.
                                                    __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
 Downloading 0.00 MB source file /usr/src/debug/glibc-2.34-43.fc35.x86_64/string/../sysdeps/x86_64/multiarch/strlen-avx2.S
 74              VPCMPEQ (%rdi), %ymm0, %ymm1
 (gdb) bt
 #0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
 tgraf#1  0x00007ffff7a84228 in __vfprintf_internal (s=s@entry=0x7fffffffb9f0,
     format=0x410f08 "[DBG] %20s:%-4u %s: Deleting dead element %s\n", ap=0x7fffffffdb30, mode_flags=0)
     at vfprintf-internal.c:1647
 tgraf#2  0x00007ffff7a849ef in buffered_vfprintf (s=0x7ffff7bfb6a0 <_IO_2_1_stderr_>,
     format=format@entry=0x410f08 "[DBG] %20s:%-4u %s: Deleting dead element %s\n", args=args@entry=0x7fffffffdb30,
     mode_flags=mode_flags@entry=0) at vfprintf-internal.c:2295
 tgraf#3  0x00007ffff7a839cb in __vfprintf_internal (s=<optimized out>,
     format=0x410f08 "[DBG] %20s:%-4u %s: Deleting dead element %s\n", ap=ap@entry=0x7fffffffdb30,
     mode_flags=mode_flags@entry=0) at vfprintf-internal.c:1377
 tgraf#4  0x00007ffff7a6f3ca in __fprintf (stream=<optimized out>, format=<optimized out>) at fprintf.c:32
 tgraf#5  0x0000000000406339 in __group_foreach_element (g=g@entry=0x422ae0, list=list@entry=0x4da940,
     cb=cb@entry=0x407260 <element_check_if_dead>, arg=arg@entry=0x0) at group.c:45
 tgraf#6  0x0000000000406351 in __group_foreach_element (g=g@entry=0x422ae0, list=list@entry=0x4d6d40,
     cb=cb@entry=0x407260 <element_check_if_dead>, arg=arg@entry=0x0) at group.c:48
 tgraf#7  0x0000000000406351 in __group_foreach_element (g=0x422ae0, list=0x422af0, cb=0x407260 <element_check_if_dead>,
     arg=arg@entry=0x0) at group.c:48
 tgraf#8  0x0000000000406750 in group_foreach_recursive (arg=0x0, cb=<optimized out>) at group.c:67
 tgraf#9  free_unused_elements () at group.c:192
 tgraf#10 0x00000000004041f0 in main (argc=<optimized out>, argv=0x7fffffffdfb8) at bmon.c:350
 (gdb)

this happens because 'e->e_name' is used by 'DBG()' after the call to
element_free(e); calling DBG(...) before element_free() proved to fix the
above crash.

Signed-off-by: Davide Caratti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant