Skip to content

std::bad_alloc starting from 20.12.0 #52436

@bolt-juri-gavshin

Description

@bolt-juri-gavshin

Version

20.12.0

Platform

x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Build the following Dockerfile

FROM node:20.12.0-bookworm
WORKDIR /app
RUN echo 'foreground-scripts = true' >> .npmrc
RUN npm install rocksdb@5.2.1 --force --loglevel=verbose

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

Always

What is the expected behavior? Why is that the expected behavior?

Same as in 20.11.1:

<NPM fetch rows>
#7 3.613 npm info run rocksdb@5.2.1 install node_modules/rocksdb node-gyp-build
#7 3.613 
#7 3.613 > rocksdb@5.2.1 install
#7 3.613 > node-gyp-build
#7 3.613 
#7 3.711 npm info run rocksdb@5.2.1 install { code: 0, signal: null }
#7 3.722 
#7 3.722 added 12 packages in 3s
#7 3.722 
#7 3.722 5 packages are looking for funding
#7 3.722   run `npm fund` for details
#7 3.722 npm notice 
#7 3.723 npm notice New minor version of npm available! 10.2.4 -> 10.5.1
#7 3.723 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.1>
#7 3.723 npm notice Run `npm install -g npm@10.5.1` to update!
#7 3.723 npm notice 
#7 3.723 npm verb exit 0
#7 3.723 npm info ok 
#7 DONE 3.9s

What do you see instead?

<NPM fetch rows>
#7 2.704 npm info run rocksdb@5.2.1 install node_modules/rocksdb node-gyp-build
#7 2.704 
#7 2.704 > rocksdb@5.2.1 install
#7 2.704 > node-gyp-build
#7 2.704 
#7 2.806 terminate called after throwing an instance of 'std::bad_alloc'
#7 2.806   what():  std::bad_alloc
#7 2.806 Aborted
#7 2.806 
#7 2.847 gyp info it worked if it ends with ok
#7 2.848 gyp verb cli [
#7 2.848 gyp verb cli '/usr/local/bin/node',
#7 2.848 gyp verb cli '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
#7 2.848 gyp verb cli 'rebuild'
#7 2.848 gyp verb cli ]
#7 2.848 gyp info using node-gyp@10.0.1
#7 2.848 gyp info using node@20.12.0 | linux | x64
#7 2.853 gyp verb clean removing "build" directory
#7 2.882 gyp verb find Python Python is not set from command line or npm configuration
#7 2.883 gyp verb find Python Python is not set from environment variable PYTHON
#7 2.883 gyp verb find Python checking if "python3" can be used
#7 2.883 gyp verb find Python - executing "python3" to get executable path
#7 2.897 gyp verb find Python - executable path is "/usr/bin/python3"
#7 2.897 gyp verb find Python - executing "/usr/bin/python3" to get version
#7 2.912 gyp verb find Python - version is "3.11.2"
#7 2.915 gyp info find Python using Python version 3.11.2 found at "/usr/bin/python3"
#7 2.915 gyp verb get node dir no --target version specified, falling back to host node version: 20.12.0
#7 3.006 
#7 3.007 gyp verb install input version string "20.12.0"
#7 3.007 gyp verb install installing version: 20.12.0
#7 3.007 gyp verb install --ensure was passed, so won't reinstall if already installed
#7 3.008 gyp verb install version not already installed, continuing with install 20.12.0
#7 3.008 gyp verb ensuring devDir is created /root/.cache/node-gyp/20.12.0
#7 3.008 gyp verb created devDir /root/.cache
#7 3.008 gyp http GET https://nodejs.org/download/release/v20.12.0/node-v20.12.0-headers.tar.gz
#7 3.094 gyp http 200 https://nodejs.org/download/release/v20.12.0/node-v20.12.0-headers.tar.gz
<VERY LONG COMPILATION>

Additional information

Not sure, whether the bug is in NodeJS or rocksdb or node-gyp-build, but this code worked fine in NodeJS 16, 18 and 20.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gypIssues and PRs related to the GYP tool and .gyp build files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions