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

Avoid standard heap in droption and drcachesim init #4660

Open
derekbruening opened this issue Jan 7, 2021 · 0 comments
Open

Avoid standard heap in droption and drcachesim init #4660

derekbruening opened this issue Jan 7, 2021 · 0 comments

Comments

@derekbruening
Copy link
Contributor

While typical shared-library usage of DR isolates a client's heap from the app, when DR and clients are statically linked into the application there is unfortunately no way to isolate. We're already using placement new at runtime in drcachesim to support static usage. We'd been assuming that application heap usage at client init time was relatively safe, for internally-triggered attach where the init thread is at a clean ABI point. However, we have hit issues with application heap and tools that replace the allocator with a scheme involving SIGSEGV for detecting bugs. During attach, the init thread then raises SIGSEGV, running into signal delivery problems under #1921. While we plan to solve all the #1921 cases in any case, it may be worth providing app-heap-free options, for possible ptrace-attach with static DR or other cases where worse problems arise, or cases where clients need to parse options post-init-time.

Xref #4640 (comment) where using std::string with a custom allocator that invokes dr_global_alloc for all droption strings does not work with static DR, due to the static initializers that run natively at process init time. An allocator that looks at dynamo_heap_initialized does not work either, as it doesn't know how to free.

A possible solution is to store only literal char* types at init time and only construct std::string at parse time.

Beyond droption, func_trace has a std::vector and std::set which can easily be made to use a custom allocator.

We may want to make a C++ allocator that uses dr_global_heap part of a library exported by DR. Or bundled with droption.

derekbruening added a commit that referenced this issue May 24, 2022
derekbruening added a commit that referenced this issue May 25, 2022
Fixes a bug where drcachesim -offline complained about an open file
across a fork.  This bug blocked tracing of SPECCPU perlbench.

Adds a new test of drcachesim -offline with an app that forks.  As is,
this matched the -satisfy_w_xor_x test regex, and I tried to make it
work with that option by fixing a file close bug here.  However, I did
not have time to figure out another bug which I filed as #5499.  I
thus tightened the "fork" regex to exclude this test from
-satisfy_w_xor_x.  I also had to disable the malloc check and issue a
warning for static link offline across fork due to the unsolved #4660.

Issue: #5495, #5499, #4660
Fixes #5495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant