Commit graph

583 commits

Author SHA1 Message Date
Ben Noordhuis
966dbfc1f9 Fix crash in deserializer on bad regexp 2024-10-18 10:01:34 +02:00
Ben Noordhuis
7be9d99d15 Restrict atom count in deserializer to 1 million
Otherwise it's too easy to tie up too many resources (cpu, memory) by
crafting inputs with a very large atom count (up to 4 billion.)

This may need some finetuning. If the limit proves too restrictive for
very large snapshots, we can make it relative to the size of the input.
2024-10-18 10:01:34 +02:00
Ben Noordhuis
a1d1bce0b7
Fix crash in deserializer (#602)
Check inside the deserializer that const atoms are indeed const, don't
trust the input. The serializer only writes type 0 records for const
atoms but the byte stream may have been corrupted or manipulated.

Overlooked during review of c25aad7 ("Add ability to (de)serialize
symbols")

Found with libfuzzer and it found it _really_ fast. Great tool.
2024-10-17 08:45:04 +02:00
Ben Noordhuis
e4406fa55f
Remove NetBSD CI buildbot (#603)
It's been super flaky due to GHA changes or the vmactions/netbsd-vm@v1
action it depends on, and I'm not invested enough to investigate.

If someone is motivated enough to fix it up, we can bring it back.

Fixes: https://github.com/quickjs-ng/quickjs/issues/600
2024-10-16 23:08:48 +02:00
Ben Noordhuis
857f711e0f
Simplify extract_desc() (#601)
Overlooked in commit 79eee54 from last week.
2024-10-16 21:05:26 +02:00
Richard Davison
afeeebf89e
Expose ctx->function_proto 2024-10-16 20:39:09 +02:00
Ben Noordhuis
36227a5310
Fix cyclic import/export segfault (#568)
Before this commit it segfaulted, now it throws a SyntaxError.
That's still not correct behavior but better than segfaulting.
To be continued.

Includes a small run-test262 fix to handle Windows line endings.

Refs: https://github.com/quickjs-ng/quickjs/issues/567
2024-10-16 10:13:38 +02:00
Saúl Ibarra Corretgé
d9d6939b20 Implement Promise.try 2024-10-15 14:52:40 +02:00
Saúl Ibarra Corretgé
e204fa53a3 Fix CI for setup-alpine
Ref: https://github.com/jirutka/setup-alpine/issues/15
2024-10-15 14:52:40 +02:00
Saúl Ibarra Corretgé
47846c585b Fix definition of minimum_length
It's part of C99 but we require C11 anyway.
2024-10-13 17:50:33 +02:00
Ben Noordhuis
b9be6d4ff2 Run local tests with run-test262 2024-10-10 21:52:34 +02:00
Ben Noordhuis
79eee54b22 Remove obsolete run-test262 style option
We always run the test262 suite in new-style mode.
2024-10-10 21:52:34 +02:00
Ben Noordhuis
3c3c487e11 Build and run run-test262 on Windows
The ulterior motive here is not that I want to increase CI times
further but that I want to repurpose run-test262 for running our
own tests.
2024-10-10 21:52:34 +02:00
Saúl Ibarra Corretgé
364453b3d6
DRY assertion functions in tests 2024-10-10 21:39:12 +02:00
Ben Noordhuis
e145244999
Replace js_mode with is_strict_mode bit field (#590)
Shrinks some structures by one or more bytes and is easier to read.
2024-10-10 19:31:47 +02:00
Ben Noordhuis
681568353c
Enforce buffer length in utf8_encode definition (#589)
Fixes: https://github.com/quickjs-ng/quickjs/issues/464
2024-10-10 18:55:42 +02:00
Saúl Ibarra Corretgé
416dde8458 Remove unused defines in cutils.h 2024-10-10 17:52:39 +02:00
Ben Noordhuis
d79aa871d1
Include <intrin.h> on Windows (#584)
Needed for the definition of _BitScanReverse and _BitScanReverse64.
2024-10-08 22:32:24 +02:00
Saúl Ibarra Corretgé
a51c77efd8
Build all Windows targets when building in CI 2024-10-08 16:58:08 +02:00
satk0
2344d19220 Fix MSVC compilation when atomics experimental feature is not set 2024-10-07 22:34:01 +02:00
satk0
1db8d6cc19 Fix out-of-bound write in libbf 2024-10-07 22:34:01 +02:00
satk0
7491c81153 Don't include pthread on wasi or enscripten 2024-10-07 22:34:01 +02:00
satk0
ba863b1a82 Follow declaration of variables before for loop 2024-10-07 22:34:01 +02:00
satk0
86b1853a21 Improve gcc warning fix 2024-10-07 22:34:01 +02:00
Saúl Ibarra Corretgé
52e0f24048 Fix computed reference on null or undefined 2024-10-07 21:39:59 +02:00
Saúl Ibarra Corretgé
acc0dd9273 Implement proper Symbol.toStringTag for iterators 2024-10-07 21:39:02 +02:00
Ben Noordhuis
9a37c57779
Fix thread-safety issue in quickjs-libc (#578)
`JS_NewClassID(rt, &class_id)` where `class_id` is a global variable
is unsafe when called from multiple threads but that is exactly what
quickjs-libc.c did.

Add a new JS_AddRuntimeFinalizer function that lets quickjs-libc
store the class ids in JSRuntimeState and defer freeing the memory
until the runtime is destroyed. Necessary because object finalizers
such as js_std_file_finalizer need to know the class id and run after
js_std_free_handlers runs.

Fixes: https://github.com/quickjs-ng/quickjs/issues/577
2024-10-07 21:27:38 +02:00
Ben Noordhuis
27715a46bb
Forbid closing stdio from quickjs-libc (#576)
Intrinsically dangerous because it leaves the std{in,out,err} C globals
in an undefined state.
2024-10-07 09:35:09 +02:00
Ben Noordhuis
ddabcf5e93
Run ThreadSanitizer on push to master (#575)
Fixes: https://github.com/quickjs-ng/quickjs/issues/557
2024-10-06 20:17:50 +02:00
Saúl Ibarra Corretgé
4b1a244d3b Run test262-update in a single thread
In order to guarantee the order of the results in the error file.
2024-10-05 12:39:04 +02:00
Saúl Ibarra Corretgé
a0877514b9 fixup! 2024-10-05 12:35:47 +02:00
Saúl Ibarra Corretgé
3dcadf1518 Fix next token parsing after a function definition
Ref: c06c399f4f
Fixes: https://github.com/quickjs-ng/quickjs/issues/572
2024-10-05 12:35:47 +02:00
Richard Davison
5590756b93
Move JS_{Dup,Free}Value and the RT variants from header, reduced duplication 2024-10-04 09:18:12 +02:00
Ben Noordhuis
1eb9608d64
Fix regexp split with zero-length capture group (#566)
The expected result of `"ab".split(/(c)*/)[1]` is `undefined` but
was in fact `"undefined"` due to unintentional stringification.

Fixes: https://github.com/quickjs-ng/quickjs/issues/565
2024-10-01 01:05:01 +02:00
Ben Noordhuis
e1564526ea
Run test262 tests in parallel (#564)
This commit introduces a couple of changes in order to make run-test262
go brr and execute tests in parallel:

- Remove CONFIG_AGENT build option. The disabled version of the build
  was already broken and no one noticed, Remove the define altogether.

- Remove the -C switch. Hard to support in multi-threaded mode.
  I may bring it back some day because it _is_ useful.

- Remove the -r switch. Also hard to support and I never look at
  test262_report.txt anyway so on the chopping block it goes.

- Judicious use of thread-local storage so I don't have to thread
  through state everywhere and embiggen the diff even more.

This is what Real Programmers(TM) do: stay up coding way past midnight
just so the test suite finishes in one minute instead of four.

Fixes: https://github.com/quickjs-ng/quickjs/issues/547
2024-09-30 18:35:35 +02:00
Andrew Johnson
72d4587163
Support printing unicode characters on Windows 2024-09-30 13:30:08 +02:00
Ben Noordhuis
0bf36b98b9
Fix ThreadSanitizer warning in quickjs-libc (#562)
A global function pointer was getting accessed from multiple threads.
Replace it with an atomic integer and an immediate function call.
2024-09-28 22:27:18 +02:00
Ben Noordhuis
6d63b36c0a
Fix printing of slow tests with -T in run-test262 (#563)
It's currently printing them whenever a test takes one millisecond or
longer to complete.

Introduced in commit 7db24cc0da from earlier today, mea culpa.
2024-09-28 22:26:18 +02:00
Ben Noordhuis
7db24cc0da
Add -vv verboser mode switch to run-test262 (#561)
Prints the test name and running time in milliseconds. Supersedes
`-T <ms>` because that switch prints the same info, only for slow
tests.
2024-09-28 14:37:16 +02:00
Ben Noordhuis
4d4dbcf37e
Add -C compact mode switch to run-test262 (#560)
Turns on the reporting mode that is the default on the CI.
2024-09-28 14:01:40 +02:00
Saúl Ibarra Corretgé
d0df61d04a Support the NO_COLOR env variable in the REPL 2024-09-27 19:53:11 +02:00
Ben Noordhuis
348d60985d
Add Iterator.from (#555) 2024-09-27 00:16:50 +02:00
Saúl Ibarra Corretgé
06175d1e0c
Simplify eval_and_print code in REPL
We always use async eval.

Also clean up some console.log usage since we use std.puts all across.
2024-09-26 20:07:24 +02:00
Saúl Ibarra Corretgé
b1dc19c4f7 Add Ctrl-W support for REPL 2024-09-26 09:55:18 +02:00
Ben Noordhuis
9a618ed426
Add Iterator.prototype.toArray (#552)
Churn in test262_errors.txt is due to fixing Iterator inheritance,
necessary to make the prototype method actually callable.
2024-09-25 22:45:02 +02:00
Saúl Ibarra Corretgé
7e82ad80c1 Don't run ci and valgrind for non-code changes when pushing to master 2024-09-25 22:32:25 +02:00
Saúl Ibarra Corretgé
7cfedb0952
New documentation website 2024-09-25 22:21:45 +02:00
Saúl Ibarra Corretgé
946d653c58 Fix clearing screen in REPL with Ctrl-L 2024-09-25 21:14:49 +02:00
Ben Noordhuis
aefdee7b9a
Add Iterator (#548) 2024-09-24 22:07:29 +02:00
Saúl Ibarra Corretgé
2b953a72be Set version to 0.6.1 2024-09-24 19:45:59 +02:00