This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
"segfault at 0 ip (null) .." at when using LD_PRELOAD on tty7 (GUI)
- From: Yubin Ruan <ablacktshirt at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 29 Aug 2017 23:27:18 +0800
- Subject: "segfault at 0 ip (null) .." at when using LD_PRELOAD on tty7 (GUI)
- Authentication-results: sourceware.org; auth=none
Hi,
Has anyone encounter a situation like this:
I use a script to export the LD_PRELOAD environment variable at system startup:
# /etc/profile.d/some_script.sh
export LD_PRELOAD=/path/to/my/libhook.so
Inside "libhook.so", there are three wrapper: open/read/write, which I
use as hooks of the open/read/write system calls. I was hoping that
after setting LD_PRELOAD to point to "libhook.so" at system startup,
every program, when executing, will load the "libhook.so"
automatically and when they invoke open/read/write, my hooks will get
invoked instead.
This work fine, except that it does not work for most GUI programs,
that is, those program running on tty7. I just cannot start those GUI
programs. I find in /var/log/kern.log and /var/log/syslog something
related:
"...program name... segfault at 0 ip null sp... error 14"
for every GUI program I try to execute.
Those "segfault at 0 ip null..." looks very weird to me because I can
find anywhere in my code any use of NULL pointer. And my code work
find for every other program when I explicitly set LD_PRELOAD instead
of setting it at system startup.
The most strange thing is: I move to other tty (say tty4) and rm
"/path/to/my/libhook.so", and go back to tty7, all GUI programs work
fine, as expected. And then I cp another "libhook.so" to
"/path/to/my/", those GUI programs still work fine and all my hooks
get invoked correctly!
I don't understand, why would I get "segfault at 0 ip (null) ..." if I
set LD_PRELOAD=/path/to/my/libhook.so at system startup, while it
works fine if I set it lately, after system startup.
I think this might be a linkage bug/feature of the dynamic linker
which I don't knows. Hopefully anyone who know it can provide some
hints.
FYI, I am using a Ubuntu 16.04, and tty7 is used for GUI. And it seems
that the kernel provides no core file for this situation...
Yubin