-
-
Notifications
You must be signed in to change notification settings - Fork 441
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
UncaughtExceptionHandlerIntegration leaks memory #3266
Comments
I might be reading it wrong, but it looks like |
Yes I agree with you Roman, that does seem to be the case Sadly I can't really give any detail on how this would be the case because it's a library used by a plugin used by a framework, all of which I have no direct control over aside from config From what I understand from debugging the whole stack, init should only be called once at framework startup when the plugin is initialised, and captureEvent is called for each event to be logged I have no idea how or why the register method is being called multiple thousands of times, but my assumption would have been that init would be idempotent |
hm, but do you see that My explanation would be that we just get into a infinite recursive call, because we delegate to sentry-java/sentry/src/main/java/io/sentry/UncaughtExceptionHandlerIntegration.java Line 134 in 28c9a83
and since it's our own handler, we'll get into the loop. One improvement from our side would be to just check if |
also, just realised - we don't really support this case out of the box (using our sdk in a library), because there might be another library/plugin which uses sentry and then they will have a conflict (including sending events to a wrong dsn/project). I assume this is precisely what happens here actually. |
my evidence for this is that
I can categorically guarantee that is not the case for my particular situation, we only have this one plugin which uses the sentry SDK, and no other component in the entire system makes use or reference of the Sentry SDK in any way As far as I can understand it, the framework we use only initialises one instance of the plugin, and that one plugin instance only calls As a side note- hypothetically speaking, if calling If crashing doesn't seem like a palatable choice then I would at least expect |
yeah the sentry-java/sentry/src/main/java/io/sentry/Sentry.java Lines 222 to 228 in 28c9a83
without testing it locally however, I cannot say if we've overlooked something to clean up between multiple |
no worries. Thank you for your attention Roman I apologise for the somewhat vague issue report, but I'm only able to tell you as much as I know myself 😅
Not sure where that is expected to be logged (in sentry itself or in stderr/stdout), but I don't see any evidence of it anywhere. My assumption is that |
Hi @xenomote, Thank you for your patience, we'll keep you updated. |
excellent, thanks for your attention I am not personally blocked on this issue, because I wasn't using this functionality anyway- I just disabled in the init config. But for the sake of others it would still be positive to fix 👍 |
🎉 |
Integration
sentry
Java Version
17
Version
7.6.0
Steps to Reproduce
Cannot be very specific because sentry SDK is being used by a plugin within a framework, and within that environment we cannot reproduce the issue unless we are receiving production traffic
Expected Result
no memory leak
Actual Result
the UncaughtExceptionHandlerIntegration appears to occupy the majority of the heap, eventually resulting in memory exhaustion and a crash.
On auditing the code it appears that
sentry-java/sentry/src/main/java/io/sentry/UncaughtExceptionHandlerIntegration.java
Lines 68 to 81 in 28c9a83
causes a stack to form, which prevents any of the exeption handlers from being GC'd and results in OOM. No idea why that register method is being called over and over again
we are planning to simply turn the UncaughtExceptionHandler off in the options to resolve this issue, but it's weird that the Sentry SDK apparently behaves this way by default
The text was updated successfully, but these errors were encountered: