Coder Social home page Coder Social logo

Segfault inside `gemmlowp` on mac about rune HOT 5 OPEN

hotg-ai avatar hotg-ai commented on June 9, 2024
Segfault inside `gemmlowp` on mac

from rune.

Comments (5)

Michael-F-Bryan avatar Michael-F-Bryan commented on June 9, 2024

I think this may be related to the initial stack size on macs being smaller than Linux (e.g. 512kb vs 8mb).

We can work around it by telling the linker to request a larger stack size:

diff --git a/.cargo/config.toml b/.cargo/config.toml
index f85e6a9427..902ea893ff 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -6,10 +6,12 @@ rune = "run --package rune --release --quiet --"
 rustflags = [
   "-C", "link-arg=-undefined",
   "-C", "link-arg=dynamic_lookup",
+  "-C", "link-args=-Wl,-stack_size,0x800000",
 ]

 [target.aarch64-apple-darwin]
 rustflags = [
   "-C", "link-arg=-undefined",
   "-C", "link-arg=dynamic_lookup",
+  "-C", "link-args=-Wl,-stack_size,0x800000",
 ]

I would like to know what is using up so much stack size, though. We don't have infinite recursion because otherwise the Linux build would fail and we shouldn't be using any deeply recursive data structures, so I'm guessing maybe a couple functions are storing very large arrays on the stack and when called in the right order we run out of stack space.

If someone has a mac and is proficient with LLDB, we may be able to drop a breakpoint at the SIGSEGV signal handler (overflowing the stack triggers a segfault which wasmer is catching and turning into heap_get_oob) then print a stack trace to see which parts of our code may be at fault.

from rune.

Mi1ind avatar Mi1ind commented on June 9, 2024
$ (lldb) bt
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x
7, bit_size = 0
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x
7, bit_size = 0
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x
7, bit_size = 0
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (c
ode=1, address=0x3110)
  * frame #0: 0x0000000101061314 rune`void gemmlowp::DispatchGemmShape<unsign
ed char, short, gemmlowp::BitDepthParams<gemmlowp::OperandRange<1, 255>, gemm
lowp::OperandRange<0, 255> >, (gemmlowp::MapOrder)1, (gemmlowp::MapOrder)0, (
gemmlowp::MapOrder)0, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0
>, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1>, std::__1::tuple<
gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStage
Clamp, gemmlowp::OutputStageSaturatingCastToInt16>, gemmlowp::GemmContext>(ge
mmlowp::GemmContext*, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::Map
Order)1> const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOrder
)0> const&, gemmlowp::MatrixMap<short, (gemmlowp::MapOrder)0>*, gemmlowp::Vec
torDup<int const, (gemmlowp::VectorShape)0> const&, gemmlowp::VectorDup<int c
onst, (gemmlowp::VectorShape)1> const&, std::__1::tuple<gemmlowp::OutputStage
ScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp::Outp
utStageSaturatingCastToInt16> const&) + 20
    frame #1: 0x00000002885e1240
    frame #2: 0x000000010105d0b8 rune`gemmlowp::ComputeImpl<gemmlowp::PackedS
ideBlock<gemmlowp::KernelSideFormat<gemmlowp::CellFormat<4, 2, (gemmlowp::Cel
lOrder)1>, 3> >, gemmlowp::PackedSideBlock<gemmlowp::KernelSideFormat<gemmlow
p::CellFormat<4, 2, (gemmlowp::CellOrder)1>, 1> >, gemmlowp::PackedResult>::C
omputeRun(int, int, int, int) + 216
    frame #3: 0x0000000100fe0eab rune`void gemmlowp::SingleThreadGemm<gemmlow
p::KernelFormat<gemmlowp::KernelSideFormat<gemmlowp::CellFormat<4, 2, (gemmlo
wp::CellOrder)1>, 3>, gemmlowp::KernelSideFormat<gemmlowp::CellFormat<4, 2, (
gemmlowp::CellOrder)1>, 1> >, unsigned char, unsigned char, gemmlowp::BitDept
hParams<gemmlowp::OperandRange<1, 255>, gemmlowp::OperandRange<0, 255> >, (ge
mmlowp::MapOrder)1, (gemmlowp::MapOrder)0, (gemmlowp::MapOrder)1, gemmlowp::V
ectorDup<int const, (gemmlowp::VectorShape)1>, gemmlowp::VectorDup<int const,
 (gemmlowp::VectorShape)0>, std::__1::tuple<gemmlowp::OutputStageBiasAddition
<gemmlowp::VectorMap<int const, (gemmlowp::VectorShape)1> >, gemmlowp::Output
StageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp:
:OutputStageSaturatingCastToUint8> >(gemmlowp::SingleThreadGemmContext*, gemm
lowp::KernelBase const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::
MapOrder)1> const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOr
der)0> const&, gemmlowp::MatrixMap<unsigned char, (gemmlowp::MapOrder)1>*, ge
mmlowp::VectorDup<int const, (gemmlowp::VectorShape)1> const&, gemmlowp::Vect
orDup<int const, (gemmlowp::VectorShape)0> const&, std::__1::tuple<gemmlowp::
OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gemmlowp::VectorShape
)1> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::Outp
utStageClamp, gemmlowp::OutputStageSaturatingCastToUint8> const&) + 1179
    frame #4: 0x0000000100fdfd73 rune`void gemmlowp::DispatchGemmShape<unsign
ed char, unsigned char, gemmlowp::BitDepthParams<gemmlowp::OperandRange<1, 25
5>, gemmlowp::OperandRange<0, 255> >, (gemmlowp::MapOrder)1, (gemmlowp::MapOr
der)0, (gemmlowp::MapOrder)1, gemmlowp::VectorDup<int const, (gemmlowp::Vecto
rShape)1>, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0>, std::__1
::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gem
mlowp::VectorShape)1> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndExpone
nt, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint8>,
gemmlowp::GemmContext>(gemmlowp::GemmContext*, gemmlowp::MatrixMap<unsigned c
har const, (gemmlowp::MapOrder)1> const&, gemmlowp::MatrixMap<unsigned char c
onst, (gemmlowp::MapOrder)0> const&, gemmlowp::MatrixMap<unsigned char, (gemm
lowp::MapOrder)1>*, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1>
const&, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0> const&, std:
:__1::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const,
(gemmlowp::VectorShape)1> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndEx
ponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint
8> const&) + 291
    frame #5: 0x0000000100fdfc07 rune`void gemmlowp::DispatchGemmShape<unsign
ed char, unsigned char, gemmlowp::BitDepthParams<gemmlowp::OperandRange<1, 25
5>, gemmlowp::OperandRange<0, 255> >, (gemmlowp::MapOrder)1, (gemmlowp::MapOr
der)0, (gemmlowp::MapOrder)0, gemmlowp::VectorDup<int const, (gemmlowp::Vecto
rShape)0>, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1>, std::__1
::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gem
mlowp::VectorShape)0> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndExpone
nt, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint8>,
gemmlowp::GemmContext>(gemmlowp::GemmContext*, gemmlowp::MatrixMap<unsigned c
har const, (gemmlowp::MapOrder)1> const&, gemmlowp::MatrixMap<unsigned char c
onst, (gemmlowp::MapOrder)0> const&, gemmlowp::MatrixMap<unsigned char, (gemm
lowp::MapOrder)0>*, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0>
const&, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1> const&, std:
:__1::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const,
(gemmlowp::VectorShape)0> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndEx
ponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint
8> const&) + 247
    frame #6: 0x0000000100fded6c rune`tflite::cpu_backend_gemm::detail::GemmI
mplUsingGemmlowp<unsigned char, unsigned char, int, unsigned char, (tflite::c
pu_backend_gemm::QuantizationFlavor)1>::Run(tflite::cpu_backend_gemm::MatrixP
arams<unsigned char> const&, unsigned char const*, tflite::cpu_backend_gemm::
MatrixParams<unsigned char> const&, unsigned char const*, tflite::cpu_backend
_gemm::MatrixParams<unsigned char> const&, unsigned char*, tflite::cpu_backen
d_gemm::GemmParams<int, unsigned char, (tflite::cpu_backend_gemm::Quantizatio
nFlavor)1> const&, tflite::CpuBackendContext*) + 220
    frame #7: 0x0000000100fde277 rune`tflite::optimized_ops::Conv(tflite::Con
vParams const&, tflite::RuntimeShape const&, unsigned char const*, tflite::Ru
ntimeShape const&, unsigned char const*, tflite::RuntimeShape const&, int con
st*, tflite::RuntimeShape const&, unsigned char*, tflite::RuntimeShape const&
, unsigned char*, tflite::CpuBackendContext*) + 615
    frame #8: 0x0000000100fefcb9 rune`void tflite::ops::builtin::conv::EvalQu
antized<(tflite::ops::builtin::conv::KernelType)2>(TfLiteContext*, TfLiteNode
*, TfLiteConvParams*, tflite::ops::builtin::conv::OpData*, TfLiteTensor*, TfL
iteTensor*, TfLiteTensor*, TfLiteTensor*, TfLiteTensor*, TfLiteTensor*) + 713
    frame #9: 0x0000000100fc28c7 rune`TfLiteStatus tflite::ops::builtin::conv
::Eval<(tflite::ops::builtin::conv::KernelType)2>(TfLiteContext*, TfLiteNode*
) + 695
    frame #10: 0x0000000100f707ec rune`tflite::Subgraph::Invoke() + 732
    frame #11: 0x0000000100f763bd rune`tflite::Interpreter::Invoke() + 29
    frame #12: 0x0000000100f65ee8 rune`__cpp_closure_11793350538227341524_imp
l(interpreter=0x00007ffeefbfb048) at mod.rs:117:37
    frame #13: 0x0000000100f65ec1 rune`::__cpp_closure_11793350538227341524(i
nterpreter=0x00007ffeefbfb048, __result=0x00007ffeefbfb057) at mod.rs:122:28
    frame #14: 0x00000001001eff7e rune`tflite::interpreter::Interpreter$LT$Op
$GT$::invoke::h8b6fe16ffa5e4fb5(self=0x0000000105849f20) at mod.rs:116:13
    frame #15: 0x00000001001f4266 rune`_$LT$tflite..interpreter..Interpreter$
LT$tflite..interpreter..ops..builtin..resolver..Resolver$GT$$u20$as$u20$runic
os_base..image..Model$GT$::infer::hb895634a5a176650(self=0x0000000105849f20,
input=(data_ptr = "����������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������������������������������������������
�����������������������������������������"..., length = 150528), output=(data
_ptr = "", length = 1001)) at �image.rs:508:9
    frame #16: 0x000000010020c6ba rune`runicos_base::image::tfm_model_invoke:
:_$u7b$$u7b$closure$u7d$$u7d$::ha2f339d8d733b538(ctx=&CallContext @ 0x00007ff
eefbfb7d8, (null)=<unavailable>) at image.rs:429:13
    frame #17: 0x00000001001f93db rune`rune_runtime::function::Function::new:
:_$u7b$$u7b$closure$u7d$$u7d$::hab7005e2ca6d17de(ctx=&CallContext @ 0x00007ff
eefbfba48, args=(data_ptr = 0x0000000103f30490, length = 5)) at function.rs:8
0:31
    frame #18: 0x0000000100c9c5d3 rune`_$LT$alloc..boxed..Box$LT$F$C$A$GT$$u2
0$as$u20$core..ops..function..Fn$LT$Args$GT$$GT$::call::h43a116a6e7fb9b1e(sel
f=0x0000000103f32a40, args=(&CallContext, &[rune_runtime::WasmValue]) @ 0x000
07ffeefbfbac8) at boxed.rs:1589:9
    frame #19: 0x0000000100c9d96c rune`rune_runtime::function::Function::call
::h707488c77e13dc46(self=0x0000000103f32a20, ctx=&CallContext @ 0x00007ffeefb
fbb50, args=(data_ptr = 0x0000000103f30490, length = 5)) at function.rs:97:9
    frame #20: 0x0000000100226f9f rune`_$LT$rune_wasmer_runtime..Registrar$u2
0$as$u20$rune_runtime..Registrar$GT$::register_function::_$u7b$$u7b$closure$u
7d$$u7d$::h979bcdbd7cc48447(ctx=0x0000000103f852f0, args=(data_ptr = 0x000000
010781f250, length = 5)) at lib.rs:121:23
    frame #21: 0x00000001002322a2 rune`_$LT$wasmer..externals..function..Dyna
micFunctionWithEnv$LT$Env$GT$$u20$as$u20$wasmer..externals..function..VMDynam
icFunction$GT$::call::hc2c0995f41142c44(self=0x0000000103f86138, args=(data_p
tr = 0x000000010781f250, length = 5)) at function.rs:856:9
    frame #22: 0x0000000100232533 rune`_$LT$wasmer_vm..vmcontext..VMDynamicFu
nctionContext$LT$T$GT$$u20$as$u20$wasmer..externals..function..VMDynamicFunct
ionCall$LT$T$GT$$GT$::func_wrapper::_$u7b$$u7b$closure$u7d$$u7d$::hb40770296c
e01cff at function.rs:896:27
    frame #23: 0x0000000100234369 rune`core::ops::function::FnOnce::call_once
::h2825bca8898bbc42((null)=closure-0 @ 0x00007ffeefbfc368, (null)=<unavailabl
e>) at function.rs:227:5
    frame #24: 0x0000000100230095 rune`_$LT$std..panic..AssertUnwindSafe$LT$F
$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h
3a2873dfc110f321(self=AssertUnwindSafe<closure-0> @ 0x00007ffeefbfc3b0, _args
=<unavailable>) at panic.rs:344:9
    frame #25: 0x000000010022bd5a rune`std::panicking::try::do_call::hd43c905
7cc277600(data="xſ��") at panicking.rs:379:40
    frame #26: 0x000000010022bedb rune`__rust_try + 43
    frame #27: 0x000000010022baa9 rune`std::panicking::try::h2205cc8779b1474b
(f=AssertUnwindSafe<closure-0> @ 0x00007ffeefbfc4c8) at panicking.rs:343:19
    frame #28: 0x000000010023015c rune`std::panic::catch_unwind::hc518dfb817c
ef1e7(f=AssertUnwindSafe<closure-0> @ 0x00007ffeefbfc540) at panic.rs:431:14
    frame #29: 0x0000000100221374 rune`_$LT$wasmer_vm..vmcontext..VMDynamicFu
nctionContext$LT$T$GT$$u20$as$u20$wasmer..externals..function..VMDynamicFunct
ionCall$LT$T$GT$$GT$::func_wrapper::haf5fefa407bd2d59(self=0x0000000103f86130
, values_vec=0x00007ffeefbfc5f0) at function.rs:890:22
    frame #30: 0x00000001079d2f47
    frame #31: 0x0000000107937c18
    frame #32: 0x000000010793401d
    frame #33: 0x000000010793fb21
    frame #34: 0x00000001079648e7
    frame #35: 0x00000001079d262d
    frame #36: 0x0000000100b959e1 rune`wasmer_vm::trap::traphandlers::wasmer_
call_trampoline::_$u7b$$u7b$closure$u7d$$u7d$::h4b0ff2e273d96f8a at traphandl
ers.rs:504:9
    frame #37: 0x0000000100b95e31 rune`wasmer_vm::trap::traphandlers::catch_t
raps::call_closure::ha0a5f54abcf1845e(payload="8ӿ��") at traphandlers.rs:536:
18
    frame #38: 0x0000000100bbf9f6 rune`RegisterSetjmp(buf_storage=0x00007ffee
fbfd2c0, body=(rune`wasmer_vm::trap::traphandlers::catch_traps::call_closure:
:ha0a5f54abcf1845e at traphandlers.rs:532), payload=0x00007ffeefbfd350) at he
lpers.c:15:3
    frame #39: 0x0000000100b95dc0 rune`wasmer_vm::trap::traphandlers::catch_t
raps::_$u7b$$u7b$closure$u7d$$u7d$::h2890668d5849e27e(cx=0x00007ffeefbfd288)
at traphandlers.rs:525:9
    frame #40: 0x0000000100b960ad rune`wasmer_vm::trap::traphandlers::CallThr
eadState::with::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h
b183b908be0fbe3d at traphandlers.rs:601:42
    frame #41: 0x0000000100bbb880 rune`wasmer_vm::trap::traphandlers::tls::se
t::_$u7b$$u7b$closure$u7d$$u7d$::hf59ea4cef977e393(p=0x0000000105008770) at t
raphandlers.rs:761:13
    frame #42: 0x0000000100b78320 rune`std::thread::local::LocalKey$LT$T$GT$:
:try_with::h0190ed433476876d(self=0x0000000101797400, f=closure-0 @ 0x00007ff
eefbfcaa0) at local.rs:376:16
    frame #43: 0x0000000100b7819c rune`std::thread::local::LocalKey$LT$T$GT$:
:with::hb36939b5639c834b(self=0x0000000101797400, f=<unavailable>) at local.r
s:352:9
    frame #44: 0x0000000100bbb814 rune`wasmer_vm::trap::traphandlers::tls::se
t::hc69eaf83d32a8125(ptr=0x00007ffeefbfd288, closure=closure-1 @ 0x00007ffeef
bfcb00) at traphandlers.rs:759:9
    frame #45: 0x0000000100b9678b rune`wasmer_vm::trap::traphandlers::CallThr
eadState::with::_$u7b$$u7b$closure$u7d$$u7d$::h3d54c0f19988499c(prev=Option<&
wasmer_vm::trap::traphandlers::CallThreadState> @ 0x00007ffeefbfce88) at trap
handlers.rs:601:23
    frame #46: 0x0000000100bbbcdf rune`wasmer_vm::trap::traphandlers::tls::wi
th::_$u7b$$u7b$closure$u7d$$u7d$::h3520867863f23b96(ptr=0x0000000105008770) a
t traphandlers.rs:770:22
    frame #47: 0x0000000100b78475 rune`std::thread::local::LocalKey$LT$T$GT$:
:try_with::h0d2e4c51ddd79ed1(self=0x0000000101797400, f=closure-0 @ 0x00007ff
eefbfd028) at local.rs:376:16
    frame #48: 0x0000000100b78145 rune`std::thread::local::LocalKey$LT$T$GT$:
:with::h9246a7789fede286(self=0x0000000101797400, f=closure-0 @ 0x00007ffeefb
fd0c0) at local.rs:352:9
    frame #49: 0x0000000100bbba53 rune`wasmer_vm::trap::traphandlers::tls::wi
th::h220754374e37b24f(closure=closure-0 @ 0x00007ffeefbfd100) at traphandlers
.rs:768:9
    frame #50: 0x0000000100b9600c rune`wasmer_vm::trap::traphandlers::CallThr
eadState::with::h30cbff9d16adf4c8(self=CallThreadState @ 0x00007ffeefbfd288,
closure=closure-0 @ 0x00007ffeefbfd148) at traphandlers.rs:599:9
    frame #51: 0x0000000100b95d36 rune`wasmer_vm::trap::traphandlers::catch_t
raps::h733696d81de870d2(vmctx=VMFunctionEnvironment @ 0x00007ffeefbfd2f0, clo
sure=closure-0 @ 0x00007ffeefbfd350) at traphandlers.rs:524:12
    frame #52: 0x0000000100b9598c rune`wasmer_vm::trap::traphandlers::wasmer_
call_trampoline::h433b1fdcd204d5c5(vmctx=VMFunctionEnvironment @ 0x00007ffeef
bfd330, trampoline=(0x00000001079d25e0), callee=0x0000000107964790, values_ve
c="") at traphandlers.rs:503:5
    frame #53: 0x00000001002233db rune`wasmer::native::NativeFunc$LT$$LP$A1$C
$A2$C$A3$RP$$C$Rets$GT$::call::h05e39d5c7f18d9e5(self=0x00007ffeefbfdf38, A1=
0, A2=0, A3=0) at native.rs:139:29
    frame #54: 0x0000000100235a4c rune`rune_wasmer_runtime::Runtime::call::h7
5078b8ded146df7(self=0x00007ffeefbfe7d0) at lib.rs:69:9
    frame #55: 0x0000000100057765 rune`rune::run::Run::execute::h6b08d5d600a3
6ca1(self=Run @ 0x00007ffeefbff028) at run.rs:56:13
    frame #56: 0x0000000100012097 rune`rune::main::h219e6534771ef61a at main.
rs:46:32
    frame #57: 0x000000010000863e rune`core::ops::function::FnOnce::call_once
::hb4045903df9d0e8c((null)=(rune`rune::main::h219e6534771ef61a at main.rs:28)
, (null)=<unavailable>) at function.rs:227:5
    frame #58: 0x000000010000cc01 rune`std::sys_common::backtrace::__rust_beg
in_short_backtrace::he9b86a90e76c8cb0(f=(rune`rune::main::h219e6534771ef61a a
t main.rs:28)) at backtrace.rs:125:18
    frame #59: 0x000000010004b464 rune`std::rt::lang_start::_$u7b$$u7b$closur
e$u7d$$u7d$::hb62e795d7d5efe03 at rt.rs:49:18
    frame #60: 0x0000000101567301 rune`std::rt::lang_start_internal::h09b48eb
36ffca70d [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..func
tion..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h88801ec30fa967bc at
function.rs:259:13 [opt]
    frame #61: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb
36ffca70d [inlined] std::panicking::try::do_call::ha5838b1ed53bb3ce at panick
ing.rs:379 [opt]
    frame #62: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb
36ffca70d [inlined] std::panicking::try::h2c2c426e3f3c01a8 at panicking.rs:34
3 [opt]
    frame #63: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb
36ffca70d [inlined] std::panic::catch_unwind::h383eb7eff10b175f at panic.rs:4
31 [opt]
    frame #64: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb
36ffca70d at rt.rs:34 [opt]
    frame #65: 0x000000010004b43e rune`std::rt::lang_start::h7faecf3e55ba3944
(main=(rune`rune::main::h219e6534771ef61a at main.rs:28), argc=4, argv=0x0000
7ffeefbff668) at rt.rs:48:5
    frame #66: 0x00000001000139c6 rune`main + 22
    frame #67: 0x00007fff67ac5cc9 libdyld.dylib`start + 1
    frame #68: 0x00007fff67ac5cc9 libdyld.dylib`start + 1
(lldb)

from rune.

Michael-F-Bryan avatar Michael-F-Bryan commented on June 9, 2024

@Mi1ind and I were able to easily reproduce this issue using the inception Rune on his computer (revision 7312198).

Here is a slightly cleaner backtrace that we captured. It looks like the segfault happens inside gemmlowp, the library used by TensorFlow Lite to do matrix math.

Interestingly, the address mentioned in the hardware exception ( EXC_BAD_ACCESS (code=1, address=0x3110)) is 0x3110, which is very low for a 64-bit program on an OS using ASLR.

$ (lldb) bt
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3110)
  * frame #0: 0x0000000101061314 rune`void gemmlowp::DispatchGemmShape<unsigned char, short, gemmlowp::BitDepthParams<gemmlowp::OperandRange<1, 255>, gemmlowp::OperandRange<0, 255> >, (gemmlowp::MapOrder)1, (gemmlowp::MapOrder)0, (gemmlowp::MapOrder)0, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0>, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1>, std::__1::tuple<gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStage Clamp, gemmlowp::OutputStageSaturatingCastToInt16>, gemmlowp::GemmContext>(gemmlowp::GemmContext*, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::Map Order)1> const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOrder)0> const&, gemmlowp::MatrixMap<short, (gemmlowp::MapOrder)0>*, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0> const&, gemmlowp::VectorDup<int c onst, (gemmlowp::VectorShape)1> const&, std::__1::tuple<gemmlowp::OutputStage ScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp::Outp utStageSaturatingCastToInt16> const&) + 20
    frame #1: 0x00000002885e1240
    frame #2: 0x000000010105d0b8 rune`gemmlowp::ComputeImpl<gemmlowp::PackedSideBlock<gemmlowp::KernelSideFormat<gemmlowp::CellFormat<4, 2, (gemmlowp::CellOrder)1>, 3> >, gemmlowp::PackedSideBlock<gemmlowp::KernelSideFormat<gemmlowp::CellFormat<4, 2, (gemmlowp::CellOrder)1>, 1> >, gemmlowp::PackedResult>::ComputeRun(int, int, int, int) + 216
    frame #3: 0x0000000100fe0eab rune`void gemmlowp::SingleThreadGemm<gemmlowp::KernelFormat<gemmlowp::KernelSideFormat<gemmlowp::CellFormat<4, 2, (gemmlowp::CellOrder)1>, 3>, gemmlowp::KernelSideFormat<gemmlowp::CellFormat<4, 2, (gemmlowp::CellOrder)1>, 1> >, unsigned char, unsigned char, gemmlowp::BitDepthParams<gemmlowp::OperandRange<1, 255>, gemmlowp::OperandRange<0, 255> >, (gemmlowp::MapOrder)1, (gemmlowp::MapOrder)0, (gemmlowp::MapOrder)1, gemmlowp::V ectorDup<int const, (gemmlowp::VectorShape)1>, gemmlowp::VectorDup<int const,(gemmlowp::VectorShape)0>, std::__1::tuple<gemmlowp::OutputStageBiasAddition <gemmlowp::VectorMap<int const, (gemmlowp::VectorShape)1> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint8> >(gemmlowp::SingleThreadGemmContext*, gemm lowp::KernelBase const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp:: MapOrder)1> const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOr der)0> const&, gemmlowp::MatrixMap<unsigned char, (gemmlowp::MapOrder)1>*, ge mmlowp::VectorDup<int const, (gemmlowp::VectorShape)1> const&, gemmlowp::Vect orDup<int const, (gemmlowp::VectorShape)0> const&, std::__1::tuple<gemmlowp:: OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gemmlowp::VectorShape)1> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::Outp utStageClamp, gemmlowp::OutputStageSaturatingCastToUint8> const&) + 1179
    frame #4: 0x0000000100fdfd73 rune`void gemmlowp::DispatchGemmShape<unsigned char, unsigned char, gemmlowp::BitDepthParams<gemmlowp::OperandRange<1, 255>, gemmlowp::OperandRange<0, 255> >, (gemmlowp::MapOrder)1, (gemmlowp::MapOrder)0, (gemmlowp::MapOrder)1, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1>, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0>, std::__1::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gem mlowp::VectorShape)1> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint8>, gemmlowp::GemmContext>(gemmlowp::GemmContext*, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOrder)1> const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOrder)0> const&, gemmlowp::MatrixMap<unsigned char, (gemm lowp::MapOrder)1>*, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1> const&, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0> const&, std: :__1::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gemmlowp::VectorShape)1> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndEx ponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint 8> const&) + 291
    frame #5: 0x0000000100fdfc07 rune`void gemmlowp::DispatchGemmShape<unsigned char, unsigned char, gemmlowp::BitDepthParams<gemmlowp::OperandRange<1, 255>, gemmlowp::OperandRange<0, 255> >, (gemmlowp::MapOrder)1, (gemmlowp::MapOrder)0, (gemmlowp::MapOrder)0, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0>, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1>, std::__1::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gem mlowp::VectorShape)0> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndExponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint8>, gemmlowp::GemmContext>(gemmlowp::GemmContext*, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOrder)1> const&, gemmlowp::MatrixMap<unsigned char const, (gemmlowp::MapOrder)0> const&, gemmlowp::MatrixMap<unsigned char, (gemm lowp::MapOrder)0>*, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)0> const&, gemmlowp::VectorDup<int const, (gemmlowp::VectorShape)1> const&, std: :__1::tuple<gemmlowp::OutputStageBiasAddition<gemmlowp::VectorMap<int const, (gemmlowp::VectorShape)0> >, gemmlowp::OutputStageScaleInt32ByFixedPointAndEx ponent, gemmlowp::OutputStageClamp, gemmlowp::OutputStageSaturatingCastToUint 8> const&) + 247
    frame #6: 0x0000000100fded6c rune`tflite::cpu_backend_gemm::detail::GemmImplUsingGemmlowp<unsigned char, unsigned char, int, unsigned char, (tflite::cpu_backend_gemm::QuantizationFlavor)1>::Run(tflite::cpu_backend_gemm::MatrixParams<unsigned char> const&, unsigned char const*, tflite::cpu_backend_gemm::MatrixParams<unsigned char> const&, unsigned char const*, tflite::cpu_backend_gemm::MatrixParams<unsigned char> const&, unsigned char*, tflite::cpu_backen d_gemm::GemmParams<int, unsigned char, (tflite::cpu_backend_gemm::QuantizationFlavor)1> const&, tflite::CpuBackendContext*) + 220
    frame #7: 0x0000000100fde277 rune`tflite::optimized_ops::Conv(tflite::ConvParams const&, tflite::RuntimeShape const&, unsigned char const*, tflite::RuntimeShape const&, unsigned char const*, tflite::RuntimeShape const&, int const*, tflite::RuntimeShape const&, unsigned char*, tflite::RuntimeShape const&, unsigned char*, tflite::CpuBackendContext*) + 615
    frame #8: 0x0000000100fefcb9 rune`void tflite::ops::builtin::conv::EvalQuantized<(tflite::ops::builtin::conv::KernelType)2>(TfLiteContext*, TfLiteNode*, TfLiteConvParams*, tflite::ops::builtin::conv::OpData*, TfLiteTensor*, TfLiteTensor*, TfLiteTensor*, TfLiteTensor*, TfLiteTensor*, TfLiteTensor*) + 713
    frame #9: 0x0000000100fc28c7 rune`TfLiteStatus tflite::ops::builtin::conv::Eval<(tflite::ops::builtin::conv::KernelType)2>(TfLiteContext*, TfLiteNode* + 695
    frame #10: 0x0000000100f707ec rune`tflite::Subgraph::Invoke() + 732
    frame #11: 0x0000000100f763bd rune`tflite::Interpreter::Invoke() + 29
    frame #12: 0x0000000100f65ee8 rune`__cpp_closure_11793350538227341524_impl(interpreter=0x00007ffeefbfb048) at mod.rs:117:37
    frame #13: 0x0000000100f65ec1 rune`::__cpp_closure_11793350538227341524(interpreter=0x00007ffeefbfb048, __result=0x00007ffeefbfb057) at mod.rs:122:28
    frame #14: 0x00000001001eff7e rune`tflite::interpreter::Interpreter$LT$Op$GT$::invoke::h8b6fe16ffa5e4fb5(self=0x0000000105849f20) at mod.rs:116:13
    frame #15: 0x00000001001f4266 rune`_$LT$tflite..interpreter..Interpreter$LT$tflite..interpreter..ops..builtin..resolver..Resolver$GT$$u20$as$u20$runicos_base..image..Model$GT$::infer::hb895634a5a176650(self=0x0000000105849f20, nput=(data_ptr = "����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���������������������������������������������������������������������������������������������������������������������������������������������������������� ����������������������������������������������������������������������������� ����������������������������������������������������������������������������� ����������������������������������������������������������������������������� ����������������������������������������������������������������������������� ����������������������������������������������������������������������������� ����������������������������������������������������������������������������� �����������������������������������������"..., length = 150528), output=(data _ptr = "", length = 1001)) at �image.rs:508:9
    frame #16: 0x000000010020c6ba rune`runicos_base::image::tfm_model_invoke::_$u7b$$u7b$closure$u7d$$u7d$::ha2f339d8d733b538(ctx=&CallContext @ 0x00007ffeefbfb7d8, (null)=<unavailable>) at image.rs:429:13
    frame #17: 0x00000001001f93db rune`rune_runtime::function::Function::new::_$u7b$$u7b$closure$u7d$$u7d$::hab7005e2ca6d17de(ctx=&CallContext @ 0x00007ffeefbfba48, args=(data_ptr = 0x0000000103f30490, length = 5)) at function.rs:80:31
    frame #18: 0x0000000100c9c5d3 rune`_$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..Fn$LT$Args$GT$$GT$::call::h43a116a6e7fb9b1e(self=0x0000000103f32a40, args=(&CallContext, &[rune_runtime::WasmValue]) @ 0x00007ffeefbfbac8) at boxed.rs:1589:9
    frame #19: 0x0000000100c9d96c rune`rune_runtime::function::Function::call::h707488c77e13dc46(self=0x0000000103f32a20, ctx=&CallContext @ 0x00007ffeefbfbb50, args=(data_ptr = 0x0000000103f30490, length = 5)) at function.rs:97:9
    frame #20: 0x0000000100226f9f rune`_$LT$rune_wasmer_runtime..Registrar$u20$as$u20$rune_runtime..Registrar$GT$::register_function::_$u7b$$u7b$closure$u7d$$u7d$::h979bcdbd7cc48447(ctx=0x0000000103f852f0, args=(data_ptr = 0x000000010781f250, length = 5)) at lib.rs:121:23
    frame #21: 0x00000001002322a2 rune`_$LT$wasmer..externals..function..DynamicFunctionWithEnv$LT$Env$GT$$u20$as$u20$wasmer..externals..function..VMDynamicFunction$GT$::call::hc2c0995f41142c44(self=0x0000000103f86138, args=(data_ptr = 0x000000010781f250, length = 5)) at function.rs:856:9
    frame #22: 0x0000000100232533 rune`_$LT$wasmer_vm..vmcontext..VMDynamicFunctionContext$LT$T$GT$$u20$as$u20$wasmer..externals..function..VMDynamicFunctionCall$LT$T$GT$$GT$::func_wrapper::_$u7b$$u7b$closure$u7d$$u7d$::hb40770296ce01cff at function.rs:896:27
    frame #23: 0x0000000100234369 rune`core::ops::function::FnOnce::call_once::h2825bca8898bbc42((null)=closure-0 @ 0x00007ffeefbfc368, (null)=<unavailable>) at function.rs:227:5
    frame #24: 0x0000000100230095 rune`_$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h3a2873dfc110f321(self=AssertUnwindSafe<closure-0> @ 0x00007ffeefbfc3b0, _args=<unavailable>) at panic.rs:344:9
    frame #25: 0x000000010022bd5a rune`std::panicking::try::do_call::hd43c9057cc277600(data="xſ��") at panicking.rs:379:40
    frame #26: 0x000000010022bedb rune`__rust_try + 43 frame #27: 0x00000001022baa9 rune`std::panicking::try::h2205cc8779b1474b
(f=AssertUnwindSafe<closure-0> @ 0x00007ffeefbfc4c8) at panicking.rs:343:19
    frame #28: 0x000000010023015c rune`std::panic::catch_unwind::hc518dfb817cef1e7(f=AssertUnwindSafe<closure-0> @ 0x00007ffeefbfc540) at panic.rs:431:14
    frame #29: 0x0000000100221374 rune`_$LT$wasmer_vm..vmcontext..VMDynamicFunctionContext$LT$T$GT$$u20$as$u20$wasmer..externals..function..VMDynamicFunctionCall$LT$T$GT$$GT$::func_wrapper::haf5fefa407bd2d59(self=0x0000000103f86130, values_vec=0x00007ffeefbfc5f0) at function.rs:890:22
    frame #30: 0x00000001079d2f47
    frame #31: 0x0000000107937c18
    frame #32: 0x000000010793401d
    frame #33: 0x000000010793fb21
    frame #34: 0x00000001079648e7
    frame #35: 0x00000001079d262d
    frame #36: 0x0000000100b959e1 rune`wasmer_vm::trap::traphandlers::wasmer_call_trampoline::_$u7b$$u7b$closure$u7d$$u7d$::h4b0ff2e273d96f8a at traphandlers.rs:504:9
    frame #37: 0x0000000100b95e31 rune`wasmer_vm::trap::traphandlers::catch_traps::call_closure::ha0a5f54abcf1845e(payload="8ӿ��") at traphandlers.rs:536:18
    frame #38: 0x0000000100bbf9f6 rune`RegisterSetjmp(buf_storage=0x00007ffeefbfd2c0, body=(rune`wasmer_vm::trap::traphandlers::catch_traps::call_closure::ha0a5f54abcf1845e at traphandlers.rs:532), payload=0x00007ffeefbfd350) at helpers.c:15:3
    frame #39: 0x0000000100b95dc0 rune`wasmer_vm::trap::traphandlers::catch_traps::_$u7b$$u7b$closure$u7d$$u7d$::h2890668d5849e27e(cx=0x00007ffeefbfd288) t traphandlers.rs:525:9
    frame #40: 0x0000000100b960ad rune`wasmer_vm::trap::traphandlers::CallThreadState::with::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hb183b908be0fbe3d at traphandlers.rs:601:42
    frame #41: 0x0000000100bbb880 rune`wasmer_vm::trap::traphandlers::tls::set::_$u7b$$u7b$closure$u7d$$u7d$::hf59ea4cef977e393(p=0x0000000105008770) at traphandlers.rs:761:13
    frame #42: 0x0000000100b78320 rune`std::thread::local::LocalKey$LT$T$GT$::try_with::h0190ed433476876d(self=0x0000000101797400, f=closure-0 @ 0x00007ffeefbfcaa0) at local.rs:376:16
    frame #43: 0x0000000100b7819c rune`std::thread::local::LocalKey$LT$T$GT$::with::hb36939b5639c834b(self=0x0000000101797400, f=<unavailable>) at local.rs:352:9
    frame #44: 0x0000000100bbb814 rune`wasmer_vm::trap::traphandlers::tls::set::hc69eaf83d32a8125(ptr=0x00007ffeefbfd288, closure=closure-1 @ 0x00007ffeefbfcb00) at traphandlers.rs:759:9
    frame #45: 0x0000000100b9678b rune`wasmer_vm::trap::traphandlers::CallThreadState::with::_$u7b$$u7b$closure$u7d$$u7d$::h3d54c0f19988499c(prev=Option<&wasmer_vm::trap::traphandlers::CallThreadState> @ 0x00007ffeefbfce88) at traphandlers.rs:601:23
    frame #46: 0x0000000100bbbcdf rune`wasmer_vm::trap::traphandlers::tls::with::_$u7b$$u7b$closure$u7d$$u7d$::h3520867863f23b96(ptr=0x0000000105008770) at traphandlers.rs:770:22
    frame #47: 0x0000000100b78475 rune`std::thread::local::LocalKey$LT$T$GT$::try_with::h0d2e4c51ddd79ed1(self=0x0000000101797400, f=closure-0 @ 0x00007ffeefbfd028) at local.rs:376:16
    frame #48: 0x0000000100b78145 rune`std::thread::local::LocalKey$LT$T$GT$::with::h9246a7789fede286(self=0x0000000101797400, f=closure-0 @ 0x00007ffeefbfd0c0) at local.rs:352:9
    frame #49: 0x0000000100bbba53 rune`wasmer_vm::trap::traphandlers::tls::with::h220754374e37b24f(closure=closure-0 @ 0x00007ffeefbfd100) at traphandlers.rs:768:9
    frame #50: 0x0000000100b9600c rune`wasmer_vm::trap::traphandlers::CallThreadState::with::h30cbff9d16adf4c8(self=CallThreadState @ 0x00007ffeefbfd288, losure=closure-0 @ 0x00007ffeefbfd148) at traphandlers.rs:599:9
    frame #51: 0x0000000100b95d36 rune`wasmer_vm::trap::traphandlers::catch_traps::h733696d81de870d2(vmctx=VMFunctionEnvironment @ 0x00007ffeefbfd2f0, closure=closure-0 @ 0x00007ffeefbfd350) at traphandlers.rs:524:12
    frame #52: 0x0000000100b9598c rune`wasmer_vm::trap::traphandlers::wasmer_call_trampoline::h433b1fdcd204d5c5(vmctx=VMFunctionEnvironment @ 0x00007ffeefbfd330, trampoline=(0x00000001079d25e0), callee=0x0000000107964790, values_vec="") at traphandlers.rs:503:5
    frame #53: 0x00000001002233db rune`wasmer::native::NativeFunc$LT$$LP$A1$C$A2$C$A3$RP$$C$Rets$GT$::call::h05e39d5c7f18d9e5(self=0x00007ffeefbfdf38, A1=0, A2=0, A3=0) at native.rs:139:29
    frame #54: 0x0000000100235a4c rune`rune_wasmer_runtime::Runtime::call::h75078b8ded146df7(self=0x00007ffeefbfe7d0) at lib.rs:69:9
    frame #55: 0x0000000100057765 rune`rune::run::Run::execute::h6b08d5d600a36ca1(self=Run @ 0x00007ffeefbff028) at run.rs:56:13
    frame #56: 0x0000000100012097 rune`rune::main::h219e6534771ef61a at main. rs:46:32
    frame #57: 0x000000010000863e rune`core::ops::function::FnOnce::call_once::hb4045903df9d0e8c((null)=(rune`rune::main::h219e6534771ef61a at main.rs:28), (null)=<unavailable>) at function.rs:227:5
    frame #58: 0x000000010000cc01 rune`std::sys_common::backtrace::__rust_begin_short_backtrace::he9b86a90e76c8cb0(f=(rune`rune::main::h219e6534771ef61a at main.rs:28)) at backtrace.rs:125:18
    frame #59: 0x000000010004b464 rune`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hb62e795d7d5efe03 at rt.rs:49:18
    frame #60: 0x0000000101567301 rune`std::rt::lang_start_internal::h09b48eb36ffca70d [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h88801ec30fa967bc at function.rs:259:13 [opt]
    frame #61: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb36ffca70d [inlined] std::panicking::try::do_call::ha5838b1ed53bb3ce at panicking.rs:379 [opt]
    frame #62: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb36ffca70d [inlined] std::panicking::try::h2c2c426e3f3c01a8 at panicking.rs:343 [opt]
    frame #63: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb36ffca70d [inlined] std::panic::catch_unwind::h383eb7eff10b175f at panic.rs:431 [opt]
    frame #64: 0x00000001015672fd rune`std::rt::lang_start_internal::h09b48eb36ffca70d at rt.rs:34 [opt]
    frame #65: 0x000000010004b43e rune`std::rt::lang_start::h7faecf3e55ba3944(main=(rune`rune::main::h219e6534771ef61a at main.rs:28), argc=4, argv=0x00007ffeefbff668) at rt.rs:48:5
    frame #66: 0x00000001000139c6 rune`main + 22
    frame #67: 0x00007fff67ac5cc9 libdyld.dylib`start + 1
    frame #68: 0x00007fff67ac5cc9 libdyld.dylib`start + 1

from rune.

Michael-F-Bryan avatar Michael-F-Bryan commented on June 9, 2024

@Mi1ind and I were initially thinking this may be an issue due to stack size because we'd seen heap_get_oom in #44, so we tried to update .cargo/config.toml to tell the linker to increase the initial stack size just for macs.

[target.x86_64-apple-darwin]
rustflags = [
  "-C", "link-args=-Wl,-stack_size,0x80000000",
]
[target.aarch64-apple-darwin]
rustflags = [
  "-C", "link-args=-Wl,-stack_size,0x80000000",
]

However this fails because, even if you add it to the .cargo directory next to the rune binary, we'll still try to compile proc macros with those linker arguments and the linker complains because -stack_size is only valid for binaries (proc macros are a *.so file).

Our next attempt was to run the main() function on a background thread and use std::thread::Builder's stack_size() method to set the stack size to 64MB. The thinking being that it using such a large stack should eliminate the possibility of a segfault due to overflowing the stack and hitting a guard page.

The thread method didn't work either, so we're thinking it may just be a bug in the gemmlowp library used by TensorFlow Lite for matrix math. If so, it should be resolved by #155.

CC: @kthakore.

from rune.

Michael-F-Bryan avatar Michael-F-Bryan commented on June 9, 2024

After switching from the tflite crate to librunecoral, @Mohit0928 found that rune run still sometimes segfaults on MacOS. I'm guessing this is a bug in the TensorFlow repository itself because we are seeing the same issue when building TensorFlow Lite in two very different ways (tflite uses CMake while librunecoral uses Bazel, both are using commits 5 or 6 months apart).

from rune.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.