Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segmentation fault on "napi_wrap" when trying to call a loaded .node extension #1286

Closed
Tracked by #1523
nya1 opened this issue Oct 1, 2022 · 0 comments
Closed
Tracked by #1523
Labels
bug Something isn't working needs repro Needs an example to reproduce

Comments

@nya1
Copy link

nya1 commented Oct 1, 2022

Version

0.1.14

Platform

Linux debian 5.10.0-11-amd64 #1 SMP Debian 5.10.92-2 (2022-02-28) x86_64 GNU/Linux

What steps will reproduce the bug?

I have created two methods to reproduce the error, one manually and the other one via docker

Manual

  1. install oracledb in the current directory, npm i [email protected]
  2. run the following script with bun
// this script should be executed in the same dir where you have installed the oracledb package
const platform = process.platform;
// e.g. ./node_modules/oracledb/build/Release/oracledb-5.5.0-linux-x64.node
const oracleLibNodeExtension = `./node_modules/oracledb/build/Release/oracledb-5.5.0-${platform}-x64.node`
const oraclelib = require(oracleLibNodeExtension)

oraclelib.init(new class {})

Docker

  1. build the following docker image, docker build . -t buntesting:latest
# Dockerfile
FROM node:14-bullseye-slim

RUN apt-get update && apt-get install curl unzip -y

# install canary bun
RUN curl -OL https://github.com/oven-sh/bun/releases/download/canary/bun-linux-x64.zip && unzip bun-linux-x64.zip -d ~/

# add oracle module
RUN npm init -y && npm i [email protected]

# create test file
RUN echo "\
const oraclelib = require('./node_modules/oracledb/build/Release/oracledb-5.5.0-linux-x64.node');\
oraclelib.init(new class {});" > test.js

# run test file with bun
RUN ~/bun-linux-x64/bun test.js

How often does it reproduce? Is there a required condition?

Always, tested with bun 0.1.13 and 0.1.14

What is the expected behavior?

The expected behavior should be an "Invalid argument" error with exit code 1 (because it expects an oracle class as input), the same as node (tested on version 14):

Error: Invalid argument
    at Object.<anonymous> (/test.js:1:108)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at internal/main/run_main_module.js:17:47

What do you see instead?

Segmentation fault error

from bun-profile executed in lldb

Process 6152 launched: '/home/user/.bun/bin/bun-profile' (x86_64)
Process 6152 stopped
* thread #1, name = 'bun-profile', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
    frame #0: 0x0000000005690aba bun-profile`napi_wrap + 458
bun-profile`napi_wrap:
->  0x5690aba <+458>: movq   %r12, 0x18(%rbx)
    0x5690abe <+462>: xorl   %eax, %eax
    0x5690ac0 <+464>: testq  %r14, %r14
    0x5690ac3 <+467>: je     0x5690ac8                 ; <+472>
SegmentationFault at 0x1800000000000000


----- bun meta -----
Bun v0.1.14 (c57b32fa) Linux x64 #1 SMP Fri Apr 22 12:57:03 CEST 2022
AutoCommand: 
Elapsed: 106448ms | User: 4ms | Sys: 7ms
RSS: 67.11MB | Peak: 32.62MB | Commit: 67.11MB | Faults: 0
----- bun meta -----

Ask for #help in https://bun.sh/discord or go to https://bun.sh/issues

Process 6152 exited with status = 139 (0x0000008b) 

Additional information

To give more context, the .node extension is needed by oracledb module, it is loaded via require and then initialized, this is where I observed the segmentation fault

@nya1 nya1 added bug Something isn't working needs repro Needs an example to reproduce labels Oct 1, 2022
@nya1 nya1 changed the title segmentation fault on "napi_write" when trying to call a loaded .node extension segmentation fault on "napi_wrap" when trying to call a loaded .node extension Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs repro Needs an example to reproduce
Projects
None yet
Development

No branches or pull requests

1 participant