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

Attempt to bind a C library resulted in a compiler error #5996

Closed
sherjilozair opened this issue Apr 23, 2018 · 6 comments
Closed

Attempt to bind a C library resulted in a compiler error #5996

sherjilozair opened this issue Apr 23, 2018 · 6 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. status:duplicate topic:compiler

Comments

@sherjilozair
Copy link

sherjilozair commented Apr 23, 2018

This is the line which caused the error: https://github.com/sherjilozair/cudnn.cr/blob/master/spec/cudnn_spec.cr#L18

The relevant pieces of code are:

describe CuDNN do
 it "allocates memory" do
   p = ::CuDNN.malloc(100)
   p.should be_a(Pointer(Void))
 end
end

which calls

module CuDNN
 extend self
 def malloc(size)
   check_success(LibCUDA.malloc(out ptr, size))
   return ptr
 end
end

which calls

@[Link("cudart")]
lib LibCUDA
 enum ErrorT
   Success
 end
 fun malloc = cudaMalloc(ptr : Void**, size : LibC::Int) : ErrorT
end

The error is:

Module validation failed: Incorrect number of arguments passed to called function!
  %0 = call %"String::Builder"* @"*Pointer(Void)@Object::to_s<String::Builder>:String::Builder"(i32 %obj, %"String::Builder"* %self), !dbg !148
 
???
???
???
???
???
???
???
???
 
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
 
@RX14 RX14 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Apr 25, 2018
@sherjilozair
Copy link
Author

This was caused due to using p as a variable name. Apparently, p is a keyword in Crystal. Closing, since it's not a bug.

@straight-shoota
Copy link
Member

If module validation fails, it's a compiler bug, regardless of whether the input is valid or not.

p is not a keyword but a global method. It shouldn't be an issue if you name a local variable p.

@RX14 RX14 reopened this Apr 27, 2018
@asterite
Copy link
Member

asterite commented Apr 27, 2018

Note that the reduced code doesn't reproduce the bug. Someone will have to remove the real bug from the git repo.

@sherjilozair
Copy link
Author

@bararchy fixed this on the repository, so he might have more information on how to extract the bug.

@straight-shoota
Copy link
Member

Closing, there's no reproducible code. This has likely been fixed in the meantime.

@HertzDevil
Copy link
Contributor

Duplicate of #8544 (which is not fixed, see latest comment)

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. status:duplicate topic:compiler
Projects
None yet
Development

No branches or pull requests

5 participants