oven-sh / bun

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

crash when trying to load a library #11697

Open Polygons1 opened 5 months ago

Polygons1 commented 5 months ago

How can we reproduce the crash?

// Bun code
import { dlopen, FFIType, suffix } from "bun:ffi";

// Path to the dynamic library
const path = `./libsshot.${suffix}`;

// Load the dynamic library
const {
  symbols: {
    main, // the function to call
  },
} = dlopen(
  path, // the library name or file path
  {
    main: {
      // no arguments, returns a pointer to a string
      args: [],
      returns: FFIType.cstring,
    },
  }
);

// Call the function and log the result
const result = main();
console.log(`Result from Rust: ${result}`);

Relevant log output

============================================================
Bun v1.1.10 (5102a944) macOS Silicon
Args: "bun" "test.ts"
Features: jsc 
Builtins: "bun:ffi" "bun:main" 
Elapsed: 678ms | User: 23ms | Sys: 62ms
RSS: 32.65MB | Peak: 73.99MB | Commit: 1.07GB | Faults: 1029

panic(main thread): Segmentation fault at address 0x14D800000
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.10/Ma15102a94AC__uy7sJ_mozvpC+p1vpCmozvpCmrompCuo344B_A2CggggwtC

zsh: trace trap  bun test.ts

Stack Trace (bun.report)

Bun v1.1.10 (5102a94) on macos aarch64 [AutoCommand]

Segmentation fault at address 0x14D800000

nektro commented 1 week ago

what is the source of libsshot?