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

Node Serialport crashes #4622

Open
GriffinSauce opened this issue Sep 8, 2023 · 7 comments · Fixed by #5452
Open

Node Serialport crashes #4622

GriffinSauce opened this issue Sep 8, 2023 · 7 comments · Fixed by #5452
Labels
bug Something isn't working crash An issue that could cause a crash needs investigate Needs to be investigated to find the root cause

Comments

@GriffinSauce
Copy link

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983 (congrats btw!)

What platform is your computer?

Darwin 21.6.0 arm64 arm

What steps can reproduce the bug?

Reproduction here

  • bun install @serialport/bindings-cpp
  • try to use serial port bindings, eg:
import { autoDetect } from "@serialport/bindings-cpp";

const Binding = autoDetect();
Binding.list();

This crashes with:

dyld[30366]: missing symbol called

What is the expected behavior?

The Node Serialport packages work as expected, the list command lists available serial ports etc.

What do you see instead?

Crash:

dyld[30366]: missing symbol called

Additional information

This package is the low-level interface for Node Serialport so I expect if this works the whole thing should. I suspect this issue has something to do with napi usage but I have 0 experience in this area.

@GriffinSauce GriffinSauce added the bug Something isn't working label Sep 8, 2023
@hugofreire
Copy link

+1

@overflowz
Copy link

overflowz commented Sep 15, 2023

It crashes with SIGSEGV when doing something like this:

import { SerialPort } from "serialport";

const sp = new SerialPort({
  path: "/dev/ttyUSB0",
  baudRate: 9600,
  autoOpen: true,
});

output: Job 1, 'bun src/index.ts' terminated by signal SIGSEGV (Address boundary error)

EDIT: using serialport version 12.0.0 (works with node on version 20)

Jarred-Sumner added a commit that referenced this issue Sep 15, 2023
Jarred-Sumner added a commit that referenced this issue Sep 15, 2023
* Fixes #4622

* cleanup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
@Jarred-Sumner Jarred-Sumner reopened this Sep 15, 2023
paperdave pushed a commit to SuperAuguste/bun that referenced this issue Sep 18, 2023
* Fixes oven-sh#4622

* cleanup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
@jakeg
Copy link
Contributor

jakeg commented Sep 22, 2023

This works for me in Bun 1.0.2:

$ bun install @serialport/bindings-cpp
import { autoDetect } from "@serialport/bindings-cpp"
const Binding = autoDetect()
console.log(await Binding.list())
// see a list correctly

But this doesn't (serialport is v12.0.0):

$ bun install serialport
import { SerialPort } from 'serialport'
const serial = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200, autoOpen: false })
serial.open((err) => console.log(err || 'success'))

Error shows as follows:

374 |       writable: !1,
375 |       configurable: !0
376 |     }), fn;
377 |   }
378 |
379 |   function fn() {
                             ^
error: Error
      at fn (node:util:379:26)
      at /mnt/c/code/node_modules/@serialport/bindings-cpp/dist/linux.js:31:19
      at open (/mnt/c/code/node_modules/@serialport/bindings-cpp/dist/linux.js:19:15)
      at open (/mnt/c/code/node_modules/@serialport/stream/dist/index.js:107:8)
      at /mnt/c/code/test.js:3:0
      at processTicksAndRejections (:55:76)

Is this related to trustedDependencies somehow?

@Electroid Electroid added crash An issue that could cause a crash needs investigate Needs to be investigated to find the root cause labels Oct 27, 2023
@robobun robobun added needs investigate Needs to be investigated to find the root cause and removed needs investigate Needs to be investigated to find the root cause labels Oct 27, 2023
@ScreamZ
Copy link

ScreamZ commented Nov 9, 2023

Interested in this

@GriffinSauce
Copy link
Author

GriffinSauce commented May 26, 2024

This works for me in Bun 1.0.2:

$ bun install @serialport/bindings-cpp
import { autoDetect } from "@serialport/bindings-cpp"
const Binding = autoDetect()
console.log(await Binding.list())
// see a list correctly

I've tried this but it didn't work for me when running the script with bun. It will work if you run with node so it's the runtime that is failing (not the install). It's been a while but I suspect you accidentally ran it with node. I can't make bun work with any permutation of the serialport libraries.

@Jarred-Sumner in #5452 you mention "serialport no longer crashes" but it does, the same reproduction applies. It might be worth mentioning that I'm running this on modern MBPs, I haven't checked whether Linux / Windows would run.

Thanks for looking into it so far!

@Matoseb
Copy link

Matoseb commented May 29, 2024

Got no luck too

@kdev
Copy link

kdev commented May 30, 2024

Bun is just quitting on me using the latest win 11 build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash needs investigate Needs to be investigated to find the root cause
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants