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

Setting atomic reference to nil crashes the compiler #4062

Closed
ggiraldez opened this issue Feb 22, 2017 · 0 comments
Closed

Setting atomic reference to nil crashes the compiler #4062

ggiraldez opened this issue Feb 22, 2017 · 0 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Milestone

Comments

@ggiraldez
Copy link
Contributor

The following code crashes the compiler:

class Foo
end

a = Atomic(Foo?).new nil

a.set Foo.new
a.set nil

The full error message is:

Module validation failed: Stored value type does not match pointer operand type!
  store atomic volatile %Nil zeroinitializer, %Foo** %0 seq_cst, align 8, !dbg !17
 %Foo*
0x10da5dc23: *raise<String>:NoReturn at ??
0x10e9ad3dc: *Crystal::CodeGenVisitor#finish:Nil at ??
0x10e8e7f7e: *Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil) at ??
0x10f1364f4: *Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result at ??
0x10f1d8019: *Crystal::Command#run_command<Bool>:Nil at ??
0x10dac3c71: *Crystal::Command#run:(Bool | Crystal::Compiler::Result | IO::FileDescriptor | Nil) at ??
0x10da8c62d: main at ??

Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

The error is triggered at the second set call.

Seen on Crystal 0.20.5 and 0.21.0.

@ggiraldez ggiraldez added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Feb 22, 2017
@asterite asterite added this to the Next milestone Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Projects
None yet
Development

No branches or pull requests

2 participants