-
Notifications
You must be signed in to change notification settings - Fork 566
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
CRASH using libpthread in a client #956
Comments
From [email protected] on October 19, 2012 03:18:33 forgot to mention, this was first discussed in: https://groups.google.com/forum/?fromgroups=#!topic/DynamoRIO-Users/GkVL9IxxdnQ |
From [email protected] on November 20, 2012 15:48:35 I started to debug this. The systemc header includes sc_ver.h which creates a little static global in every file that includes it. If I don't do anything to make sure the client is linking against systemc, it wil crash when it tries to call the constructor. More info: You may have to put the systemc library on LD_LIBRARY_PATH. Owner: [email protected] |
From [email protected] on November 20, 2012 16:02:04 Going further and actually linking it in, it looks like systemc wants to use pthreads, which we don't support. It crashes in libpthread initialization: If systemc doesn't actually use pthreads but just links against it, we could provide a no-op compatibility layer so you can load systemc and use it's threading unrelated components. If not, supporting pthreads is a much bigger work item that I don't think we'll implement soon. Status: Started |
From [email protected] on November 21, 2012 06:50:34 The idea behind
If systemc doesn't actually use pthreads but just links against it, we We were planning to cast one of the function parameters that we get as a |
From [email protected] on November 21, 2012 15:54:32 Yes, apps that use pthreads (or any other threading) are definitely supported. Clients, however, can't use pthreads. It integrates tightly into the loader for TLS support among other things, and it interferes with the isolation of DR and the client from the app. There is support in DR for launching threads from the client using dr_create_client_thread(): http://dynamorio.org/docs/dr__tools_8h.html#ac6b80b83502ff13d4674b13e7b30b555 In theory, someone could figure out how to map pthreads onto our primitives, but it's pretty tricky. Anyway, it sounds like you don't actually need pthreads at runtime, you just depend on some code that is linked with code that depends on pthreads. You could try something gross like editing out the PT_NEEDED phdr for pthreads. |
From [email protected] on November 27, 2012 10:43:57 Looked into this a bit more, and it's crashing here in __pthread_initialize_minimal_internal(): I'm assuming its that _dl_error_catch_tsd global that's set to zero, and then we do a function call to NULL. |
While the docs do say we don't support a private libpthread, it seems best to also have the private loader give a warning, to help diagnose problems like https://groups.google.com/forum/#!topic/DynamoRIO-Users/Sk4D0w2LC7s. |
Adds a new extension "drcallstack" which provides callstack walking facilities. This initial implementation adds a libunwind-based implementation and targets only Linux for now. Adds an interface to walk one step at a time over callstack frames. The implementation converts the dr_mcontext_t into libunwind's context structure and invokes the libunwind step API. Getting libunwind to work requires several steps: + Ignore libpthread exports when importing any symbol that does not start with "pthread". Otherwise libunwind crashes using __errno_location from libpthread instead of from libc. We add a warning when a private libpthread is loaded to help diagnose any other potential problems (xref #956). + Have dl_iterate_phdr operate on app libraries instead of private libraries. This is done with a new flag and logic in the redirection code, with the flag set for libraries named "libunwind*". A statically-linked libunwind is not supported. Updates drwrap to set the mcontext pc field to simplify usage. Adds a test and documentation. Adds a sample client showing how to use this library. Issue: #2414, #956
Adds a new extension "drcallstack" which provides callstack walking facilities. This initial implementation adds a libunwind-based implementation and targets only Linux for now. Adds an interface to walk one step at a time over callstack frames. The implementation converts the dr_mcontext_t into libunwind's context structure and invokes the libunwind step API. Getting libunwind to work requires several steps: + Ignore libpthread exports when importing any symbol that does not start with "pthread". Otherwise libunwind crashes using __errno_location from libpthread instead of from libc. We add a warning when a private libpthread is loaded to help diagnose any other potential problems (xref #956). + Have dl_iterate_phdr operate on app libraries instead of private libraries. This is done with a new flag and logic in the redirection code, with the flag set for libraries named "libunwind*". A statically-linked libunwind is not supported. Updates drwrap to set the mcontext pc field to simplify usage. Adds a test and documentation. Adds a sample client showing how to use this library. Installs libunwind for cross-compiling and for 32-bit x86 using manual download and unpack steps, as there are no ready-made packages (GA CI uses a microsoft.com repository which has only 64-bit libunwind, and file conflicts are hit when trying to add a new repository for 32-bit only). Issue: #2414, #956
In case it's not clear, a warning on libpthread being loaded was added in PR #5154:
|
Adds private loader redirection of open, close, read, and write to DR's syscall-wrapper versions (plus file descriptor isolation, for open and close). The libc write invokes pthread code for cancel features, and we are not able to create a private libpthread or isolate pthread resources (#956) which leads to poor interactions with application pthread uses and observed hangs. Tested on the AArch64 Jenkins machine where these tests all hung every 5 to 10 runs in release build before and now they succeed 20,000 times in a row: -------------------------------------------------- derek@dynamorio:~/dr/build_rel$ for i in sim.threads\$ sim.TLB-threads sim.coherence sim.threads-with; do echo $i; ctest --repeat-until-fail 20000 -R $i > RUN-$i 2>&1; done sim.threads$ sim.TLB-threads sim.coherence sim.threads-with derek@dynamorio:~/dr/build_rel$ grep -c Passed RUN-* RUN-sim.coherence:20000 RUN-sim.threads$:20000 RUN-sim.threads-with:20000 RUN-sim.TLB-threads:20000 derek@dynamorio:~/dr/build_rel$ grep failed RUN-* RUN-sim.coherence:100% tests passed, 0 tests failed out of 1 RUN-sim.threads$:100% tests passed, 0 tests failed out of 1 RUN-sim.threads-with:100% tests passed, 0 tests failed out of 1 RUN-sim.TLB-threads:100% tests passed, 0 tests failed out of 1 -------------------------------------------------- While at it, removes drcachesim.invariants which was tested as well and has no failures. Issue: #4928, #4954, #2417, #956 Fixes #4928 Fixes #4954 Fixes #2892
Adds private loader redirection of open, close, read, and write to DR's syscall-wrapper versions (plus file descriptor isolation, for open and close). The libc write invokes pthread code for cancel features, and we are not able to create a private libpthread or isolate pthread resources (#956) which leads to poor interactions with application pthread uses and observed hangs. Tested on the AArch64 Jenkins machine where these tests all hung every 5 to 10 runs in release build before and now they succeed 20,000 times in a row: ``` -------------------------------------------------- derek@dynamorio:~/dr/build_rel$ for i in sim.threads\$ sim.TLB-threads sim.coherence sim.threads-with; do echo $i; ctest --repeat-until-fail 20000 -R $i > RUN-$i 2>&1; done sim.threads$ sim.TLB-threads sim.coherence sim.threads-with derek@dynamorio:~/dr/build_rel$ grep -c Passed RUN-* RUN-sim.coherence:20000 RUN-sim.threads$:20000 RUN-sim.threads-with:20000 RUN-sim.TLB-threads:20000 derek@dynamorio:~/dr/build_rel$ grep failed RUN-* RUN-sim.coherence:100% tests passed, 0 tests failed out of 1 RUN-sim.threads$:100% tests passed, 0 tests failed out of 1 RUN-sim.threads-with:100% tests passed, 0 tests failed out of 1 RUN-sim.TLB-threads:100% tests passed, 0 tests failed out of 1 -------------------------------------------------- ``` While at it, removes drcachesim.invariants which was tested as well and has no failures, under the theory that the original failures were these same release-build hangs. Today, it's a debug-only test. Issue: #4928, #4954, #2417, #956 Fixes #4928 Fixes #4954 Fixes #2892
From [email protected] on October 19, 2012 06:16:31
For the Summary, please follow the guidelines at https://code.google.com/p/dynamorio/wiki/BugReporting and use one of the CRASH, APP CRASH, HANG, or ASSERT keywords What version of DynamoRIO are you using? 3.2.0-3 What operating system version are you running on? 64 bit Ubuntu 12.04
Linux kernel 3.2.0-32-generic What application are you running? a simple systemc example:
What happens when you run with debug build ("-debug" flag to drrun/drconfig/drinject)? Same crash with/without
-debug
flag. This is the output when run with-debug
:<Starting application a.out (6490)>
<Initial options = -client_lib '/PATH/TO/DR/
bin/libwrapperpp.so;0;' -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_ca
ll 0 -no_inline_ignored_syscalls -no_native_exec -no_indcall2direct >
Segmentation fault (core dumped) What steps will reproduce the problem? I have prepared a minimal example of the client where I observe the crash:
If I exclude
#include \<systemc>
it works fine. If I include, I get a segmentation fault. What is the expected output? What do you see instead? Is this an application crash, a DynamoRIO crash, a DynamoRIO assert, or a hang (see https://code.google.com/p/dynamorio/wiki/BugReporting and set the title appropriately)? I would expect just the output of my systemc program since I haven't really done anything in my client. Please provide any additional information below. Just to clear it out, DynamoRIO works fine with SystemC applications, it just doesn't like it when I try to include systemc header in my client.Original issue: http://code.google.com/p/dynamorio/issues/detail?id=956
The text was updated successfully, but these errors were encountered: