-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Description
Version
v16.20.2, v20.17.0, v22.7.0
Platform
Linux ip-10-8-1-229 6.1.0-23-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.99-1 (2024-07-15) x86_64 GNU/Linux
But same on ubuntu and debian 11.
Subsystem
No response
What steps will reproduce the bug?
const bufs = []
let i = 0
while (true) {
++i
bufs.push(Array.from({ length: 10*1024 * 1024 }, () => Math.random().toString()))
// console.log(i)
}
The code just have to reach the OOM point
node --max-old-space-size=32000 --trace-gc index.js
[12808:0x6f27120] 146468 ms: Scavenge 19279.2 (19571.3) -> 19263.9 (19571.3) MB, 50.10 / 0.00 ms (average mu = 0.831, current mu = 0.831) allocation failure;
[12808:0x6f27120] 146787 ms: Scavenge 19317.6 (19610.3) -> 19302.1 (19610.5) MB, 35.85 / 0.00 ms (average mu = 0.831, current mu = 0.831) allocation failure;
Segmentation fault
How often does it reproduce? Is there a required condition?
On Outscale VMs
What is the expected behavior? Why is that the expected behavior?
OOM at max-old-size-space
What do you see instead?
OOM when heap reaches ~20G
Additional information
The code works as expected on my own computer and crashes when max-old-space is reached...
But on cloud VMs (of Outscale) it always runs OOM around 20G.
$ cat /proc/<pid>/limits
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 257180 257180 processes
Max open files 1048576 1048576 files
Max locked memory unlimited unlimited bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 257180 257180 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
I checked ulimits, cgroups (even if cgroups kills a process with oom reaper, it doesn't throws a segfault), found nothing...
I tried to put 50G fixed value on ulimits to see if unlimited hides a low default value and it's the same.
I looked with /proc/sys/vm/overcommit_memory 0,1,2 values and its the same.
I tried to recompile nodejs on the VM.... Same....
I exhausted ChatGPT ideas....
I thought maybe this is a host limit applied on processes of my VM by the cloud provider, so I tried this :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc,char* argv[]){
size_t oneHundredMiB=1024*1048576;
size_t maxMemMiB=25*oneHundredMiB;
void *memPointer = NULL;
do{
if(memPointer != NULL){
printf("Max Tested Memory = %zi\n",maxMemMiB);
memset(memPointer,0,maxMemMiB);
free(memPointer);
}
maxMemMiB+=oneHundredMiB;
memPointer=malloc(maxMemMiB);
}while(memPointer != NULL);
maxMemMiB -= oneHundredMiB;
printf("Max Usable Memory aprox = %zi\n",maxMemMiB);
memPointer = malloc(maxMemMiB);
memset(memPointer,1,maxMemMiB);
sleep(30);
return 0;
}
But this can reach the VM RAM limit (64G or 128G) without any problem.
Same for stress
command....
So I'm running out of ideas...
I hope someone here has a clue about what is happening....
Thank you.