File tree Expand file tree Collapse file tree 2 files changed +31
-15
lines changed
stringbytes-external-exceed-max Expand file tree Collapse file tree 2 files changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,3 @@ prefix addons
33[true] # This section applies to all platforms
44
55[$system==aix]
6- # https://github.com/nodejs/build/issues/1820#issuecomment-505998851
7- # https://github.com/nodejs/node/pull/28469
8- # https://github.com/nodejs/node/pull/28516
9- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js: SKIP
10-
11- # https://github.com/nodejs/node/pull/28516
12- stringbytes-external-exceed-max/test-stringbytes-external-at-max: SKIP
13- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii: SKIP
14- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64: SKIP
15- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary: SKIP
16- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex: SKIP
17- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8: SKIP
18- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2: SKIP
19- stringbytes-external-exceed-max/test-stringbytes-external-exceed-max: SKIP
Original file line number Diff line number Diff line change 22#include < node.h>
33#include < v8.h>
44
5+ #ifdef _AIX
6+ // AIX allows over-allocation, and will SIGKILL when the allocated pages are
7+ // used if there is not enough VM. Check for available space until
8+ // out-of-memory. Don't allow more then some (large) proportion of it to be
9+ // used for the test strings, so Node & V8 have some space for allocations.
10+ #include < signal.h>
11+ #include < sys/vminfo.h>
12+
13+ static void * Allowed (size_t size) {
14+ blkcnt_t allowedBlocks = psdanger (SIGKILL);
15+
16+ if (allowedBlocks < 1 ) {
17+ // Already OOM
18+ return nullptr ;
19+ }
20+ const size_t BYTES_PER_BLOCK = 512 ;
21+ size_t allowed = (allowedBlocks * BYTES_PER_BLOCK * 4 ) / 5 ;
22+ if (size < allowed) {
23+ return malloc (size);
24+ }
25+ return nullptr ;
26+ }
27+ #else
28+ // Other systems also allow over-allocation, but this malloc-and-free approach
29+ // seems to be working for them.
30+ static void * Allowed (size_t size) {
31+ return malloc (size);
32+ }
33+ #endif // _AIX
34+
535void EnsureAllocation (const v8::FunctionCallbackInfo<v8::Value> &args) {
636 v8::Isolate* isolate = args.GetIsolate ();
737 uintptr_t size = args[0 ].As <v8::Integer>()->Value ();
838 v8::Local<v8::Boolean> success;
939
10- void * buffer = malloc (size);
40+ void * buffer = Allowed (size);
1141 if (buffer) {
1242 success = v8::Boolean::New (isolate, true );
1343 free (buffer);
You can’t perform that action at this time.
0 commit comments