crystal-lang / crystal_lib

Automatic binding generator for native libraries in Crystal
138 stars 30 forks source link

Don't know how to convert union __mbstate_ #39

Closed fazibear closed 7 years ago

fazibear commented 7 years ago

For most of examples I get this exception:

Don't know how to convert union __mbstate_t (119) (Exception)
0x106cd57d2: *CallStack::unwind:Array(Pointer(Void)) at ??
0x106cd5771: *CallStack#initialize:Array(Pointer(Void)) at ??
0x106cd5748: *CallStack::new:CallStack at ??
0x106cc3d31: *raise<Exception>:NoReturn at ??
0x106cc3d11: *raise<String>:NoReturn at ??
0x106dce8eb: *CrystalLib::Parser#type<Clang::Type>:CrystalLib::Type+ at ??
0x106dcf951: *CrystalLib::Parser#visit_typedef_declaration<Clang::Cursor>:CrystalLib::Typedef at ??
0x106dcd2ec: *CrystalLib::Parser#visit<Clang::Cursor>:(CrystalLib::ASTNode+ | Nil) at ??
0x106cd3d6a: ~procProc(Clang::Cursor, Clang::VisitResult)@src/crystal_lib/parser.cr:22 at ??
0x106cd3ce7: ~procProc(LibClang::Cursor, LibClang::Cursor, Pointer(Void), Clang::VisitResult)@src/clang/cursor.cr:52 at ??
0x106f7bf0e: _ZN5clang8cxcursor13CursorVisitor5VisitE8CXCursorb at ??
0x106f7d99a: _ZN5clang8cxcursor13CursorVisitor23handleDeclForVisitationEPKNS_4DeclE at ??
0x106f7da43: _ZN5clang8cxcursor13CursorVisitor16VisitDeclContextEPNS_11DeclContextE at ??
0x106f7c8a3: _ZN5clang8cxc0x106f7c8a3: _ZN5clang8cxcursor13CursorVisitor13VisitChildrenE8CXCursor at ??
Unhandled exception in spawn:
end of file reached (IO::EOFError)
0x106cd57d2: *CallStack::unwind:Array(Pointer(Void)) at ??
0x106cd5771: *CallStack#initialize:Array(Pointer(Void)) at ??
0x106cd5748: *CallStack::new:CallStack at ??
0x106cd1cc1: *raise<IO::EOFError>:NoReturn at ??
0x106cfa1d3: *IO::FileDescriptor+@IO#read_fully<Slice(UInt8)>:Int32 at ??
0x106d034cf: *IO::ByteFormat::LittleEndian::decode<Int32:Class, IO::FileDescriptor+>:Int32 at ??
0x106ceef72: *Int32@Int::from_io<IO::FileDescriptor+, IO::ByteFormat::LittleEndian:Module>:Int32 at ??
0x106cfc572: *IO::FileDescriptor+@IO#read_bytes<Int32:Class>:Int32 at ??
0x106d118c5: *Event::SignalHandler#run:NoReturn at ??
0x106cd209c: ~procProc(Nil)@/usr/local/Cellar/crystal-lang/0.20.5_2/src/event/signal_handler.cr:93 at ??
0x106cdf794: *Fiber#run:(IO::FileDescriptor | Nil) at ??
0x106cd2089: ~proc2Proc(Fiber, (IO::FileDescriptor | Nil))@/usr/local/Cellar/crystal-lang/0.20.5_2/src/fiber.cr:29 at ??
ber, (IO::FileDescriptor | Nil))@/usr/local/Cellar/c0x106f86ad6: clang_visitChildren at ??
0x106dd157f: *Clang::Cursor#visit_children<&Proc(Clang::Cursor, Clang::VisitResult)>:UInt32 at ??
0x106dcd12f: *CrystalLib::Parser#parse:UInt32 at ??
0x106dcce9a: *CrystalLib::Parser::parse<String, Array(String)>:Array(CrystalLib::ASTNode+) at ??
0x106dc9f4c: *CrystalLib::LibTransformer#transform<Crystal::LibDef>:Crystal::LibDef at ??
0x106d7b33f: *Crystal::ASTNode+@Crystal::ASTNode#transform<CrystalLib::LibTransformer>:Crystal::ASTNode+ at ??
0x106dca810: *CrystalLib::LibTransformer@Crystal::Transformer#transform<Crystal::Expressions>:Crystal::ASTNode+ at ??
0x106d7b36c: *Crystal::ASTNode+@Crystal::ASTNode#transform<CrystalLib::LibTransformer>:Crystal::ASTNode+ at ??
0x106cc38c4: __crystal_main at ??
0x106cd22c8: main at ??
fazibear commented 7 years ago

https://github.com/crystal-lang/crystal_lib/pull/35 will fix it

mverzilli commented 7 years ago

Would you specify which example returns that? I'm not being able to reproduce this.

fazibear commented 7 years ago

@mverzilli libgit2 for example. But you have to have llvm 3.9 installed.

mverzilli commented 7 years ago

Using llvm 3.9.1 + libgit2 0.25.1 + macOS 10.12.2 it works as expected. What's your env?

I want to merge #35, but for that I need some code samples that reproduce these issues so that I can add regression tests.

Other ways to help me move this forward faster: share a reduced code snippet that will reproduce the issue or even better, write a regression test.

fazibear commented 7 years ago
Os X: 10.11.6
crystal-lang: stable 0.20.5 (bottled), HEAD
Fast and statically typed, compiled language with Ruby-like syntax
https://crystal-lang.org/
/usr/local/Cellar/crystal-lang/0.20.5_2 (768 files, 51.4M) *
  Poured from bottle on 2017-01-31 at 13:56:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/crystal-lang.rb
lvm: stable 3.9.1 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
http://llvm.org/
/usr/local/Cellar/llvm/3.9.1 (2,089 files, 840.2M) *
  Poured from bottle on 2017-02-01 at 13:53:14
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/llvm.rb
libgit2: stable 0.25.1 (bottled), HEAD
C library of Git core methods that is re-entrant and linkable
https://libgit2.github.com/
/usr/local/Cellar/libgit2/0.25.1 (105 files, 1.8M) *
  Poured from bottle on 2017-02-01 at 13:11:59
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libgit2.rb
crystal src/main.cr -- examples/lib_git2.cr
Don't know how to convert union __mbstate_t (119) (Exception)
0x10c1337d2: *CallStack::unwind:Array(Pointer(Void)) at ??
0x10c133771: *CallStack#initialize:Array(Pointer(Void)) at ??
0x10c133748: *CallStack::new:CallStack at ??
0x10c121d31: *raise<Exception>:NoReturn at ??
0x10c121d11: *raise<String>:NoReturn at ??
0x10c22c8eb: *CrystalLib::Parser#type<Clang::Type>:CrystalLib::Type+ at ??
0x10c22d951: *CrystalLib::Parser#visit_typedef_declaration<Clang::Cursor>:CrystalLib::Typedef at ??
0x10c22b2ec: *CrystalLib::Parser#visit<Clang::Cursor>:(CrystalLib::ASTNode+ | Nil) at ??
0x10c131d6a: ~procProc(Clang::Cursor, Clang::VisitResult)@src/crystal_lib/parser.cr:22 at ??
0x10c131ce7: ~procProc(LibClang::Cursor, LibClang::Cursor, Pointer(Void), Clang::VisitResult)@src/clang/cursor.cr:52 at ??
0x10c3d8f0e: _ZN5clang8cxcursor13CursorVisitor5VisitE8CXCursorb at ??
0x10c3da99a: _ZN5clang8cxcursor13CursorVisitor23handleDeclForVisitationEPKNS_4DeclE at ??
0x10c3daa43: _ZN5clang8cxcursor13CursorVisitor16VisitDeclContextEPNS_11DeclContextE at ??
0x10c3d98a3: _ZN5clang8cxc0x10c3d98a3: _ZN5clang8cxcursor13CursorVisitor13VisitChildrenE8CXCursor at ??
Unhandled exception in spawn:
end of file reached (IO::EOFError)
0x10c1337d2: *CallStack::unwind:Array(Pointer(Void)) at ??
0x10c133771: *CallStack#initialize:Array(Pointer(Void)) at ??
0x10c133748: *CallStack::new:CallStack at ??
0x10c12fcc1: *raise<IO::EOFError>:NoReturn at ??
0x10c1581d3: *IO::FileDescriptor+@IO#read_fully<Slice(UInt8)>:Int32 at ??
0x10c1614cf: *IO::ByteFormat::LittleEndian::decode<Int32:Class, IO::FileDescriptor+>:Int32 at ??
0x10c14cf72: *Int32@Int::from_io<IO::FileDescriptor+, IO::ByteFormat::LittleEndian:Module>:Int32 at ??
0x10c15a572: *IO::FileDescriptor+@IO#read_bytes<Int32:Class>:Int32 at ??
0x10c16f8c5: *Event::SignalHandler#run:NoReturn at ??
0x10c13009c: ~procProc(Nil)@/usr/local/Cellar/crystal-lang/0.20.5_2/src/event/signal_handler.cr:93 at ??
0x10c13d794: *Fiber#run:(IO::FileDescriptor | Nil) at ??
0x10c130089: ~proc2Proc(Fiber, (IO::FileDescriptor | Nil))@/usr/local/Cellar/crystal-lang/0.20.5_2/src/fiber.cr:29 at ??
ber, (IO::FileDescriptor | Nil))@/usr/local/Cellar/c0x10c3e3ad6: clang_visitChildren at ??
0x10c22f57f: *Clang::Cursor#visit_children<&Proc(Clang::Cursor, Clang::VisitResult)>:UInt32 at ??
0x10c22b12f: *CrystalLib::Parser#parse:UInt32 at ??
0x10c22ae9a: *CrystalLib::Parser::parse<String, Array(String)>:Array(CrystalLib::ASTNode+) at ??
0x10c227f4c: *CrystalLib::LibTransformer#transform<Crystal::LibDef>:Crystal::LibDef at ??
0x10c1d933f: *Crystal::ASTNode+@Crystal::ASTNode#transform<CrystalLib::LibTransformer>:Crystal::ASTNode+ at ??
0x10c228810: *CrystalLib::LibTransformer@Crystal::Transformer#transform<Crystal::Expressions>:Crystal::ASTNode+ at ??
0x10c1d936c: *Crystal::ASTNode+@Crystal::ASTNode#transform<CrystalLib::LibTransformer>:Crystal::ASTNode+ at ??
0x10c1218c4: __crystal_main at ??
0x10c1302c8: main at ??
mverzilli commented 7 years ago

@fazibear we merged #35 so I assume this is fixed. Feel free to reopen if it continues to happen.