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

SDK stuck in processing RecursionError:maximum recursion depth exceeded events #2764

Open
rodolfoBee opened this issue Feb 26, 2024 · 4 comments · May be fixed by #3795
Open

SDK stuck in processing RecursionError:maximum recursion depth exceeded events #2764

rodolfoBee opened this issue Feb 26, 2024 · 4 comments · May be fixed by #3795
Assignees
Labels
Triaged Has been looked at recently during old issue triage

Comments

@rodolfoBee
Copy link
Member

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.40.5

Steps to Reproduce

One Sentry user reported an issue where the SDK gets in am apparently endless loop while processing a RecursionError.

I was able to reproduce it with a simple FastAPI project and setting recursion depth limit to 1M:

import resource, sys
sys.setrecursionlimit(10**6)

from fastapi import FastAPI
import logging
from sentry_sdk.integrations.fastapi import FastApiIntegration
import sentry_sdk

sentry_sdk.init(
    dsn="....",
    debug=True,
)

def fibonacci_of(n):
    return fibonacci_of(n)

app = FastAPI()

@app.get("/")
        fibonacci_of(50)
        return {"OH dear"}

The code above creates an infinite recursion, which will eventually trigger a RecursionError:maximum recursion depth exceeded events error that is captured by the SDK.

In a sync environment the SDK will hold the app while processing the event. I suspect it is during stack trace processing, as in this case the stack trace will have 1M frames.

Original report can be found in this internal ticket.

Expected Result

The SDK is able to quickly process the event and attempt to send it, or stop processing in case it takes long freeing the app.

Actual Result

The SDK gets in an seemingly infinite loop.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Feb 26, 2024
@antonpirker
Copy link
Member

Hey @rodolfoBee !

Thanks for bringing this up. We will have a look!

@sentrivana sentrivana added the Type: Bug Something isn't working label Feb 28, 2024
@szokeasaurusrex szokeasaurusrex added the Triaged Has been looked at recently during old issue triage label Sep 11, 2024
@dlahyani
Copy link

@szokeasaurusrex any update on this one?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 16, 2024
@szokeasaurusrex
Copy link
Member

@dlahyani looking into it

@szokeasaurusrex szokeasaurusrex self-assigned this Nov 18, 2024
szokeasaurusrex added a commit that referenced this issue Nov 18, 2024
Only process and send the first 300 stack frames for an error event. This prevents the SDK from causing the program to hang when the SDK captures an error with a very large number of stack frames. Relay anyways [trims events to 250 stack frames](https://github.com/getsentry/relay/blob/aae36669414a1f7c6ef68d5226cb2e96a28f7667/relay-event-normalization/src/trimming.rs#L286), so it is pointless for us to process much beyond that number.

Fixes #2764
@szokeasaurusrex szokeasaurusrex linked a pull request Nov 18, 2024 that will close this issue
@szokeasaurusrex
Copy link
Member

@dlahyani We have a PR in review

@stephanie-anderson stephanie-anderson removed the Type: Bug Something isn't working label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triaged Has been looked at recently during old issue triage
Projects
Status: No status
Status: No status
Development

Successfully merging a pull request may close this issue.

6 participants