Segmentation fault / std::bad_alloc on node version >= v12
See original GitHub issue[REQUIRED] Step 2: Describe your environment
- Operating System version: Ubuntu 20.04, Debian Buster, OSX 10.15.6, Alpine 3.12.0
- Firebase SDK version: 9.2.0
- Firebase Product: database
- Node.js version: v12.18.3
- NPM version: 6.14.6
[REQUIRED] Step 3: Describe the problem
We have a pretty basic js-script to update a property in firebase (see below). This script works fine on node v10 and v11 but has a segmentation fault (std::bad_alloc) when run on node v12 or higher
Steps to reproduce:
Switch node version and run script:
$ nvm use v10
Now using node v10.22.1 (npm v6.14.6)
$ time node fire.js
OK
node fire.js 0,30s user 0,04s system 26% cpu 1,249 total
$ nvm use v12
Now using node v12.18.3 (npm v6.14.6)
$ time node ./fire.js
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
[2] 3460141 abort (core dumped) node ./fire.js
node ./fire.js 0,28s user 0,03s system 0% cpu 1:01,63 total
(note the 28 second duration)
$ nvm use v14
Now using node v14.12.0 (npm v6.14.8)
$ time node fire.js
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
[2] 3456469 abort (core dumped) node fire.js
node fire.js 0,25s user 0,02s system 26% cpu 1,039 total
Relevant Code:
const admin = require('firebase-admin');
const FIREBASE_AUTH_DOMAIN = '';
const FIREBASE_DATABASE_URL = '';
const FIREBASE_CLIENT_EMAIL = '';
const FIREBASE_PRIVATE_KEY = ''
const credential = admin.credential.cert({
projectId: FIREBASE_AUTH_DOMAIN,
clientEmail: FIREBASE_CLIENT_EMAIL,
privateKey: FIREBASE_PRIVATE_KEY,
});
const app = admin.initializeApp(
{
credential,
databaseURL: FIREBASE_DATABASE_URL,
},
FIREBASE_AUTH_DOMAIN,
);
const firebaseScreenData = {
'some-prop': 'some-value',
};
const firebaseClient = app;
const database = firebaseClient.database();
const main = async () => {
try {
await database.ref('temp-db').set(firebaseScreenData);
await firebaseClient.delete();
} catch (e) {
console.log('Error', e);
throw e;
}
console.log('OK');
};
main();
Node versions tested:
| Version | Works |
|---|---|
| v8.11.4 | ✅ |
| v10.22.1 | ✅ |
| v11.15.0 | ✅ |
| v12.18.3 | ❌ |
| v13.14.0 | ❌ |
| v14.12.0 | ❌ |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:21 (5 by maintainers)
Top Results From Across the Web
node Segmentation fault on version change - Stack Overflow
When we type n the versions we installed show up but they are all greyed out. What's a Segmentation fault, why is it...
Read more >Installing node.js on v1 Model B - segmentation fault
newbie here. Raspberry Pi 1 Model B. Raspbian. Had Adafruit WebIDE before. pi@raspberrypi ~ $ node -v Segmentation fault. tried to uninstall:
Read more >The request for the fix and improvement of Node.js modules or ...
prompting a message “Segmentation fault (core dumped)”. But it is success to be running at cv::FileStorage.open() in Node.js version v12.18.2.
Read more >Core Dump (Segmentation fault) in C/C++ - GeeksforGeeks
It is an error indicating memory corruption. Common segmentation fault scenarios: Modifying a string literal : The below program may crash ( ...
Read more >IV79436: SEGMENTATION FAULT IN BASIC_STRING CODE ...
13 compiler or earlier encounters runtime segmentation faults after upgrading to the XL C++ Runtime, V13.1 (fileset: xlC.rte). The XL C++ Runtime, V12.1...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Same issue.
Running Firebase Admin on NodeJS > 11.15.0 cause “std::bad_alloc” or “Segmentation fault”
Node version : 14.6.0 Firebase Admin version : 9.4.2
Everything works well with Node v11.15.0 and firebase-admin@9.4.2
Getting the same on a simple read with a query