Mac x86_64: make installcheck failing some tests
I'm trying to install plv8 with Postgres 14 using make install.
Here is my configuration:
- PostgreSQL 14.1 on x86_64-apple-darwin21.1.0, compiled by Apple clang version 13.0.0 (clang-1300.0.29.3), 64-bit
- v3.1 branch of https://github.com/JerrySievert/plv8
make install looks successful with some below start/end logs (didn't get any errors):
make -f Makefiles/Makefile.macos
Setting up build directory
Downloading gn source
Building gn
ninja: Entering directory `out/'
[194/194] LINK gn
Downloading v8 source
Building v8
Done. Made 164 targets from 89 files in 897ms
ninja: Entering directory `./out.gn'
[1278/1278] LIBTOOL-STATIC obj/libv8_monolith.a
..
..
....
MacOSX12.sdk -I/usr/local/opt/[email protected]/include -I/usr/local/opt/readline/include -DLANG_plcoffee - > plcoffee--3.1.0.sql
sed -e 's/@PLV8_VERSION@/3.1.0/g' plv8.control.common | g++ -E -P -DLANG_plls - > plls.control
sed -e 's/@LANG_NAME@/plls/g' plv8.sql.common | sed -e 's/@PLV8_VERSION@/3.1.0/g' | g++ -E -P -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -I/usr/local/Cellar/icu4c/69.1/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I/usr/local/opt/[email protected]/include -I/usr/local/opt/readline/include -DLANG_plls - > plls--3.1.0.sql
Errors:
make installcheck
/usr/local/lib/postgresql/pgxs/src/makefiles/../../src/test/regress/pg_regress --inputdir=./ --bindir='/usr/local/Cellar/postgresql/14.1_1/bin' --dbname=contrib_regression init-extension plv8 plv8-errors inline json startup_pre startup varparam json_conv jsonb_conv window guc es6 arraybuffer composites currentresource startup_perms bytea find_function_perms memory_limits array_spread reset show dialect bigint procedure
(using postmaster on Unix socket, default port)
============== dropping database "contrib_regression" ==============
DROP DATABASE
============== creating database "contrib_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries ==============
test init-extension ... ok 201 ms
test plv8 ... FAILED 169 ms
test plv8-errors ... ok 87 ms
test inline ... ok 73 ms
test json ... ok 85 ms
test startup_pre ... ok 87 ms
test startup ... ok 172 ms
test varparam ... ok 88 ms
test json_conv ... ok 83 ms
test jsonb_conv ... ok 88 ms
test window ... ok 128 ms
test guc ... ok 80 ms
test es6 ... ok 91 ms
test arraybuffer ... ok 80 ms
test composites ... ok 90 ms
test currentresource ... ok 76 ms
test startup_perms ... ok 96 ms
test bytea ... ok 88 ms
test find_function_perms ... ok 110 ms
test memory_limits ... ok 10346 ms
test array_spread ... FAILED (test process exited with exit code 2) 90247 ms
test reset ... FAILED (test process exited with exit code 2) 14 ms
test show ... FAILED (test process exited with exit code 2) 14 ms
test dialect ... FAILED (test process exited with exit code 2) 14 ms
test bigint ... FAILED (test process exited with exit code 2) 13 ms
test procedure ... FAILED (test process exited with exit code 2) 14 ms
=======================
7 of 26 tests failed.
=======================
Postgres log while running make installcheck
2021-11-30 11:17:17.247 +03 [35070] ERROR: invalid input syntax for type integer: "abc"
2021-11-30 11:17:17.247 +03 [35070] STATEMENT: SELECT text_to_int4('abc');
2021-11-30 11:17:17.256 +03 [35070] ERROR: a column definition list is required for functions returning "record" at character 15
2021-11-30 11:17:17.256 +03 [35070] STATEMENT: SELECT * FROM return_record(1, 'a');
2021-11-30 11:17:17.257 +03 [35070] ERROR: input of anonymous composite types is not implemented
2021-11-30 11:17:17.257 +03 [35070] STATEMENT: SELECT * FROM return_record(1, 'a') AS t(j integer, s text);
2021-11-30 11:17:17.257 +03 [35070] ERROR: input of anonymous composite types is not implemented
2021-11-30 11:17:17.257 +03 [35070] STATEMENT: SELECT * FROM return_record(1, 'a') AS t(x text, y text);
2021-11-30 11:17:17.260 +03 [35070] ERROR: argument must be an object
2021-11-30 11:17:17.260 +03 [35070] CONTEXT: set_of_record_but_non_obj() LINE 2: plv8.return_next( "abc" );
2021-11-30 11:17:17.260 +03 [35070] STATEMENT: SELECT * FROM set_of_record_but_non_obj();
2021-11-30 11:17:17.268 +03 [35070] ERROR: function returning record called in context that cannot accept type record
2021-11-30 11:17:17.268 +03 [35070] STATEMENT: SELECT set_of_unnamed_records();
2021-11-30 11:17:17.269 +03 [35070] ERROR: field name / property name mismatch
2021-11-30 11:17:17.269 +03 [35070] CONTEXT: set_of_unnamed_records() LINE 2: plv8.return_next({"a": 1, "b": 2});
2021-11-30 11:17:17.269 +03 [35070] STATEMENT: SELECT * FROM set_of_unnamed_records() AS x(a int, c int);
2021-11-30 11:17:17.270 +03 [35070] ERROR: value is not an Array
2021-11-30 11:17:17.270 +03 [35070] STATEMENT: SELECT bogus_return_type();
2021-11-30 11:17:17.274 +03 [35070] ERROR: NULL element, or multi-dimension array not allowed in external array type
2021-11-30 11:17:17.274 +03 [35070] STATEMENT: SELECT fastsum(ARRAY[NULL, 2]);
2021-11-30 11:17:17.275 +03 [35070] WARNING: warning
2021-11-30 11:17:17.275 +03 [35070] ERROR: FATAL is not allowed
2021-11-30 11:17:17.275 +03 [35070] CONTEXT: test_elog() LINE 9: plv8.elog(21, 'FATAL is not allowed');
2021-11-30 11:17:17.275 +03 [35070] STATEMENT: SELECT test_elog('ABC');
2021-11-30 11:17:17.295 +03 [35070] ERROR: SyntaxError: Invalid or unexpected token
2021-11-30 11:17:17.295 +03 [35070] CONTEXT: syntax_error() LINE 1: @
2021-11-30 11:17:17.295 +03 [35070] STATEMENT: CREATE FUNCTION syntax_error() RETURNS text AS '@' LANGUAGE plv8;
2021-11-30 11:17:17.296 +03 [35070] ERROR: ReferenceError: not_defined is not defined
2021-11-30 11:17:17.296 +03 [35070] CONTEXT: reference_error() LINE 1: not_defined
2021-11-30 11:17:17.296 +03 [35070] STATEMENT: SELECT reference_error();
2021-11-30 11:17:17.297 +03 [35070] ERROR: an error
2021-11-30 11:17:17.297 +03 [35070] CONTEXT: throw() LINE 1: throw new Error("an error");
2021-11-30 11:17:17.297 +03 [35070] STATEMENT: SELECT throw();
2021-11-30 11:17:17.300 +03 [35070] WARNING: Error: plan expected -1 argument(s), given is 0
2021-11-30 11:17:17.300 +03 [35070] WARNING: Error: cannot find cursor
2021-11-30 11:17:17.303 +03 [35070] ERROR: javascript function is not found for "sqlf"
2021-11-30 11:17:17.303 +03 [35070] CONTEXT: caller() LINE 8: func = plv8.find_function("sqlf");
2021-11-30 11:17:17.303 +03 [35070] STATEMENT: SELECT caller(10, 3);
2021-11-30 11:17:17.303 +03 [35070] ERROR: function "callee(int, int)" does not exist
2021-11-30 11:17:17.303 +03 [35070] CONTEXT: caller() LINE 10: func = plv8.find_function("callee(int, int)");
2021-11-30 11:17:17.303 +03 [35070] STATEMENT: SELECT caller(10, 4);
2021-11-30 11:17:17.307 +03 [35070] ERROR: relation "t" does not exist at character 28
2021-11-30 11:17:17.307 +03 [35070] STATEMENT: SELECT f_attdrop(t.*) FROM t;
2021-11-30 11:17:17.426 +03 [35084] ERROR: syntax error at or near "ERROR"
2021-11-30 11:17:17.426 +03 [35084] CONTEXT: test_sql_error() LINE 1: plv8.execute("ERROR")
2021-11-30 11:17:17.426 +03 [35084] STATEMENT: SELECT test_sql_error();
2021-11-30 11:17:17.437 +03 [35084] ERROR: division by zero
2021-11-30 11:17:17.437 +03 [35084] CONTEXT: test_subtransaction_throw() LINE 2: plv8.subtransaction(function(){
2021-11-30 11:17:17.437 +03 [35084] STATEMENT: SELECT test_subtransaction_throw();
2021-11-30 11:17:17.441 +03 [35084] ERROR: custom exception
2021-11-30 11:17:17.441 +03 [35084] CONTEXT: catch_elog_error2() LINE 5: throw 'custom exception';
2021-11-30 11:17:17.441 +03 [35084] STATEMENT: SELECT catch_elog_error2();
2021-11-30 11:17:17.520 +03 [35088] ERROR: return_next called in context that cannot accept a set
2021-11-30 11:17:17.520 +03 [35088] CONTEXT: undefined() LINE 1: plv8.return_next(new Object());
2021-11-30 11:17:17.520 +03 [35088] STATEMENT: DO $$ plv8.return_next(new Object());$$ LANGUAGE plv8;
2021-11-30 11:17:17.781 +03 [35100] WARNING: failed to find js function function "foo" does not exist
2021-11-30 11:17:17.782 +03 [35100] ERROR: ReferenceError: foo is not defined
2021-11-30 11:17:17.782 +03 [35100] CONTEXT: undefined() LINE 1: plv8.elog(NOTICE, 'foo = ' + foo)
2021-11-30 11:17:17.782 +03 [35100] STATEMENT: do $$ plv8.elog(NOTICE, 'foo = ' + foo) $$ language plv8;
2021-11-30 11:17:17.874 +03 [35101] ERROR: ReferenceError: foo is not defined
2021-11-30 11:17:17.874 +03 [35101] CONTEXT: undefined() LINE 1: plv8.elog(NOTICE, 'foo = ' + foo)
2021-11-30 11:17:17.874 +03 [35101] STATEMENT: do $$ plv8.elog(NOTICE, 'foo = ' + foo) $$ language plv8;
2021-11-30 11:17:18.257 +03 [35117] ERROR: window local memory overflow
2021-11-30 11:17:18.257 +03 [35117] CONTEXT: bad_alloc() LINE 5: winobj.set_partition_local(context);
2021-11-30 11:17:18.257 +03 [35117] STATEMENT: SELECT bad_alloc('5') OVER ();
2021-11-30 11:17:18.257 +03 [35117] ERROR: window local memory overflow
2021-11-30 11:17:18.257 +03 [35117] CONTEXT: bad_alloc() LINE 5: winobj.set_partition_local(context);
2021-11-30 11:17:18.257 +03 [35117] STATEMENT: SELECT bad_alloc('not a number') OVER ();
2021-11-30 11:17:18.259 +03 [35117] ERROR: get_window_object called in wrong context
2021-11-30 11:17:18.259 +03 [35117] CONTEXT: non_window() LINE 2: var winobj = plv8.get_window_object();
2021-11-30 11:17:18.259 +03 [35117] STATEMENT: SELECT non_window();
2021-11-30 11:17:18.792 +03 [35141] WARNING: failed to find js function start
2021-11-30 11:17:18.988 +03 [35149] WARNING: failed to find or no permission for js function perm
2021-11-30 11:17:18.989 +03 [35149] WARNING: failed to find or no permission for js function perm()
2021-11-30 11:17:19.178 +03 [35153] ERROR: RangeError: Array buffer allocation failed
2021-11-30 11:17:19.178 +03 [35153] CONTEXT: undefined() LINE 3: const a = new ArrayBuffer(limit*1024*1024);
2021-11-30 11:17:19.178 +03 [35153] STATEMENT: do $$
const limit = plv8.execute(`select setting from pg_settings where name = $1`, ['plv8.memory_limit'])[0].setting;
const a = new ArrayBuffer(limit*1024*1024);
$$ language plv8;
2021-11-30 11:17:29.085 +03 [35153] ERROR: RangeError: Array buffer allocation failed
2021-11-30 11:17:29.085 +03 [35153] CONTEXT: undefined() LINE 6: s.push(new ArrayBuffer(63)) // small non-aligned allocations
2021-11-30 11:17:29.085 +03 [35153] STATEMENT: do $$
const limit = plv8.execute(`select setting from pg_settings where name = $1`, ['plv8.memory_limit'])[0].setting;
const a = new ArrayBuffer(limit*1024*1024/1.5);
const s = [];
while(true) {
s.push(new ArrayBuffer(63)) // small non-aligned allocations
}
$$ language plv8;
libc++abi: terminating with uncaught exception of type js_error
2021-11-30 11:18:58.667 +03 [31097] LOG: server process (PID 35158) was terminated by signal 6: Abort trap: 6
2021-11-30 11:18:58.667 +03 [31097] DETAIL: Failed process was running: do $$
Object.prototype[Symbol.iterator] = function() {
return {
next:() => this
}
};
[...({})];
$$ language plv8;
Sometimes re-running make installcheck passes a few of the last tests (without doing any changes)
test array_spread ... FAILED (test process exited with exit code 2) 89570 ms
test reset ... FAILED (test process exited with exit code 2) 20 ms
test show ... FAILED (test process exited with exit code 2) 15 ms
test dialect ... FAILED (test process exited with exit code 2) 18 ms
test bigint ... FAILED (test process exited with exit code 2) 15 ms
test procedure ... ok 104 ms
=======================
6 of 26 tests failed.
and
test memory_limits ... ok 10060 ms
test array_spread ... FAILED (test process exited with exit code 2) 87521 ms
test reset ... FAILED (test process exited with exit code 2) 16 ms
test show ... FAILED (test process exited with exit code 2) 17 ms
test dialect ... ok 278 ms
test bigint ... ok 67 ms
test procedure ... ok 77 ms
=======================
4 of 26 tests failed.
=======================
hello! Not sure what's happening, but, I just tried creating a plv8 extension and it seems successful. Does i take it as a success or something is wrong here?
myuser-MacBook-Pro:dir/plv8-3.1> psql postgres
psql (14.1)
Type "help" for help.
postgres=# CREATE EXTENSION plv8;
CREATE EXTENSION
postgres=# DO $$ plv8.elog(NOTICE, "hello there!"); $$ LANGUAGE plv8;
NOTICE: hello there!
DO
postgres=#
I have not yet finished getting all tests to pass (hence have not opened a PR against the main repo and released it). specifically, the array_spread test is failing, which is causes the next few to fail while pg recovers.
it should be very stable, except for the issue that array_spread is meant to mitigate.
@pkit do you have any insight on why array_spread may fail on newer v8? you added the original test and mitigation.
@JerrySievert @hmarzooq unfortunately the last tests may hard crash v8 or leave it in an unusable state (if it has these vulnerabilities). Which means that the following tests may crash too (isolating each test was a much harder task). So the first fail is usually the correct one, and all others are just repercussions. Anyway, I do have M1 and x64 macs right now, will test it. Unfortunately I'm too busy with fundraising/execution right now, so it may take a while.
@hmarzooq I do have an idea though, make sure that you are really running make installcheck using the newly compiled plv8 extension. Knowing how, err... screwed the usual paths on macs are, it may happen that you have make install-ed the extension not where the make installcheck runs....
@pkit I have m1/x64 and arm64 servers sitting around, which has been good, and yes, it's the one test failure that cascades into the others due to waiting for Postgres to come back up.
I was mostly curious as I was having difficulty finding your mitigations. I thought it had been in the memory allocator, but couldn't find exactly what I was looking for (and haven't had the time to continue myself).
3.1 has been released, this should now all be working.