Repository navigation
Conversation
Avoid shifting a negative value
This was raised by asan nightly runs
> Task :ddprof-test:testClasses
ddprof-lib/src/main/cpp/vmStructs.cpp:816:34: runtime error: left shift of negative value -1
#0 0x7f6f6bd20631 in ScopeDesc::readInt()
#1 0x7f6f6bce54a6 in ScopeDesc::decode(int)
#2 0x7f6f6bce7fb0 in StackWalker::walkVM(void*, ASGCT_CallFrame*, int, void const*, void const*)
|
🔧 Report generated by pr-comment-scanbuild Scan-Build Report
Bug Summary
Reports
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (c >= 192) { | ||
| for (int shift = 6; ; shift += 6) { | ||
| c = *_stream++; | ||
| if (c < _unsigned5_base) { |
There was a problem hiding this comment.
is this not an indication of a race condition and we should retry the read ?
The previous byte indicated we were expecting something, so having 0 here is unexpected.
There was a problem hiding this comment.
reads of NMethods are generally racy - we're reading them from a process-wide codecache which can change even when the sampled thread is halted in a signal handler.
There was a problem hiding this comment.
The more valid fix would then be to bail out.
There was a problem hiding this comment.
It seems that the problem is rather insidious - the _unsigned5_base is set up depending on the JVM version but that is subtly broken for Java 8 - see #136
I am going to fix that problem first and if that does not stop the asan errors we can revisit this later.
There was a problem hiding this comment.
It seems that after #142 we are not getting to shifting a negative value.
I would keep this PR open for ~1 week to be sure the problem is fixed and then close it.
|
#142 fixed the underlying cause. Closing this PR. |
What does this PR do?:
Avoid shifting a negative value
This was raised by asan nightly runs
Motivation:
Additional Notes:
How to test the change?:
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance.Unsure? Have a question? Request a review!