File tree 2 files changed +31
-15
lines changed
stringbytes-external-exceed-max
2 files changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,3 @@ prefix addons
3
3
[true] # This section applies to all platforms
4
4
5
5
[$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 2
2
#include < node.h>
3
3
#include < v8.h>
4
4
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
+
5
35
void EnsureAllocation (const v8::FunctionCallbackInfo<v8::Value> &args) {
6
36
v8::Isolate* isolate = args.GetIsolate ();
7
37
uintptr_t size = args[0 ]->IntegerValue ();
8
38
v8::Local<v8::Boolean > success;
9
39
10
- void * buffer = malloc (size);
40
+ void * buffer = Allowed (size);
11
41
if (buffer) {
12
42
success = v8::Boolean::New (isolate, true );
13
43
free (buffer);
You can’t perform that action at this time.
0 commit comments