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

macOS catalina unsupported in bun 0.1.13 #1266

Closed
kt3k opened this issue Sep 21, 2022 · 18 comments
Closed

macOS catalina unsupported in bun 0.1.13 #1266

kt3k opened this issue Sep 21, 2022 · 18 comments
Labels
bug Something isn't working os Something wrong with a specific OS

Comments

@kt3k
Copy link

kt3k commented Sep 21, 2022

Version

0.1.13

Platform

Darwin kt3k-mac.local 19.6.0 Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64 x86_64

What steps will reproduce the bug?

run any script with bun run script.js

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

100%

What is the expected behavior?

run script

What do you see instead?

crash

Additional information

$ cat a.js 
console.log("A");
$ bun run a.js
dyld: lazy symbol binding failed: Symbol not found: _pthread_self_is_exiting_np
  Referenced from: /Users/kt3k/.bun/bin/bun (which was built for Mac OS X 11.0)
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _pthread_self_is_exiting_np
  Referenced from: /Users/kt3k/.bun/bin/bun (which was built for Mac OS X 11.0)
  Expected in: /usr/lib/libSystem.B.dylib


Crash at 0xDE5EFF0E01000000


----- bun meta -----
Bun v0.1.13 (55bdf268) macOS x64 19.6.0
RunCommand: 
Elapsed: 2ms | User: 2ms | Sys: 3ms
RSS: 3.81MB | Peak: 3.81MB | Commit: 67.11MB | Faults: 3
----- bun meta -----
@kt3k kt3k added bug Something isn't working needs repro Needs an example to reproduce labels Sep 21, 2022
@Jarred-Sumner
Copy link
Collaborator

Looks like we are missing support for macOS Catalina due to this missing symbol

@Jarred-Sumner Jarred-Sumner removed the needs repro Needs an example to reproduce label Sep 21, 2022
@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented Sep 21, 2022

webkit has dropped support for their memory allocator on macOS 10.xx as of the most recent webkit upgrade

need to think on what to do about this

oven-sh/WebKit@677b453

@Jarred-Sumner Jarred-Sumner changed the title bun 0.1.13 crashes on running any script (macOS 10.15.7) macOS catalina unsupported in bun 0.1.13 Sep 21, 2022
@EliteCheng
Copy link

+1

@chrisAXZA
Copy link

chrisAXZA commented Oct 3, 2022

Same issue here on Mojave (0.1.13) =>
System Version: macOS 10.14.6 Kernel Version: Darwin 18.7.0

@baih-npu
Copy link

baih-npu commented Oct 7, 2022

how to change version of bun?

@Mouvedia
Copy link

This crash is still a blocker for me.

Bun: 0.5.1
macOS: 10.13.6

@chrisAXZA
Copy link

Due to webkit issues, bun is so far running only on Mac OS 11.x.x versions and above.

@gotjoshua
Copy link

bun is so far running only on Mac OS 11.x.x versions and above

ouch.

@kzc
Copy link

kzc commented Feb 24, 2023

Workaround for bun v0.5.7 on macOS 10.14 Mojave below. It may work on other x64 macOS 10.x versions - I haven't tried.

Given:

$ ./bun-darwin-x64/bun -v
0.5.7
$ cat test.js
console.log(40 + 2)
$ ./bun-darwin-x64/bun install uglify-js
bun add v0.5.7 (5929daee)

 installed uglify-js@3.17.4 with binaries:
  - uglifyjs

[5.00ms] done

Without workaround:

$ ./bun-darwin-x64/bun test.js
dyld: lazy symbol binding failed: Symbol not found: _pthread_self_is_exiting_np
  Referenced from: /private/tmp/v0.5.7/./bun-darwin-x64/bun
  Expected in: flat namespace

dyld: Symbol not found: _pthread_self_is_exiting_np
  Referenced from: /private/tmp/v0.5.7/./bun-darwin-x64/bun
  Expected in: flat namespace

Killed: 9
$ ./bun-darwin-x64/bun uglifyjs test.js -mc
dyld: lazy symbol binding failed: Symbol not found: _posix_spawn_file_actions_addchdir_np
  Referenced from: /private/tmp/v0.5.7/./bun-darwin-x64/bun
  Expected in: flat namespace

