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

Compiling Marten projects in debug mode result in compilation errors #219

Open
ellmetha opened this issue Apr 8, 2024 · 2 comments
Open
Labels

Comments

@ellmetha
Copy link
Member

ellmetha commented Apr 8, 2024

Description

It appears trying to compile a Marten project in debug mode (with the --debug option) results in a compilation error. The problem might be on the Crystal compiler side of things, but let's investigate.

Versions

  • Crystal 1.11.2
  • Marten 0.4.4

How to reproduce

  1. Create an empty Marten project with marten new project testproject
  2. CD into the created project: cd testproject
  3. Install the project dependencies: shards install
  4. Try to compile the server in debug mode: crystal build src/server.cr -o bin/server --debug

The following error is returned:

BUG: called create_llvm_type for M (Exception)
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'raise<Exception>:NoReturn'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'raise<String>:NoReturn'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#create_llvm_type<Crystal::Type+, Bool>:NoReturn'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#llvm_type<Crystal::Type+, Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#create_llvm_type<Crystal::PointerInstanceType, Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#llvm_type<Crystal::Type+, Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#create_llvm_struct_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#llvm_struct_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#create_llvm_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#llvm_type<Crystal::Type+, Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#create_llvm_struct_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::LLVMTyper#llvm_struct_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Bool>:LLVM::Type'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<Crystal::MixedUnionType, Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<Crystal::PointerInstanceType, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<Crystal::PointerInstanceType, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<Crystal::PointerInstanceType, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_debug_type<(Crystal::GenericClassInstanceType+ | Crystal::GenericClassType+ | Crystal::GenericModuleInstanceType | Crystal::GenericModuleType | Crystal::NonGenericClassType | Crystal::NonGenericModuleType+ | Crystal::VirtualType), Crystal::Type+>:Pointer(Void)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#get_debug_type<Crystal::Type+, Crystal::Type+>:(LibLLVM::MetadataRef | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#codegen_fun<String, Crystal::Def+, Crystal::Type+, Bool, Crystal::CodeGenVisitor::ModuleInfo, Bool, Bool>:Crystal::LLVMTypedFunction'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#target_def_fun<Crystal::Def+, Crystal::Type+>:Crystal::LLVMTypedFunction'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::Call>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#create_initialize_class_var_function<Crystal::MetaTypeVar, Crystal::ClassVarInitializer>:(Crystal::LLVMTypedFunction | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#initialize_class_var<Crystal::MetaTypeVar>:(LLVM::Value | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#codegen_assign<Crystal::ASTNode+, Crystal::ASTNode+, Crystal::Assign>:(Bool | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::Assign>:(Bool | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::Expressions>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::ClassDef>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::ModuleDef>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::ModuleDef>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::ModuleDef>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::FileNode>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::Expressions>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::FileNode>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::Expressions>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::FileNode>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::CodeGenVisitor#visit<Crystal::Expressions>:Bool'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::CodeGenVisitor>:Nil'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::Compiler#compile:combine_rpath<Array(Crystal::Compiler::Source), String, Bool>:Crystal::Compiler::Result'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in 'Crystal::Command::run<Array(String)>:(Bool | Crystal::Repl::Value | Nil)'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in '__crystal_main'
  from /opt/homebrew/Cellar/crystal/1.11.2/bin/crystal in '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
@ellmetha ellmetha added the Bug label Apr 8, 2024
@devnote-dev
Copy link

Looks like you might have ran into crystal-lang/crystal#3770 however there is actually a group of related issues with similar stack traces so it could fall under one of those too. Based on the described issue and the stack trace, it looks like the source is here:

class ManyToManySet(M) < Set(M)

which could point to one of many methods using the M generic.

@ellmetha
Copy link
Member Author

ellmetha commented Apr 9, 2024

Thanks for the info! Yes, there are also some issues (such as crystal-lang/crystal#6588) that seem to suggest this may be related to generics inheritance (which Marten relies on for its query set mechanism). I suspect this may be related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants