我不知道你在主線程中實例化一個Matlab::Engine
會發生什麼,然後再運行代碼按:
Matlab::Engine.new # side effect of loading the dynamic lib
t1=Thread.new do
engine = Matlab::Engine.new
engine.put_variable "x", 10
engine.put_variable "y", 22
engine.eval "z = x * y"
puts engine.get_variable "z"
end
t1.join
我問,因爲我」在使用不同庫(Sinatra/ActiveRecord/pg/etc)的Trace/BPT時遇到問題,並且在GBD中運行Ruby時,它與以下回溯相撞:
#0 0x00007fff89308590 in __CFInitialize()
#1 0x00007fff5fc0d5ce in __dyld__ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE()
#2 0x00007fff5fc0d607 in __dyld__ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE()
#3 0x00007fff5fc0bcec in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj()
#4 0x00007fff5fc0bc9d in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj()
#5 0x00007fff5fc0bc9d in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj()
#6 0x00007fff5fc0bc9d in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj()
#7 0x00007fff5fc0bda6 in __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE()
#8 0x00007fff5fc08fbb in __dyld_dlopen()
#9 0x00007fff888a7e40 in dlopen()
#10 0x0000000100001419 in dln_load()
#11 0x000000010016ad19 in rb_vm_call_cfunc()
#12 0x0000000100044d22 in rb_require_safe()
四周搜索引導我到這個bug report for SBCL這表明動態庫只能由主線程加載。