chriswailes / RLTK

The Ruby Language Toolkit
http://chriswailes.github.io/RLTK/
University of Illinois/NCSA Open Source License
453 stars 35 forks source link

JITCompiler segfaults on OSX #43

Open guncha opened 9 years ago

guncha commented 9 years ago

It seems like it doesn't matter what I do, the result's always the same. Every time I try to call run_function, it blows up.

require "rltk"
require "rltk/cg"
require "rltk/cg/module"
require "rltk/cg/contractor"
require "rltk/cg/execution_engine"

# ENV["DYLD_FALLBACK_LIBRARY_PATH"] = "/usr/local/lib/llvm-3.4/lib/"
RLTK::CG::LLVM.init(:X86)
@module = RLTK::CG::Module.new("Hello")
@engine = RLTK::CG::JITCompiler.new(@module)

f = @module.functions.add("hello", RLTK::CG::VoidType, [])
f.blocks.append('entry') do
  ret_void
end

f.verify!

@engine.run_function(f, [])
/Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/execution_engine.rb:104: [BUG] Segmentation fault at 0x00000000000000
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   for more details.

-- Control frame information -----------------------------------------------
c:0004 p:---- s:0020 e:000019 CFUNC  :run_function
c:0003 p:0075 s:0013 e:000011 METHOD /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/execution_engine.rb:104
c:0002 p:0156 s:0005 E:000b60 EVAL   binding_test.rb:26 [FINISH]
c:0001 p:0000 s:0002 E:000868 TOP    [FINISH]

binding_test.rb:26:in `<main>'
/Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/execution_engine.rb:104:in `run_function'
/Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/execution_engine.rb:104:in `run_function'

-- C level backtrace information -------------------------------------------
0   ruby                                0x00000001036a6e50 rb_vm_bugreport + 144
1   ruby                                0x00000001035589b1 report_bug + 305
2   ruby                                0x0000000103558874 rb_bug + 180
3   ruby                                0x00000001036291bc sigsegv + 156
4   libsystem_platform.dylib            0x00007fff8f1f3f1a _sigtramp + 26
5   libLLVM-3.4.dylib                   0x000000010429534a LLVMRunFunction + 96
6   ???                                 0x00007fc92b226560 0x0 + 140501988828512

-- Other runtime information -----------------------------------------------

* Loaded script: binding_test.rb

* Loaded features:

    0 enumerator.so
    1 enc/encdb.so
    2 enc/trans/transdb.so
    3 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/x86_64-darwin14.0/rbconfig.rb
    4 thread.rb
    5 thread.so
    6 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/compatibility.rb
    7 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/defaults.rb
    8 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/deprecate.rb
    9 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/errors.rb
   10 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/version.rb
   11 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/requirement.rb
   12 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/platform.rb
   13 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/basic_specification.rb
   14 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/stub_specification.rb
   15 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/util/stringio.rb
   16 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb
   17 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/exceptions.rb
   18 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb
   19 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb
   20 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb
   21 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems.rb
   22 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/path_support.rb
   23 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb
   24 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk.rb
   25 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg.rb
   26 /Users/gunca/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-14/2.1.0-static/ffi-1.9.8/ffi_c.bundle
   27 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/platform.rb
   28 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/types.rb
   29 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/library.rb
   30 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/errno.rb
   31 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/pointer.rb
   32 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/memorypointer.rb
   33 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/struct_layout_builder.rb
   34 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/struct.rb
   35 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/union.rb
   36 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/managedstruct.rb
   37 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/callback.rb
   38 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/io.rb
   39 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/autopointer.rb
   40 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/variadic.rb
   41 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/enum.rb
   42 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi/ffi.rb
   43 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/ffi-1.9.8/lib/ffi.rb
   44 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/filigree-0.3.2/lib/filigree/boolean.rb
   45 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/version.rb
   46 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/generated_bindings.rb
   47 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/bindings.rb
   48 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/context.rb
   49 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/module.rb
   50 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/filigree-0.3.2/lib/filigree/class_methods_module.rb
   51 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/ostruct.rb
   52 /Users/gunca/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/singleton.rb
   53 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/filigree-0.3.2/lib/filigree/abstract_class.rb
   54 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/filigree-0.3.2/lib/filigree/types.rb
   55 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/filigree-0.3.2/lib/filigree/class.rb
   56 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/filigree-0.3.2/lib/filigree/match.rb
   57 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/filigree-0.3.2/lib/filigree/visitor.rb
   58 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/type.rb
   59 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/value.rb
   60 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/instruction.rb
   61 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/builder.rb
   62 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/contractor.rb
   63 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/pass_manager.rb
   64 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/triple.rb
   65 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/target.rb
   66 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/execution_engine.rb
   67 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/llvm.rb
   68 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/basic_block.rb
   69 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/function.rb
   70 /Users/gunca/.rvm/gems/ruby-2.1.5/gems/rltk-3.0.0/lib/rltk/cg/generic_value.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Don't forget to include the above Crash Report log file.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6