-
Notifications
You must be signed in to change notification settings - Fork 292
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
Added NPE checkers in Instrumentation Gateway #5383
Conversation
dd-java-agent/appsec/src/main/java/com/datadog/appsec/gateway/GatewayBridge.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked at the code, at there seems to be a race condition indeed. Code follows this pattern:
while (true) {
if (this.respDataSubInfo == null) {
this.respDataSubInfo =
producerService.getDataSubscribers(
KnownAddresses.RESPONSE_STATUS, KnownAddresses.RESPONSE_HEADERS_NO_COOKIES);
}
try {
return producerService.publishDataEvent(this.respDataSubInfo, ctx, bundle, false);
} catch (ExpiredSubscriberInfoException e) {
this.respDataSubInfo = null;
}
}
where respDataSubInfo
is a volatile field. Problem is some thread may have set the variable to null after the null check on another thread. The field needs to be copied to a local variable before the null check.
BenchmarksParameters
See matching parameters
SummaryFound 0 performance improvements and 3 performance regressions! Performance is the same for 19 cases.
|
I'll try to fix the race condition issue in next PR |
What Does This Do
The temporary solution. Added Null checker to avoid an NPE (logged to debug level).
Motivation
Reported NPE:
Additional Notes