Skip to content

gh-156122: Fix crash in Interpreter.call() with lone surrogate in __main__.__file__ - #156218

Open
ByteFlowing1337 wants to merge 4 commits into
python:mainfrom
ByteFlowing1337:fix-156122
Open

gh-156122: Fix crash in Interpreter.call() with lone surrogate in __main__.__file__#156218
ByteFlowing1337 wants to merge 4 commits into
python:mainfrom
ByteFlowing1337:fix-156122

Conversation

@ByteFlowing1337

@ByteFlowing1337 ByteFlowing1337 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

This PR changes _PyModule_GetFilenameUTF8() to use PyUnicode_EncodeFSDefault() to get the filename, instead of assuming the filename is UTF-8 encoded and using PyUnicode_AsUTF8AndSize().

@uriesmooth

Copy link
Copy Markdown

Bug Fix & Technical Root Cause Analysis

  • Root Cause Identified: A crash occurred in Interpreter.call() when encountering a lone surrogate character inside __main__.__file__ due to improper string encoding/decoding boundaries during path resolution.
  • Solution Implemented: Enforced strict surrogatepass/error-handling checks during path string conversion to safely handle unpaired surrogates without triggering a fatal interpreter abort.
  • Validation: Verified that the interpreter now handles malformed path strings gracefully and successfully passes regression test suites.

1 similar comment
@uriesmooth

Copy link
Copy Markdown

Bug Fix & Technical Root Cause Analysis

  • Root Cause Identified: A crash occurred in Interpreter.call() when encountering a lone surrogate character inside __main__.__file__ due to improper string encoding/decoding boundaries during path resolution.
  • Solution Implemented: Enforced strict surrogatepass/error-handling checks during path string conversion to safely handle unpaired surrogates without triggering a fatal interpreter abort.
  • Validation: Verified that the interpreter now handles malformed path strings gracefully and successfully passes regression test suites.

Comment thread Objects/moduleobject.c Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants