Opened 12 hours ago
Closed 10 hours ago
#36716 closed Cleanup/optimization (wontfix)
Debugging can get stuck in an infinite loop if a setting is contained in itself
| Reported by: | Willem Van Onsem | Owned by: | |
|---|---|---|---|
| Component: | Core (Other) | Version: | 5.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Django can get stuck in an infinite loop when cleansing settings.
Indeed, imagine we have a setting:
MY_SETTING = [] MY_SETTING.append(MY_SETTING)
If we now visit a page that raises an error, and Django starts the debugging process, it will get stuck in infinite recursion.
while it might look a bit odd that settings can contain themself, it renders the server unresponsive when an error happens and we run it in debug.
We can for cleansing add a list of visited id(..)s of the settings, and if visited a second time, block the rendering.
Change History (1)
comment:1 by , 10 hours ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Type: | Uncategorized → Cleanup/optimization |
Hello Willem, thank you for taking the time to report this. I understand the situation you are describing. However, this kind of infinite recursion can occur in many parts of Python when language features are used in unintended ways. Since this only affects the local development environment (since debug is on, which is not intended for production use), I think the impact is limited and can be resolved locally during development. It does not seem worth adding extra complexity or overhead to Django’s settings handling to guard against such rare misuse cases.