You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
asan + rr + libGLX __glDispatchInit prevent applications from starting #2746
I guess there's something fishy going on with asan and rr both trying to intercept pthread_mutex_lock here. Oddly enough, a simpler application with a normal mutex seems to work. So I guess it's also important that the mutex is locked from a global static that's called from dl_init in a library?
the message [Scheduler] Using unlimited ticks mode is the last I see, and then it just hangs there.
If I then ctrl + c to quit, the following is logged:
^C[Task] Task 187741 changed status to 0x27f (STOP-SIGINT)
[Task] (refreshing register cache)
[Task] Requesting registers from tracee 187741
[Scheduler] new status is 0x27f (STOP-SIGINT)
[RecordSession] trace time 987: Active task is 187741. Events:
[INFO log_pending_events()] (no pending events)
[record_signal] 187741: handling signal SIGINT (pevent: PTRACE_EVENT(0), event: (none)
[record_signal] Safe to deliver signal at 0x7f14b4f8e310 because not in syscallbuf
[RecordSession] SIGINT handled
[Scheduler] Scheduling next task (PREVENT_SWITCH)
[Scheduler] (187741 is un-switchable at SIGNAL: SIGINT(async))
[RecordSession] trace time 987: Active task is 187741. Events:
[INFO log()] SIGNAL: SIGINT(async)
[INFO log()] (none)
[Task] (refreshing extra-register cache using XSAVE)
[RecordTask] Wrote event SIGNAL: SIGINT(async) for time 987
[RecordSession] 187741: no user handler for SIGINT
[Scheduler] Scheduling next task (PREVENT_SWITCH)
[Scheduler] (187741 is un-switchable at SIGNAL_DELIVERY: SIGINT(async))
[RecordSession] trace time 988: Active task is 187741. Events:
[INFO log()] SIGNAL_DELIVERY: SIGINT(async)
[INFO log()] (none)
[RecordTask] Wrote event SIGNAL_DELIVERY: SIGINT(async) for time 988
[RecordSession] in signal-stop for SIGINT
[RecordSession] injecting signal SIGINT
[RecordTask] Refreshed sigmask, now 0
[Task] resuming execution of 187741 with PTRACE_CONT, signal SIGINT tick_period -2 wait 1
[Scheduler] Scheduling next task (PREVENT_SWITCH)
[Scheduler] (187741 is un-switchable at (none))
[Scheduler] and running; waiting for state change
[Task] going into blocking waitid(187741) ...
[Task] Task 187741 changed status to 0x6057f (PTRACE_EVENT_EXIT)
[Task] (refreshing register cache)
[Task] Requesting registers from tracee 187741
[Scheduler] new status is 0x6057f (PTRACE_EVENT_EXIT)
[RecordSession] trace time 989: Active task is 187741. Events:
[INFO log_pending_events()] (no pending events)
[Task] (refreshing extra-register cache using XSAVE)
[RecordTask] Wrote event SCHED for time 989
[Task] Advancing tid 187741 to exit
[Task] Waiting for exit of 187741
[Task] ptrace_if_alive tid 187741 was not alive
[RecordTask] Wrote event EXIT for time 990
[Task] Reaping 187741
[HasTaskSet] removing 187741 from task set 0x560e4fdcea70
[HasTaskSet] removing 187741 from task set 0x560e4fdc7970
[HasTaskSet] removing 187741 from task set 0x560e4fdc4b40
[Task] dead
[INFO terminate_recording()] Processing termination request ...
[RecordSession] Killing all tasks ...
[Session] Killing all tasks ...
[Session] Session 0x560e4fdca2a0 destroyed
Are you sure the tracee isn't busy waiting or something? The rr log doesn't show a futex call or anything just before the hang. What does /proc//status show for the tracee when it hangs
well yes, it is busy within the futex, that's what the CPU profile shows - it's apparently repeatedly getting woken up and then tries to lock it again - it's on-cpu and burning one core. But that only happens when I try to use rr on a binary compiled with asan - not when I just run it as-is, or when I leave out either asan or rr or both :)
197083: symbol=__pthread_mutex_lock; lookup in file=/home/milian/projects/compiled/other/bin/../lib/rr/librrpreload.so [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/libGLX.so.0 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/libstdc++.so.6 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/libm.so.6 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/libubsan.so.1 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/libgcc_s.so.1 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/libc.so.6 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/../lib/libdl.so.2 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/../lib/librt.so.1 [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/../lib/libpthread.so.0 [0]
197083: binding file /usr/lib/libasan.so.6 [0] to /usr/lib/../lib/libpthread.so.0 [0]: normal symbol `__pthread_mutex_lock'
and then later
197083: symbol=__pthread_mutex_lock; lookup in file=./a.out [0]
197083: symbol=__pthread_mutex_lock; lookup in file=/usr/lib/libasan.so.6 [0]
197083: binding file /home/milian/projects/compiled/other/bin/../lib/rr/librrpreload.so [0] to /usr/lib/libasan.so.6 [0]: normal symbol `__pthread_mutex_lock' [GLIBC_2.2.5]
Which seems like a guaranteed recipe for sadness.
This might be related to #2329 (comment). What version of ASAN are you using?
Hm I just updated rr to the latest release, and now it seems it cannot record an asan binary at all anymore:
$ rr --version
rr version 5.4.0 # patch 779040e4
$ cat test.cpp
int main() { return 0; }
$ g++ -g -O0 -l GLX -fsanitize=address,undefined test.cpp
$ ./a.out
# works fine
$ rr record ./a.out
rr: Saving execution to trace directory `/home/milian/.local/share/rr/a.out-6'.
==44279==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
$ rr record --asan ./a.out
rr: Saving execution to trace directory `/home/milian/.local/share/rr/a.out-7'.
==44302==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
So... it doesn't hang anymore, but it doesn't work either. I'm now on gcc 11.1.0 with the sanitizers that ship with that.
$ gcc -print-file-name=libasan.so
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib/libasan.so
$ LD_PRELOAD=`gcc -print-file-name=libasan.so` rr record ./a.out
rr: Saving execution to trace directory `/home/milian/.local/share/rr/a.out-8'.
==64993==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
LD_PRELOAD=/usr/lib/libasan.so.6 rr record ./a.out
rr: Saving execution to trace directory `/home/milian/.local/share/rr/a.out-9'.
==65689==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
$ export LD_PRELOAD=/usr/lib/libasan.so.6.6
$ echo $LD_PRELOAD
/usr/lib/libasan.so.6
$ rr record ./a.out
rr: Saving execution to trace directory `/home/milian/.local/share/rr/a.out-10'.
==79487==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
If you feel lucky you could run this through gdb and check what the issue is:
LD_PRELOAD=/usr/lib/libasan.so.6 gdb --args rr record ./a.out
b RecordSession.cc:2069
b RecordSession.cc:2194
c
# and now stepping and inspecting the conditional stepping
... actually it is obviously intended to work without LD_PRELOAD as the !exe_info.libasan_path.empty() should be false and the path to libasan should be seen from the link symbol, then added before the rr helper lib.
The question is: is this the case? @milianw It would be nice if you could check that nexting through read_exe_info and then nexting through the code for "LD_PRELOAD the syscall interception lib". I'd do this myself but don't have a system that matches yours.
Hello, this ASan runtime does not come first got introduced by 4be0255.
PR #2892 contains patch 5a7d3dd that fixes it, if applied on top of current tip.
(Unfortunately got not yet merged and does not cleanly apply anymore.)
A workaround might be to record with ASAN_OPTIONS=verify_asan_link_order=0 rr record ./a.out.
Activity
khuey commentedon Nov 19, 2020
Can you run with
RR_LOG=all:debugand post the output somewhere?milianw commentedon Nov 19, 2020
rr.log
here's the log file
milianw commentedon Nov 19, 2020
the message
[Scheduler] Using unlimited ticks modeis the last I see, and then it just hangs there.If I then
ctrl + cto quit, the following is logged:khuey commentedon Nov 19, 2020
Are you sure the tracee isn't busy waiting or something? The rr log doesn't show a futex call or anything just before the hang. What does /proc//status show for the tracee when it hangs
milianw commentedon Nov 19, 2020
well yes, it is busy within the futex, that's what the CPU profile shows - it's apparently repeatedly getting woken up and then tries to lock it again - it's on-cpu and burning one core. But that only happens when I try to use rr on a binary compiled with asan - not when I just run it as-is, or when I leave out either asan or rr or both :)
Here's the
/proc/PID/statuscontents:milianw commentedon Nov 19, 2020
To make this more clear:
khuey commentedon Nov 19, 2020
Ok, I misunderstood and thought this was a deadlock.
khuey commentedon Nov 19, 2020
If you
rr record -n, does anything change?Is it possible to
rr packa trace (that you terminated with Ctrl-C) and post that for me to download?milianw commentedon Nov 19, 2020
rr record -ndoes not change anything. Here are two packed traces, -0 is withrr record -n, and -1 is without the-n:rr.asan.tar.gz
khuey commentedon Nov 19, 2020
Thanks. It's definitely the dynamic linker getting confused somehow (and then looping forever)
khuey commentedon Nov 19, 2020
Does running
rr record --asanhelp?If not, try
rr record --env LD_DEBUG=alland lets see what it has to say.milianw commentedon Nov 19, 2020
--asandoes not help. the LD_DEBUG debug output is here:rr.asan.ld_debug.log.gz
khuey commentedon Nov 19, 2020
So we get
and then later
Which seems like a guaranteed recipe for sadness.
This might be related to #2329 (comment). What version of ASAN are you using?
milianw commentedon Nov 19, 2020
I'm using the one provided by GCC v10.2.0, the SO version of libasan is 6.0.0
GitMensch commentedon Jul 16, 2021
Any update here? What version of rr was that, and is it still reproducible with master?
milianw commentedon Jul 19, 2021
Hm I just updated
rrto the latest release, and now it seems it cannot record anasanbinary at all anymore:So... it doesn't hang anymore, but it doesn't work either. I'm now on
gcc 11.1.0with the sanitizers that ship with that.GitMensch commentedon Jul 19, 2021
That seems like an explicit check, what happens if you LD_PRELOAD the asan library before recording?
?
milianw commentedon Jul 19, 2021
Same problem:
GitMensch commentedon Jul 19, 2021
Just to check: what does
ldd ./a.outandldd /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../lib/libasan.sosay?milianw commentedon Jul 19, 2021
I also tested this:
GitMensch commentedon Jul 19, 2021
Last check:
milianw commentedon Jul 19, 2021
Still no dice:
GitMensch commentedon Jul 19, 2021
OK, but
./a.outruns, I assume... (note: this message obviously comes from libasan).It looks like
rrprepends another library and the try to do this after libasan atrr/src/RecordSession.cc
Lines 2067 to 2083 in 779040e
rr/src/RecordSession.cc
Lines 2192 to 2204 in 779040e
If you feel lucky you could run this through gdb and check what the issue is:
LD_PRELOAD=/usr/lib/libasan.so.6 gdb --args rr record ./a.out b RecordSession.cc:2069 b RecordSession.cc:2194 c # and now stepping and inspecting the conditional steppingGitMensch commentedon Jul 19, 2021
... actually it is obviously intended to work without LD_PRELOAD as the
!exe_info.libasan_path.empty()should be false and the path to libasan should be seen from the link symbol, then added before the rr helper lib.The question is: is this the case? @milianw It would be nice if you could check that
nexting throughread_exe_infoand thennexting through the code for "LD_PRELOAD the syscall interception lib". I'd do this myself but don't have a system that matches yours.bernhardu commentedon Jul 19, 2021
Hello, this
ASan runtime does not come firstgot introduced by 4be0255.PR #2892 contains patch 5a7d3dd that fixes it, if applied on top of current tip.
(Unfortunately got not yet merged and does not cleanly apply anymore.)
A workaround might be to record with
ASAN_OPTIONS=verify_asan_link_order=0 rr record ./a.out.bernhardu commentedon Aug 19, 2021
@milianw: That PR got merged now. So I guess this issue should now be again back to the pthread_mutex hang with current rr tip?
milianw commentedon Aug 20, 2021
with current rr master and GCC 11.1 and accompanying sanitizers, everything works as expected now
many thanks!