sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

SDK stuck in processing RecursionError:maximum recursion depth exceeded events

Open rodolfoBee opened this issue 11 months ago • 1 comments

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.

rodolfoBee avatar Feb 26 '24 13:02 rodolfoBee

Hey @rodolfoBee !

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

antonpirker avatar Feb 28 '24 11:02 antonpirker