Open grynspan opened 1 year ago
More detailed STR:
_swift_setWillThrowHandler()
appropriately. _swift_willThrow
isn't getting exported correctly on Windows right now (#62979), so you can't use it directly._swift_setWillThrowHandler()
.Unmanaged
-cast) the first argument from UnsafeMutableRawPointer
to AnyObject
.Debugging this is proving somewhat tricky; the symbols in libswiftCore seem to be incomplete, or LLDB is buggy on Windows, or maybe both. It looks like it's actually blowing up in the second swift_release()
call that gets generated at the end of the catch{}
block. (Though the symbols are pointing to something else entirely, but they're clearly wrong.)
Perhaps this is failing on Darwin/Linux, but since their allocators may allow for more liberal use-after-free, it's less explosive? If so, adding a retain in the handling code manually might solve the problem (i.e. not a Swift bug.)
Trying at desk, just manually inserting a strong retain doesn't appear to prevent the crash.
Description On Windows, the pointer passed to
_swift_willThrow
does not appear to be a valid heap object, and attempting to weakly reference it causes a crash.Steps to reproduce Implement a program that sets the
_swift_willThrow
hook to a function like so:Expected behavior As on Darwin/Linux, this pointer should be safe to bitcast to an object and then weakly reference.
Environment