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

OOM abort error #42

Closed
RaisinTen opened this issue Sep 28, 2022 · 1 comment · Fixed by #45
Closed

OOM abort error #42

RaisinTen opened this issue Sep 28, 2022 · 1 comment · Fixed by #45
Assignees
Labels
bug 🐛 Something isn't working crash 💥

Comments

@RaisinTen
Copy link
Contributor

RaisinTen commented Sep 28, 2022

System info

$ uname -a
Darwin Darshans-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64

Versions

Node.js version: v14.18.2
Postject version: v1.0.0-alpha.1

Repro

npm init --yes
echo "Hello, world!" > index.js
npx asar pack . app.asar
cp $(command -v node) .
npx postject ./node NODE_JS_CODE app.asar

app.asar has a size of 4.0K.

Error logs

log.txt

TLDR, bottom section of the log:

...
RuntimeError: Aborted(OOM). Build with -sASSERTIONS for more info.
    at abort (/Users/raisinten/.npm/_npx/6914/lib/node_modules/postject/dist/postject.js:9:7843)
    at abortOnCannotGrowMemory (/Users/raisinten/.npm/_npx/6914/lib/node_modules/postject/dist/postject.js:9:92949)
    at _emscripten_resize_heap (/Users/raisinten/.npm/_npx/6914/lib/node_modules/postject/dist/postject.js:9:93068)
    at <anonymous>:wasm-function[438]:0x1d1fd
    at hb (<anonymous>:wasm-function[193]:0xc3c0)
    at <anonymous>:wasm-function[114]:0x3d87
    at <anonymous>:wasm-function[448]:0x1d9ba
    at <anonymous>:wasm-function[3035]:0x1b9507
    at <anonymous>:wasm-function[2373]:0x138308
    at Object.getExecutableFormat (eval at new_ (/Users/raisinten/.npm/_npx/6914/lib/node_modules/postject/dist/postject.js:9:73645), <anonymous>:8:10)

Additional info

This happens only while trying to embed data into the Node.js binary. This works:

npm init --yes
echo "Hello, world!" > index.js
npx asar pack . app.asar
echo "int main() {}" | gcc -x c -
npx postject ./a.out NODE_JS_CODE app.asar

This fails in https://github.com/postmanlabs/postject/blob/0035c074f43185546dd65a6bffcfe78ccc96382b/src/postject.cpp#L24.

After building with -sASSERTIONS, this is the readable part of the error:

Aborted(Cannot enlarge memory arrays to size 82239488 bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0)
/Users/raisinten/Desktop/temp/project/trash/repro/test/node_modules/postject/dist/postject.js:9
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

RuntimeError: Aborted(Cannot enlarge memory arrays to size 82239488 bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0)
    at abort (/Users/raisinten/Desktop/temp/project/trash/repro/test/node_modules/postject/dist/postject.js:9:17539)
    at abortOnCannotGrowMemory (/Users/raisinten/Desktop/temp/project/trash/repro/test/node_modules/postject/dist/postject.js:9:111870)
    at _emscripten_resize_heap (/Users/raisinten/Desktop/temp/project/trash/repro/test/node_modules/postject/dist/postject.js:9:112336)
    at <anonymous>:wasm-function[3035]:0x290b1c
    at malloc (<anonymous>:wasm-function[3030]:0x28eb99)
    at <anonymous>:wasm-function[3619]:0x2af135
    at <anonymous>:wasm-function[128]:0x1050c
    at <anonymous>:wasm-function[130]:0x1067f
    at <anonymous>:wasm-function[140]:0x1569f
    at Object.getExecutableFormat (eval at new_ (/Users/raisinten/Desktop/temp/project/trash/repro/test/node_modules/postject/dist/postject.js:9:91135), <anonymous>:8:10)
@RaisinTen RaisinTen added the bug 🐛 Something isn't working label Sep 28, 2022
RaisinTen added a commit that referenced this issue Sep 28, 2022
After building Postject with -sASSERTIONS enabled, the error looked like
this:
```
Aborted(Cannot enlarge memory arrays to size 82239488 bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0)
```
so I followed option 2 in this change.

Fixes: #42
Signed-off-by: Darshan Sen <[email protected]>
@RaisinTen
Copy link
Contributor Author

Fix - #45

@RaisinTen RaisinTen self-assigned this Sep 28, 2022
RaisinTen added a commit that referenced this issue Sep 29, 2022
After building Postject with -sASSERTIONS enabled, the error looked like
this:
```
Aborted(Cannot enlarge memory arrays to size 82239488 bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0)
```
so I followed option 2 in this change.

Fixes: #42
Signed-off-by: Darshan Sen <[email protected]>
dsanders11 pushed a commit that referenced this issue Sep 30, 2022
* fix: OOM abort error while injecting data

After building Postject with -sASSERTIONS enabled, the error looked like
this:
```
Aborted(Cannot enlarge memory arrays to size 82239488 bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0)
```
so I followed option 2 in this change.

Fixes: #42
Signed-off-by: Darshan Sen <[email protected]>

* fixup! test: bump test timeout

40000ms is still too for macOS.

Refs: https://app.circleci.com/pipelines/github/postmanlabs/postject/139/workflows/aee3c215-ddc7-4451-aad5-70bfc58dd8c3/jobs/1051/tests
Signed-off-by: Darshan Sen <[email protected]>

* fixup! test: bump test timeout

50000ms is still too low for macOS.

Refs: https://app.circleci.com/pipelines/github/postmanlabs/postject/140/workflows/d653f352-5415-4a83-95b8-c3a52393dc76/jobs/1062/tests
Signed-off-by: Darshan Sen <[email protected]>

* fixup! set INITIAL_MEMORY and MAXIMUM_MEMORY

Resolves a code review comment.

Signed-off-by: Darshan Sen <[email protected]>

Signed-off-by: Darshan Sen <[email protected]>
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 💥
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants