oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.54k stars 2.78k forks source link

NAPI Class Pointer Segfault #1711

Open cryptodeal opened 1 year ago

cryptodeal commented 1 year ago

What version of Bun is running?

0.4.1

What platform is your computer?

Darwin 22.1.0 arm64 arm

What steps can reproduce the bug?

Clone the following repo: https://github.com/cryptodeal/gen-napi

Ensure flashlight/arrayfire are installed: https://github.com/facebookresearch/shumai#install

Build bindings: bun install

Run:

bun demo.ts

What is the expected behavior?

Tensor operations work/no segfaulting. (node tensor.cjs to see expected behavior as this runs the same logic, but from node).

What do you see instead?

(base) cryptodeal@Jamess-MacBook-Pro gen-napi % lldb -- bun demo.ts
(lldb) target create "bun"
Current executable set to '/Users/cryptodeal/.bun/bin/bun' (arm64).
(lldb) settings set -- target.run-args  "demo.ts"
(lldb) r
Process 91492 launched: '/Users/cryptodeal/.bun/bin/bun' (arm64)
Process 91492 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xaa0003f3910043fd)
    frame #0: 0x00000001515a74f8 libflashlight.0.3.2.dylib`fl::Tensor::backendType(this=0x000000014c6dbf0c) const at TensorBase.cpp:138:17
   135  }
   136 
   137  TensorBackendType Tensor::backendType() const {
-> 138    return impl_->backendType();
   139  }
   140 
   141  TensorBackend& Tensor::backend() const {
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xaa0003f3910043fd)
  * frame #0: 0x00000001515a74f8 libflashlight.0.3.2.dylib`fl::Tensor::backendType(this=0x000000014c6dbf0c) const at TensorBase.cpp:138:17
    frame #1: 0x00000001515a5988 libflashlight.0.3.2.dylib`fl::detail::areBackendsEqual(a=0x000000014c6dbf0c, b=0x0000000104012a60) at TensorBackend.cpp:14:12
    frame #2: 0x00000001515ae67c libflashlight.0.3.2.dylib`fl::add(lhs=0x000000014c6dbf0c, rhs=0x0000000104012a60) at TensorBase.cpp:635:1
    frame #3: 0x00000001062193c4 flashlight_napi_bindings.node`Tensor::add(Napi::CallbackInfo const&) + 220
    frame #4: 0x00000001062548a4 flashlight_napi_bindings.node`Napi::InstanceWrap<Tensor>::InstanceMethodCallbackWrapper(napi_env__*, napi_callback_info__*)::'lambda'()::operator()() const + 128
    frame #5: 0x00000001062547cc flashlight_napi_bindings.node`Napi::InstanceWrap<Tensor>::InstanceMethodCallbackWrapper(napi_env__*, napi_callback_info__*) + 40
    frame #6: 0x000000011800803c

Additional information

No response

Jarred-Sumner commented 1 year ago

This was probably fixed in v0.6.7