[go: nahoru, domu]

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

Crash installing on M1 Mac using arm64 node #3129

Closed
dgaedcke opened this issue Feb 11, 2021 · 33 comments
Closed

Crash installing on M1 Mac using arm64 node #3129

dgaedcke opened this issue Feb 11, 2021 · 33 comments

Comments

@dgaedcke
Copy link
dgaedcke commented Feb 11, 2021

[REQUIRED] Environment info

I've reinstalled Firebase with:
curl -sL firebase.tools | upgrade=true bash
and firebase --version
yields: Abort trap: 6 (partial log below)

Running M1 Mac 11.2
Node12 installed with Homebrew ARM64

~$ brew --version
Homebrew 3.0.0
Homebrew/homebrew-core (git revision 7eaf2; last commit 2021-02-09)
Homebrew/homebrew-cask (git revision c2081; last commit 2021-02-10)

[REQUIRED] Test case

Try it yourself on an M1 mac

[REQUIRED] Steps to reproduce

Try it yourself on an M1 mac

[REQUIRED] Expected behavior

Installs and runs

[REQUIRED] Actual behavior

==== JS stack trace =========================================

Security context: 0x00010c4408d1 <JSObject>
    0: builtin exit frame: new constructor(aka Module)(this=0x00010e9dc6f9 <Object map = 0x10ff30229>,0x00010e9dc5a9 <Uint8Array map = 0x10c402b99>,0x00010e9dc6f9 <Object map = 0x10ff30229>)

    1: ConstructFrame [pc: 0x1006f3698]
    2: StubFrame [pc: 0x1007dc144]
    3: /* anonymous */ [0x10e9dbe49] [/opt/homebrew/lib/node_modules/firebase-tools/node_modules/long/src/long.js:9] [bytecode=0x11...

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x1000920e0 node::Abort() [/opt/homebrew/opt/node@12/bin/node]
 2: 0x100092260 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string<std::nullptr_t>(char const*) [/opt/homebrew/opt/node@12/bin/node]
 3: 0x100197e14 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/opt/node@12/bin/node]
 4: 0x100197da8 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/opt/node@12/bin/node]
 5: 0x1005c8958 v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion) [/opt/homebrew/opt/node@12/bin/node]
 6: 0x1005c95d4 v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(unsigned int, v8::base::AddressRegion) [/opt/homebrew/opt/node@12/bin/node]
 7: 0x1005c8b9c v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion) [/opt/homebrew/opt/node@12/bin/node]
 8: 0x1005c941c v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, bool, v8::internal::VirtualMemory, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, std::__1::shared_ptr<v8::internal::Counters>, std::__1::shared_ptr<v8::internal::wasm::NativeModule>*) [/opt/homebrew/opt/node@12/bin/node]
 9: 0x1005cb31c v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::wasm::WasmEngine*, v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/opt/node@12/bin/node]
10: 0x1005d1674 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/opt/node@12/bin/node]
11: 0x1005d15bc v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/opt/node@12/bin/node]
12: 0x1005af038 v8::internal::wasm::CompileToNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, v8::internal::wasm::ModuleWireBytes const&, v8::internal::Handle<v8::internal::FixedArray>*) [/opt/homebrew/opt/node@12/bin/node]
13: 0x1005cf0d8 v8::internal::wasm::WasmEngine::SyncCompile(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, v8::internal::wasm::ModuleWireBytes const&) [/opt/homebrew/opt/node@12/bin/node]
14: 0x1005e80d4 v8::(anonymous namespace)::WebAssemblyModule(v8::FunctionCallbackInfo<v8::Value> const&) [/opt/homebrew/opt/node@12/bin/node]
15: 0x1001e6848 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/opt/homebrew/opt/node@12/bin/node]
16: 0x1001e5c70 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/opt/homebrew/opt/node@12/bin/node]
17: 0x1001e5788 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/opt/homebrew/opt/node@12/bin/node]
18: 0x10077600c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/opt/homebrew/opt/node@12/bin/node]
19: 0x1006f3698 Builtins_JSBuiltinsConstructStub [/opt/homebrew/opt/node@12/bin/node]
20: 0x1007dc144 Builtins_ConstructHandler [/opt/homebrew/opt/node@12/bin/node]
21: 0x1006f8460 Builtins_InterpreterEntryTrampoline [/opt/homebrew/opt/node@12/bin/node]
22: 0x1006f8460 Builtins_InterpreterEntryTrampoline [/opt/homebrew/opt/node@12/bin/node]
@approached
Copy link

