-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add null check for ThreadLocalStoragePointer in COMUnhandledExceptionFilter to prevent crash on Windows #123826
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
base: main
Are you sure you want to change the base?
Conversation
…ndledExceptionFilter Co-authored-by: jkotas <[email protected]>
|
@copilot Revert all changes you have made. Instead, implement the fix mentioned in #115476 (comment) |
…ExceptionFilter Co-authored-by: jkotas <[email protected]>
Reverted the previous implementation and implemented a more minimal fix that only protects the GetThreadNULLOk() call with __try/__except. The new approach stores the thread pointer once and reuses it, avoiding multiple TLS access attempts. Changes in commit 0ef7da5. |
|
@copilot Please revert all changes you have made, DO NOT use any __try/__catch, and just implement the fix that it similar to the code that I have linked to. The fix should early out from |
…Filter Co-authored-by: jkotas <[email protected]>
Reverted all previous changes and implemented the fix using NtCurrentTeb()->ThreadLocalStoragePointer null check. The function now returns early when TLS is not available, without using any __try/__except. Changes in commit 71288f5. |
Co-authored-by: jkotas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a defensive early-return in COMUnhandledExceptionFilter on Windows when TLS is not yet initialized, preventing a crash when the unhandled exception filter runs during very early thread startup.
Changes:
- Add a Windows-only check for
NtCurrentTeb()->ThreadLocalStoragePointer == NULLat the start ofCOMUnhandledExceptionFilterto avoid touching CLR TLS-backed state too early.
Added a null check for
NtCurrentTeb()->ThreadLocalStoragePointerat the beginning ofCOMUnhandledExceptionFilteron Windows to avoid crashing inside coreclr.dll when there is an unhandled exception early during thread initialization. We have similar check in other global EH handlers.Fixes #115476