Crystal: Compiler crash for unknown matter

Created on 29 Jan 2018  路  11Comments  路  Source: crystal-lang/crystal

I'm developing a big project, and while trying to run it I got a compiler crash; It does not give any particular message, so the nature of the bug is unknown to me.

I report here the backtrace:

Module validation failed: !dbg attachment points at wrong subprogram for function
!48 = distinct !DISubprogram(name: "new_string", linkageName: "new_string", scope: !41, file: !41, line: 87, type: !6, isLocal: true,isDefinition: true, scopeLine: 87, isOptimized: false, unit: !0, variables: !2)
%"LinCAS::Internal::LcString"* ()* @"*LinCAS::Internal::new_string:LinCAS::Internal::LcString"
  %2 = call %"LinCAS::ClassEntry"** @"~LinCAS::Internal::StringClass:read"(), !dbg !52
!52 = !DILocation(line: 32, column: 16, scope: !53)
!53 = distinct !DISubprogram(name: "lc_build_class_only", linkageName: "lc_build_class_only", scope: !5, file: !5, line: 31, type: !6, isLocal: true, isDefinition: true, scopeLine: 31, isOptimized: false, unit: !0, variables: !2)
!53 = distinct !DISubprogram(name: "lc_build_class_only", linkageName: "lc_build_class_only", scope: !5, file: !5, line: 31, type: !6, isLocal: true, isDefinition: true, scopeLine: 31, isOptimized: false, unit: !0, variables: !2)
!dbg attachment points at wrong subprogram for function
!116 = distinct !DISubprogram(name: "lc_class_class", linkageName: "lc_class_class", scope: !5, file: !5, line: 147, type: !6, isLocal: true, isDefinition: true, scopeLine: 147, isOptimized: false, unit: !0, variables: !2)
i32* (%"(LinCAS::BaseEntry+ | LinCAS::Internal::BaseC+ | LinCAS::Internal::BaseS+)")* @"*LinCAS::Internal::lc_class_class<(LinCAS::BaseEntry+ | LinCAS::Internal::BaseC+ | LinCAS::Internal::BaseS+)>:LinCAS::BaseEntry+"
  %12 = call %"LinCAS::ModuleEntry"** @"~LinCAS::Internal::LcModule:read"(), !dbg !121
!121 = !DILocation(line: 28, column: 16, scope: !122)
!122 = distinct !DISubprogram(name: "lc_build_module_only", linkageName: "lc_build_module_only", scope: !123, file: !123, line: 27, type: !6, isLocal: true, isDefinition: true, scopeLine: 27, isOptimized: false, unit: !0, variables: !2)
!122 = distinct !DISubprogram(name: "lc_build_module_only", linkageName: "lc_build_module_only", scope: !123, file: !123, line: 27, type: !6, isLocal: true, isDefinition: true, scopeLine: 27, isOptimized: false, unit: !0, variables: !2)

???
???
???
???
???
???
???
???

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

Since the project is too big to give a representation, this is the link to the repository: https://github.com/max-codeware/crLinCAS

To run it on the command line: crystal src/LinCAS.cr
Thanks to everyone who can help me in finding a solution

bug compiler topicdebugger

Most helpful comment

Don't think so. Compiling with --no-debug is only a workaround. There is still something wron that needs to be fixed. Maybe this is already tracked by another issue, but if not, this should stay open.

All 11 comments

Workaround: compile with --no-debug.

Seems to work. Thanks a lot!

You should close this issue now I think.

Don't think so. Compiling with --no-debug is only a workaround. There is still something wron that needs to be fixed. Maybe this is already tracked by another issue, but if not, this should stay open.

Hm ok yes you are right.

I am getting this same error.

Module validation failed: !dbg attachment points at wrong subprogram for function
!21 = distinct !DISubprogram(name: "save", linkageName: "save", scope: !14, file: !14, line: 21, type: !6, isLocal: true, isDefinition: true, scopeLine: 21, isOptimized: false, unit: !0, variables: !2)
i1 (%Ninja*)* @"*Ninja#save:Bool"
  %16 = call %"Arango::Collection"** @"~Ninja::collection:read"(), !dbg !23
!23 = !DILocation(line: 21, column: 1, scope: !24)
!24 = distinct !DISubprogram(name: "db", linkageName: "db", scope: !14, file: !14, line: 21, type: !6, isLocal: true, isDefinition: true, scopeLine: 21, isOptimized: false, unit: !0, variables: !2)
!24 = distinct !DISubprogram(name: "db", linkageName: "db", scope: !14, file: !14, line: 21, type: !6, isLocal: true, isDefinition: true, scopeLine: 21, isOptimized: false, unit: !0, variables: !2)

Crystal::CodeGenVisitor#finish:Nil
Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil)
Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result
Crystal::Command#run_command<Bool>:Nil
Crystal::Command#run:(Bool | Crystal::Compiler::Result | IO::FileDescriptor | Nil)
main

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
FAIL

Tried cr run src/arango_model.cr --no-debug:

Invalid memory access (signal 11) at address 0x7ffedf8daff8
[0x10fb586cb] *CallStack::print_backtrace:Int32 +107
[0x10fb38d28] __crystal_sigfault_handler +72
[0x7fff6d44df5a] _sigtramp +26
[0x10fbfa605] *Ninja::db:NoReturn +5
[0x10fbfa609] *Ninja::db:NoReturn +9 (524042 times)
[0x10fb3b876] ~Ninja::collection:init +6
[0x10fb3b861] ~Ninja::collection:read +33
[0x10fbfa4a0] *Ninja#save:Bool +400
[0x10fb26abc] __crystal_main +1852
[0x10fb3ba29] *_crystal_main<Int32, Pointer(Pointer(UInt8))>:Nil +9
[0x10fbfdfe9] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +9
[0x10fbfdec0] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +48
[0x10fb31b69] main +9
FAIL

I'm not very far into my project but I put up the code for reference here:

https://github.com/lodestone/arango_model

System Details

  • macOS 10.13.3 (17D102)
$ crystal --version
Crystal 0.24.2 (2018-03-10)

LLVM: 5.0.1
Default target: x86_64-apple-macosx

Thoughts

It seems to be triggered by the following code from src/arango_model.cr:47

chuck_params = {"name" => "Chuck", "age" => 55}
chuck = Ninja.new(chuck_params)
chuck.save # Adding this line causes the compiler to output the error above

When I added the .save call, I got this error. The save is defined in src/arango_model/persistence.cr:11

I made some changes to arangocr which I haven't pushed upstream so I included the lib dir in my project for debugging purposes.

I just got this error as well on here https://github.com/luckyframework/lucky/pull/541 Running the spec with --no-debug at the end makes the error go away.

Crystal 0.25.1 (2018-06-30)

LLVM: 5.0.2
Default target: x86_64-apple-macosx

@jwoertink @max-codeware Does this still reproduce for you guys?

Given the lack of minimal examples here I'm inclined to close this anyway though in favor of a new report with a smaller reproducing example.

With the latest releases of Crystal that error is no longer generated on my project, even without
--no-debug flag

We changed how Lucky works after that point, so we don't run in to this anymore. It's possible it's fixed. I don't think I have a way to reproduce now.

Thank you both, I guess we can always reopen or open a new issue then :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jhass picture jhass  路  3Comments

asterite picture asterite  路  3Comments

lgphp picture lgphp  路  3Comments

RX14 picture RX14  路  3Comments

asterite picture asterite  路  3Comments