dyld: Symbol not found: _posix_spawn_file_actions_addchdir_np
  Referenced from: /private/tmp/v0.5.7/./bun-darwin-x64/bun
  Expected in: flat namespace

Killed: 9

Workaround:

$ cat hack.c
int pthread_self_is_exiting_np() { return 0; }
int posix_spawn_file_actions_addchdir_np() { return 0; }

$ cc -dynamiclib hack.c -o hack.dylib

With workaround:

$ DYLD_INSERT_LIBRARIES=`pwd`/hack.dylib DYLD_FORCE_FLAT_NAMESPACE=1 ./bun-darwin-x64/bun test.js
42
$ DYLD_INSERT_LIBRARIES=`pwd`/hack.dylib DYLD_FORCE_FLAT_NAMESPACE=1 ./bun-darwin-x64/bun uglifyjs test.js -mc
console.log(42);

Alternatively:

$ export DYLD_INSERT_LIBRARIES=`pwd`/hack.dylib

$ export DYLD_FORCE_FLAT_NAMESPACE=1

$ ./bun-darwin-x64/bun test.js
42

$ ./bun-darwin-x64/bun uglifyjs test.js -mc
console.log(42);

A workaround similar to the one above probably belongs in https://github.com/macports/macports-legacy-support. Here's a similar dummy _np stub added to that project: macports/macports-legacy-support@8af62cf if anyone cares to contribute.

@Jarred-Sumner
Copy link
Collaborator

@kzc Thank you for the suggested workaround

@Mouvedia
Copy link

I am still experiencing

dyld: lazy symbol binding failed: Symbol not found: _pthread_self_is_exiting_np
  Referenced from: …/.bun/bin/bun (which was built for Mac OS X 11.0)
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _pthread_self_is_exiting_np
  Referenced from: …/.bun/bin/bun (which was built for Mac OS X 11.0)
  Expected in: /usr/lib/libSystem.B.dylib

Killed: 9

Bun: 0.5.8 (supplied on this page)
macOS: 10.13.6

@ThatOneBro
Copy link
Contributor

ThatOneBro commented Feb 25, 2023

I think the build hasn't finished for Mac x64 yet, the CI still reports the job is running. Please try again in a little while and let us know if it's still not working

@Mouvedia
Copy link

@ThatOneBro I tried the one from https://github.com/oven-sh/bun/actions/runs/4266973594
And it seems to be working. This is great news :)

@ThatOneBro
Copy link
Contributor

Great to hear! Thanks @kzc for the fix!

@gotjoshua
Copy link

And it seems to be working.

How can i try to use that build?
(i mean which artifacts need to be placed where in order to execute the binary?)

@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented Feb 25, 2023 via email

@gotjoshua
Copy link

wow, thanks for the quick weekend reply...
just before returning here to find your reply, i managed to reinstall and then run

bun upgrade --canary

Works!!

@kzc
Copy link

kzc commented Feb 26, 2023

@Jarred-Sumner The big caveat for the workaround proposed for posix_spawn_file_actions_addchdir_np on macOS 10.x is that the cwd option for the following calls cannot be overridden and will incorrectly use the current working directory of the calling process:

child_process.exec
child_process.execSync
child_process.spawn
child_process.spawnSync
child_process.execFile
child_process.execFileSync

as they're all based on Bun.spawn which calls:

actions.chdir(cwd) catch |err| return globalThis.handleError(err, "in chdir()");

which in turn calls:

pub fn chdir(self: *Actions, path: []const u8) !void {
const posix_path = try toPosixPath(path);
return self.chdirZ(&posix_path);
}
pub fn chdirZ(self: *Actions, path: [*:0]const u8) !void {
switch (errno(system.posix_spawn_file_actions_addchdir_np(&self.actions, path))) {

Until a proper fix is made for macos 10.x, an assert could be added to terminate the program if the cwd option is specified and does not match the normalized getcwd().

When I proposed the original workaround I thought it was an unimportant start-up instruction.

cirospaciari pushed a commit that referenced this issue Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working os Something wrong with a specific OS
Projects
None yet
Development

No branches or pull requests

10 participants