-
-
Notifications
You must be signed in to change notification settings - Fork 161
fix(runtime): permit dynamic construct throws to unwind #8873
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix catchable dynamic-constructor TypeErrors aborting at the runtime construct boundary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 264
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 50370
🏁 Script executed:
Repository: PerryTS/perry
Length of output: 14600
🌐 Web query:
Rust Reference C-unwind ABI non-unwinding ABI panic unwinding across extern C function boundary💡 Result:
In Rust, the behavior of panic unwinding across an FFI boundary depends on the specified Application Binary Interface (ABI) and the panic strategy [1][2]. The "C-unwind" ABI (and other variants like "system-unwind") is explicitly designed to support safe unwinding across FFI boundaries [3][4][5]. When a function is declared with an "-unwind" suffix (e.g., extern "C-unwind"), the compiler allows Rust panics or foreign exceptions to traverse these frames, provided the
panic=unwindstrategy is used [3][2]. This enables scenarios such as a C++ exception propagating through Rust frames or a Rust panic unwinding through C++ frames [3][6]. Conversely, standard ABIs (such as "C", "system", etc.) do not permit unwinding [3][2]. If a Rust panic attempts to cross an FFI boundary defined with a non-unwinding ABI (likeextern "C"), the Rust runtime is designed to safely abort the process rather than allowing the panic to propagate, provided thepanic=unwindstrategy is active [7][2][8]. However, the reverse scenario—a foreign exception (e.g., from C++) entering Rust through anextern "C"boundary—is considered undefined behavior (UB), as Rust assumes foreign code called via standard ABIs will not unwind [1][2]. Key points regarding these boundaries: - "C-unwind" ABI: Supports unwinding in both directions when usingpanic=unwind[3][2]. - Standard ABIs (e.g., "C"): Do not support unwinding. Rust panics attempting to escape these boundaries will trigger a safe abort [7][2]. - Undefined Behavior: Occurs when a foreign exception enters Rust through a non-unwinding ABI boundary or when a function is called with an ABI that does not match its definition [1][2]. - Panic=abort: When the program is compiled withpanic=abort, anypanic!will immediately abort the process, regardless of the ABI specified [2][9].Citations:
Propagate
C-unwindthroughjs_new_function_construct_with_new_target.If a
TypeErrorunwinds from its calls tojs_new_function_construct, Rust aborts at the wrapper'sextern "C"boundary instead of reaching the JavaScript catch landing pad. Change the wrapper toextern "C-unwind"and add a matching four-argument function-pointer assertion.🤖 Prompt for AI Agents
Source: MCP tools