-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
SIGSEGV when accessing tuple element from partial function #2609
Comments
This is a bug in the union-to-tuple cast code generation. |
FYI, i am hitting the same issue, when calling a method like: fun generate_and_shrink(): ((U8^ | Bool^), Iterator[(U8^ | Bool^)]) |
I was able to reproduce the issue with the following snippet: actor Main
new create(env: Env) =>
try
match _bug(env.args(0)?)?
| (let u: USize, let bn: Bool) => env.out.print("bool")
| (let u: USize, let bn: None) => env.out.print("none")
end
end
fun _bug(s: String): (USize, (Bool | None)) ? =>
match s
| "./scratch" => (0, true)
| "anything" => (0, None)
else
error
end This one seems to show that it is both the match that tries to get a tuple element and the direct tuple element access being executed on the tuple of unions result The segfault does not happen, when using no primitive types (i.e. replacing USize and Bool with String). Looking at the faulty address it seems to interpret the USize value of 0 as a memory address. I don't know if this is the problem or the fact that the USize does not seem to be a pointer but a plain machine word as tuple element. |
@malthe can you test this again to see if you're still having the issue? |
It's possible that the method body returns a subtype of the return type. For example, a return value with type `((U32, U32) | (U32, None))` is legal for a method with return type `(U32, (U32 | None))`, but it requires a cast. Fixes ponylang#2609, ponylang#2808
In the first example, the match's inferred type is The crash goes away if one changes it to something like: actor Main
new create(env: Env) =>
try _bug()?._2 as Bool end
fun _bug(): (USize, (Bool | None)) ? =>
let x: (USize, (Bool | None)) = match "bug"
| "bug" => (0, true)
| "anything" => (0, None)
else error end
x |
The segfault occurs regardless of the --debug flag.
Compiler version:
0.21.3-98ce091 [release]
llvm 3.9.1 -- msvc-15-x64
llvm 3.9.1 -- gcc (Ubuntu/Linaro 6.3.0-18ubuntu2~14.04) 6.3.0 20170519
The bugged code:
The segfault
gdb backtrace:
I do not currently have a proposed solution but the bug itself seems simple to reproduce.
The text was updated successfully, but these errors were encountered: