// 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]
How can we reproduce the crash?
Relevant log output
Stack Trace (bun.report)
Bun v1.1.10 (
5102a94
) on macos aarch64 [AutoCommand]Segmentation fault at address 0x14D800000
src.bun.js.base.wrapStaticMethod__struct_336730.method
llint_entry
llint_entry
llint_entry
vmEntryToJavaScript
JSC::AbstractModuleRecord::evaluate