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

Inlinable function call in a function with debug info must have a !dbg location #4166

Closed
cschlack opened this issue Mar 19, 2017 · 5 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:debugger
Milestone

Comments

@cschlack
Copy link

$ crystal --version

Crystal 0.21.1 (2017-03-14) LLVM 4.0.0

$ crystal spec

Module validation failed: inlinable function call in a function with debug info must have a !dbg location
  %120 = call i8* @__crystal_malloc(i32 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i32))

0x10c31fb33: *raise<String>:NoReturn at ??
0x10d2f0aab: *Crystal::CodeGenVisitor#finish:Nil at ??
0x10d21c37e: *Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil) at ??
0x10dac1ff4: *Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result at ??
0x10c38209a: *Crystal::Command#run:(Bool | Crystal::Compiler::Result | IO::FileDescriptor | Nil) at ??
0x10c3498bd: 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
@cschlack
Copy link
Author

I'm having a hard time figuring out, which code triggers this message. It does not happen in an empty project (crystal init).

Does the message above already give enough hints about the source of the issue?

If not I'm going to do more research...

@bcardiff
Copy link
Member

@cschlack without a bit more of source code is hard to diagnose. Try to reduce as much as possible before sharing please.

If this is blocking you building with --no-debug might help.

@cschlack
Copy link
Author

cschlack commented Mar 20, 2017

Okay, here we go:

file: test.cr

require "spec"
require "http"

test = ""

it "breaks the compiler" do
  test.empty?
end

$ crystal spec test.cr

(running on MacOS 10.11.6)

@bcardiff
Copy link
Member

I reach this:

file: test.cr

def call(&block)
  block.call
end

test = ""

call do
  test.empty?
end

The following passes

$ crystal test.cr --debug
$ crystal test.cr --no-debug

But given a test_main.cr file with

require "./test"
$ crystal build test_main.cr --debug
Module validation failed: inlinable function call in a function with debug info must have a !dbg location
  %73 = call i8* @__crystal_malloc(i32 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i32))

$ crystal build test_main.cr --no-debug

@bcardiff bcardiff added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler topic:compiler:debugger and removed topic:compiler labels Mar 21, 2017
@bcardiff
Copy link
Member

file: test.cr

require "lib_c"
require "c/stdlib"

fun __crystal_malloc(size : UInt32) : Void*
  LibC.malloc(size)
end

class Foo
  @p : (Void* -> Void*)?
end

def call(&block)
  block.call
end

test = 0

call do
  test
end

file: main_test.cr

require "./test"
$ DUMP=1 ./bin/crystal build test.cr --debug --prelude=empty
... ok ...
$ DUMP=1 ./bin/crystal build test_main.cr --debug --prelude=empty
....
Module validation failed: inlinable function call in a function with debug info must have a !dbg location
  %1 = call i8* @__crystal_malloc(i32 ptrtoint (i32* getelementptr (i32, i32* null, i32 1) to i32))

In the first command there are 42 debug locations and in the second command 41 debug locations. One missing :-)

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:debugger
Projects
None yet
Development

No branches or pull requests

3 participants