Skip to content
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

Crash at runtime when using typed throws #73051

Open
Jnosh opened this issue Apr 16, 2024 · 0 comments
Open

Crash at runtime when using typed throws #73051

Jnosh opened this issue Apr 16, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software typed throws Feature → error handling → throws & rethrows: Typed throws

Comments

@Jnosh
Copy link
Contributor

Jnosh commented Apr 16, 2024

Description

No response

Reproduction

The following snippet crashes with EXC_BAD_ACCESS (code=1, address=0x0) in swift_willThrowTyped:

enum MyError: Error {
    case failed
}

func foo() throws(MyError) {
    throw MyError.failed
}

try foo()

Stack dump

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes:       0x0000000000000001, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [37760]

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                           	               0x0 ???
1   TypedThrows                   	       0x10022f6cc $s11TypedThrows3fooyyAA7MyErrorOYKF + 40 (main.swift:7)
2   TypedThrows                   	       0x10022f64c main + 32 (main.swift:10)
3   dyld                          	       0x19404e0e0 start + 2360


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x000000016fbd3430   x1: 0x00000001002300f0   x2: 0x00000001fc18c030   x3: 0x00000001fc18c030
    x4: 0x00000001a45cb7d4   x5: 0x0000000200c13ad8   x6: 0x7366657272657075   x7: 0x0000000000000000
    x8: 0x000000000000270f   x9: 0x0000000100234000  x10: 0x0000000000000004  x11: 0x00000001fc18c030
   x12: 0x0000000000000000  x13: 0x000000010022fee0  x14: 0x000000010022fee4  x15: 0x00000001fc18c050
   x16: 0x0000000000000000  x17: 0x000000010022f888  x18: 0x0000000000000000  x19: 0x0000000100645fb0
   x20: 0x000000010022f62c  x21: 0x0000000000000000  x22: 0x0000000100645910  x23: 0x000000016fbd3430
   x24: 0x000000016fbd3470  x25: 0x00000001940c22db  x26: 0x0000000000000000  x27: 0x0000000000000000
   x28: 0x0000000000000000   fp: 0x000000016fbd3330   lr: 0x000000010022f8e8
    sp: 0x000000016fbd3310   pc: 0x0000000000000000 cpsr: 0x60001000
   far: 0x0000000000000000  esr: 0x82000006 (Instruction Abort) Translation fault

Expected behavior

Then snippet should not crash when trying to use typed throws.

Environment

Apple Swift version 6.0-dev (LLVM c5ac128e678cf31, Swift 59748d9)
Target: arm64-apple-macosx14.0

Additional information

No response

@Jnosh Jnosh added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Apr 16, 2024
@Jnosh Jnosh changed the title Runtime crash when using typed throws Crash at runtime when using typed throws Apr 16, 2024
@hborla hborla added typed throws Feature → error handling → throws & rethrows: Typed throws and removed triage needed This issue needs more specific labels labels Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software typed throws Feature → error handling → throws & rethrows: Typed throws
Projects
None yet
Development

No branches or pull requests

2 participants