Just try with the current version.

brew install node

@approached
Copy link

FYI: #3120

@donhmorris
Copy link

I can confirm this is a problem with m1 macs. You can't deploy firebase functions with any version of node. The firebase cli does not work for functions on m1 macs.

I also received a message from firebase support indicating it is not a priority for them to fix, so good luck.

@inlined inlined self-assigned this Feb 17, 2021
@inlined
Copy link
Member
inlined commented Feb 17, 2021

I don't have immediate access to an M1. I'm going to try to get my hands on one and look into it.

@kmcnellis
Copy link
Member
kmcnellis commented Feb 17, 2021

I'm not able to replicate this on a Mac Mini M1 running node v12.20 or v15.8, and firebase-tools v9.4.0. (and brew v2.7.3). I updated node using the n cli.

I tried installing via npm install firebase-tools -g and also via curl -sL firebase.tools | upgrade=true bash, and both work for me.

firebase --version and firebase deploy on the code from https://github.com/firebase/quickstart-js/tree/master/functions both are succeeding.

@dgaedcke
Copy link
Author

yes, the Firebase CLI won't run on M1 macs, but you can get around this problem by doing the following:

add this code near the top of your function:

process.env.GCLOUD_PROJECT = "pbusterapi"
const admin = require('firebase-admin');
admin.initializeApp();

and then use gcloud to deploy as follows:

gcloud functions deploy newCommFeedRecord
--trigger-event providers/google.firebase.database/eventTypes/ref.create
--trigger-resource projects/_/instances/pbusterapi/refs/commNews/{date}/{window}/{record}
--runtime nodejs12 --project pbusterapi

it will attempt an init by guessing the creds directly from the project name
that seems to be working for us right now

@donhmorris
Copy link

I'm not able to replicate this on a Mac Mini M1 running node v12.20 or v15.8, and firebase-tools v9.4.0. (and brew v2.7.3)

I tried installing via npm install firebase-tools -g and also via curl -sL firebase.tools | upgrade=true bash, and both work for me.

firebase --version and firebase deploy on the code from https://github.com/firebase/quickstart-js/tree/master/functions both are succeeding.

The only problem is deploying functions. Try deploying 3 or 4 functions using this command: firebase deploy --only functions

Let me know what happens using node 15.8

@donhmorris
Copy link

I haven't tried using node 12. I've been using node 14 & 15.

@kmcnellis
Copy link
Member

No issues using node 15 and firebase deploy --only functions

node -v : v15.8.0

@donhmorris
Copy link

@dgaedcke I've been using my windows machine to deploy my functions. I don't want to code around the cli issue.

The best option is to fix what is wrong with the cli running on apple silicon. The dev kit for apple silicon has been out since last summer. If I were a firebase project lead I would have assigned qa testing for the cli on apple silicon months ago. Firebase is a product sold by google, so I would want to know my product worked correctly on something as major as apple silicon.

@donhmorris
Copy link

No issues using node 15 and firebase deploy --only functions

node -v : v15.8.0

Very interesting. You are the first to report that. Firebase support sent me a message indicating they knew it was a documented issue. It might be helpful if they knew what was different in your setup.

Do you have the gcloud tools installed?

@kmcnellis
Copy link
Member

Not currently. I'll try that next.

Could it have to do with homebrew? I changed node versions with the n tool, not brew.

@donhmorris
Copy link

I don't think so.
I'm using nvm which built nodejs from src for version 14 & 15 since the binaries were not present for darwin/arm64.
Im using npm 6 instead of 7 since 7 has had some issues.

Fortunately I have a windows machine I can use since I build windows desktop apps for some of my clients.

@kmcnellis
Copy link
Member

Have you tried on the latest firebase-tools version?

@kmcnellis
Copy link
Member

I think I've narrowed this down to node being installed via nvm (built locally, rather than downloading binaries).

When installing node via n (downloads binary):

  • sudo n 15.8 : installed : v15.8.0
  • which node : /usr/local/bin/node
    Deploy complete

When installing node via nvm (builds binary locally):

  • nvm install 15.8
  • nvm use 15 : Now using node v15.8.0 (npm v7.5.1)
  • which node: /Users/kiana/.nvm/versions/node/v15.8.0/bin/node

Deployment error. Build failed: Build error details not available.

@donhmorris
Copy link

Interesting. Where did you get your darwin/arm64 node binaries from?

@Golosay
Copy link
Golosay commented Feb 22, 2021

Have the same issue.
nvm@0.37.2
node@14.15.4
firebase-tools@9.4.0

Will it help to switch to n or volta?

@donhmorris
Copy link

I don't know. There are multiple issues related to m1.

  • I have not been able to find node binaries for darwin/arm64 so I use nvm to build them
  • NPM v7 has documented issues. Angular 11 does not currently work with npm 7
  • Firebase cli crashes with node 14
  • Firebase deploy of functions fails with node 15

It's just a rough road right now. Kiana says she has not had the same problems but everyone I have talked to has. I'm wondering if she installed node while using the terminal running under rosetta. I tried that and the intel binaries for node get installed that way, but you don't get the benefit of arm64 while using node.

@Golosay
Copy link
Golosay commented Feb 22, 2021

I don't know. There are multiple issues related to m1.

  • I have not been able to find node binaries for darwin/arm64 so I use nvm to build them
  • NPM v7 has documented issues. Angular 11 does not currently work with npm 7
  • Firebase cli crashes with node 14
  • Firebase deploy of functions fails with node 15

It's just a rough road right now. Kiana says she has not had the same problems but everyone I have talked to has. I'm wondering if she installed node while using the terminal running under rosetta. I tried that and the intel binaries for node get installed that way, but you don't get the benefit of arm64 while using node.

Just tried Volta with node 14 LTS. It uses Rosetta 2 under the hood to run node. And it solves the issue with the Firebase cli. Just deployed my functions 🙃

@donhmorris
Copy link

That makes sense. If I didn't have my windows machine to deploy my functions I would probably have to run node under rosetta too.
It would be nice if Firebase would just fix the issue in the cli of running on darwin/arm64. Every other thing I do with node running on arm64 works fine.

@kmcnellis
Copy link
Member

Ah, that's an excellent insight @donhmorris. The n version does indeed run the x64 binaries, and nvm runs arm64.

@kmcnellis kmcnellis changed the title Crash installing on M1 Mac Crash installing on M1 Mac using arm64 node Feb 23, 2021
@taeold
Copy link
Contributor
taeold commented Feb 25, 2021

@donhmorris Thanks for your patience here. IIUC -

  1. In M1 Macs, Firebase CLI works with node 15
  2. In M1 Macs, Firebase CLI fails to deploy functions

Did I get this right? If so, can you share the error you are seeing when trying to deploy functions using node 15? Preferably on #3120.

@donhmorris
Copy link

@taeold yes, that is correct. Node 15+ built by nvm using source.

@kmcnellis
Copy link
Member

Added the cloud build logs to #3120

@Dellil
Copy link
Dellil commented Mar 20, 2021

I'm using node 12 on mac m1 and have the same trouble.
firebase-tools@9.6.1


[16492:0x150008000]      546 ms: Scavenge 34.5 (52.7) -> 25.0 (54.9) MB, 2.8 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[16492:0x150008000]     1004 ms: Scavenge 40.1 (58.1) -> 32.0 (62.6) MB, 3.1 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x00010d0808d1 <JSObject>
    0: builtin exit frame: new constructor(aka Module)(this=0x00010e6d69f9 <Object map = 0x1149ee749>,0x00010e6d68a9 <Uint8Array map = 0x10d042b99>,0x00010e6d69f9 <Object map = 0x1149ee749>)

    1: ConstructFrame [pc: 0x10130efb8]
    2: StubFrame [pc: 0x1013f7a64]
    3: /* anonymous */ [0x10e6d6149] [/opt/homebrew/lib/node_modules/firebase-tools/node_modules/long/src/long.js:9] [bytecode=0x11...

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x100cada60 node::Abort() [/opt/homebrew/opt/node@12/bin/node]
 2: 0x100cadbe0 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string<std::nullptr_t>(char const*) [/opt/homebrew/opt/node@12/bin/node]
 3: 0x100db3748 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/opt/node@12/bin/node]
 4: 0x100db36dc v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/opt/node@12/bin/node]
 5: 0x1011e427c v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion) [/opt/homebrew/opt/node@12/bin/node]
 6: 0x1011e4ef8 v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(unsigned int, v8::base::AddressRegion) [/opt/homebrew/opt/node@12/bin/node]
 7: 0x1011e44c0 v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion) [/opt/homebrew/opt/node@12/bin/node]
 8: 0x1011e4d40 v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, bool, v8::internal::VirtualMemory, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, std::__1::shared_ptr<v8::internal::Counters>, std::__1::shared_ptr<v8::internal::wasm::NativeModule>*) [/opt/homebrew/opt/node@12/bin/node]
 9: 0x1011e6c40 v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::wasm::WasmEngine*, v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/opt/node@12/bin/node]
