GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Obtain class IDs under the sample lock by apangin · Pull Request #1809 · async-profiler/async-profiler Conversation
Collaborator
DescriptionFixes use-after-free in This PR moves class name resolution under Related issuesHow has this been tested?A stress test that reproduces the crash: 32 threads taking ReentrantLocks and allocating instances of 20000 classes, while the main thread restarts the profiler every 50 ms with By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
linux-x64
linux-arm64
macos
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (updateCounter(_total_duration, duration, _interval)) { | ||
| recordContendedLock(PARK_SAMPLE, park_start_time, park_end_time, lock_name, park_blocker, time); | ||
| // Profiling session might have been stopped or restarted while the thread was parked | ||
| if (_enabled && park_start_time >= _start_time) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this still potentially race?
_enabled is set to true as part of installTraps which happens way earlier than the set of _start_time
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
also as a note _start_time is a normal static value, we should probably change it to volatile or maybe use atomics?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
volatile or atomics are redundant: compiler can't cache values across callbacks, and there is no happens-before requirement here. Opaque read is enough.
There is no race with respect to where _enabled is set, but I noticed a different bug: since park traps are no longer uninstalled, lock samples will continue being reported during the next profiling session started without lock. I fixed that by resetting _start_time in LockTracer::stop.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| void setClassSignature(const char* class_sig); | ||
|
|
||
| // Must be called under the sample lock (Profiler::_locks). | ||
| // May allocate; do not call in asynchronous signal handlers. |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is called for recordAllocationOutsideTLAB & recordAllocationInNewTLAB which can happen in asynchronous signal handlers (allocaTracer)
Wouldn't that cause an issue?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
AllocTracer's handlers are synchronous - they are only called at the specific locations when a thread is known not to be inside malloc.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.