Skip to content
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

When using this lib, the problem of segmentation fault i have encoutered. #4

Closed
lutianba2014 opened this issue Nov 23, 2018 · 4 comments

Comments

@lutianba2014
Copy link

In CentOS release 6.5(Linux kernel 2.6.32-431.el6.x86_64)

[root@Server]# echo $LD_PRELOAD
./libleak.so
[root@Server]# ll
Segmentation fault

@lutianba2014
Copy link
Author

(gdb) set environment LD_PRELOAD=./libleak.so
(gdb) run
Starting program: /bin/ls
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#1 0x00007ffff7adabc2 in free (p=0x0) at libleak.c:584
#2 0x00007ffff78c5e44 in ?? () from /lib64/libselinux.so.1
#3 0x00007ffff78cee26 in ?? () from /lib64/libselinux.so.1
#4 0x00007fffffffe648 in ?? ()
#5 0x0000000000000001 in ?? ()
#6 0x00007fffffffe648 in ?? ()
#7 0x00007ffff78be083 in _init () from /lib64/libselinux.so.1
#8 0x00007ffff7fee4c8 in ?? ()
#9 0x00007ffff7deb5a5 in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#10 0x00007ffff7dddb3a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#11 0x0000000000000001 in ?? ()
#12 0x00007fffffffe88f in ?? ()
#13 0x0000000000000000 in ?? ()

maybe project NULL == p when memory need to free?

@WuBingzheng
Copy link
Owner

I write a test program which free(NULL), and it works fine with libleak.
Do you find any other programs that crashes with libleak?

You'd better not define and export LD_PRELOAD for whole shell environment.
Define it for your program only, and do not export it.

@ukolovda
Copy link

ukolovda commented Jun 7, 2019

I got the same error on Fedora 29.
Call stack is:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) where
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff7ec7b31 in free (p=0x0) at libleak.c:581
#2  free (p=0x0) at /usr/include/stdlib.h:563
#3  0x00007ffff70ebaca in init_selinuxmnt () at init.c:129
#4  init_lib () at init.c:154
#5  0x00007ffff7fe1dea in call_init.part () from /lib64/ld-linux-x86-64.so.2
#6  0x00007ffff7fe1eea in _dl_init () from /lib64/ld-linux-x86-64.so.2
#7  0x00007ffff7fd314a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#8  0x0000000000000001 in ?? ()
#9  0x00007fffffffda75 in ?? ()
#10 0x0000000000000000 in ?? ()

After I append pointer check in libleak.c at line 581:

if (leak_real_free != NULL) { leak_real_free(p); }

it start fine.

@WuBingzheng
Copy link
Owner

I will commit this pointer check.
Thanks.

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

No branches or pull requests

3 participants