10: 0x1011ecf98 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/opt/node@12/bin/node]
11: 0x1011ecee0 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/opt/node@12/bin/node]
12: 0x1011ca95c v8::internal::wasm::CompileToNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, v8::internal::wasm::ModuleWireBytes const&, v8::internal::Handle<v8::internal::FixedArray>*) [/opt/homebrew/opt/node@12/bin/node]
13: 0x1011ea9fc v8::internal::wasm::WasmEngine::SyncCompile(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, v8::internal::wasm::ErrorThrower*, v8::internal::wasm::ModuleWireBytes const&) [/opt/homebrew/opt/node@12/bin/node]
14: 0x1012039f8 v8::(anonymous namespace)::WebAssemblyModule(v8::FunctionCallbackInfo<v8::Value> const&) [/opt/homebrew/opt/node@12/bin/node]
15: 0x100e0217c v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/opt/homebrew/opt/node@12/bin/node]
16: 0x100e015a4 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/opt/homebrew/opt/node@12/bin/node]
17: 0x100e010bc v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/opt/homebrew/opt/node@12/bin/node]
18: 0x10139192c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/opt/homebrew/opt/node@12/bin/node]
19: 0x10130efb8 Builtins_JSBuiltinsConstructStub [/opt/homebrew/opt/node@12/bin/node]
20: 0x1013f7a64 Builtins_ConstructHandler [/opt/homebrew/opt/node@12/bin/node]
21: 0x101313d80 Builtins_InterpreterEntryTrampoline [/opt/homebrew/opt/node@12/bin/node]
22: 0x101313d80 Builtins_InterpreterEntryTrampoline [/opt/homebrew/opt/node@12/bin/node]
23: 0x101313d80 Builtins_InterpreterEntryTrampoline [/opt/homebrew/opt/node@12/bin/node]
24: 0x104ff6510 
25: 0x10500b3b0 
...

[1]    16492 abort      firebase

Is there any solution without install node 15v or using volta?

@cvlos
Copy link
cvlos commented Mar 21, 2021

Any updates on this?

@kmcnellis
Copy link
Member

For the pre-node 15 questions, it does seem to be a problem with node itself, and it's generally fixed by running on the x86 / rosetta version - check out https://github.com/nvm-sh/nvm/blob/master/README.md#troubleshooting-on-macos

For the error where most of the CLI works, but functions deploys don't (due to the uploaded archive not being able to be uncompressed), check out #3120 for updates.

@jeffhodsdon
Copy link

Same issue here. Any update?

@donhmorris
Copy link

I haven't had any issues after installing node 16, which contains a binary version for arm64

@approached
Copy link

me 2

@tamer-mohamed
Copy link

same for me, any updates on this?

@taeold
Copy link
Contributor
taeold commented Aug 12, 2021

For the pre-node 15 questions, it does seem to be a problem with node itself, and it's generally fixed by running on the x86 / rosetta version - check out https://github.com/nvm-sh/nvm/blob/master/README.md#troubleshooting-on-macos

For the error where most of the CLI works, but functions deploys don't (due to the uploaded archive not being able to be uncompressed), check out #3120 for updates.

TL;DR - Please check your node version and upgrade to >15.3.0 (relevant stackoverflow).

@taeold taeold added the Needs: Author Feedback Issues awaiting author feedback label Aug 12, 2021
@tamer-mohamed
Copy link

For the pre-node 15 questions, it does seem to be a problem with node itself, and it's generally fixed by running on the x86 / rosetta version - check out https://github.com/nvm-sh/nvm/blob/master/README.md#troubleshooting-on-macos
For the error where most of the CLI works, but functions deploys don't (due to the uploaded archive not being able to be uncompressed), check out #3120 for updates.

TL;DR - Please check your node version and upgrade to >15.3.0 (relevant stackoverflow).

Works with node 15. Thank you @taeold

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests