Commit Graph
703 Commits
Author SHA1 Message Date
Calvin Rose 5fb06039f3 Correct flags in fiber.h and add comments!
Flag collisions was causing some unexpected behavior in some situations.
Removing the source of collisions resolve odd cancelation behavior in
the ev/ module where multiple calls to ev/cancel on the same fiber would
mess with the internal fiber flags and cause bad behavior and the wrong
error message return (but still otherwise behave correctly, so unless
you were parsing the returned error messages, things likely worked).

Also leave comments and test to avoid regressions.
2026-08-18 16:03:46 -05:00
c6f44b9c11 Add tests for partition (#1814)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
Co-authored-by: Calvin Rose <calsrose@gmail.com>
2026-08-18 08:16:20 -05:00
f590dac4f9 Add tests for filter (#1812)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
Co-authored-by: Calvin Rose <calsrose@gmail.com>
2026-08-18 08:15:46 -05:00
sogaiuandsogaiu eb1a7e2b20 Add tests for interpose (#1813)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-18 08:14:47 -05:00
Calvin Rose 65745d0237 Fix some fuzzing bugs and add asserts.
Passing in the wrong number of keyword arguments could be problematic
and cause compialtion issues. Handle that more gracefully and at least
be clean in valgrind.
2026-08-17 11:05:18 -05:00
sogaiuandsogaiu c6ca76044d Add tests for find (#1808)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-17 07:55:40 -05:00
sogaiuandsogaiu 82b2bdc8e2 Add tests for find-index (#1807)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-16 20:49:01 -05:00
0888a6dfb0 Add tests for partition-by (#1795)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
Co-authored-by: Calvin Rose <calsrose@gmail.com>
2026-08-15 12:05:01 -05:00
ffb6648742 Add tests for update (#1796)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
Co-authored-by: Calvin Rose <calsrose@gmail.com>
2026-08-15 12:04:18 -05:00
Calvin Rose 27000deed5 Address #1790 - limit number of automatic parameters.
This also improves the error behavior of malformed automatic parameters
so that the error conditions are better defined. Previously, large
indices like 88888888888888 would actually simply be converted to
symbols and fail later. This change puts strict limitations on this
conversion process - If a symbol is of the form "$<str>" and
(scan-number str) returns non-nil, the result must be a valid index. In
this way, symbols like `$1.1` will result in an immediate macro expansion error
rather than (usually) and unknown binding error.
2026-08-15 11:35:15 -05:00
sogaiuandsogaiu e5e13489c2 Add tests for distinct (#1801)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-15 08:38:43 -05:00
sogaiuandsogaiu 331e8544bc Simplify frequencies implementation (#1793)
* Add tests for frequencies

* Simplify frequencies implementation

---------

Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-08 09:30:20 -05:00
Calvin Rose 8dbe828504 Add casts to u32 before left shifts to address ubsan edge cases.
Common idiom that wasn't always applied, especially in emit.c and
cfuns.c
2026-06-27 14:26:57 -05:00
Arthur Chan 0e0cbc3ab0 OSS-Fuzz: Add fuzzer targets compile process (#1767)
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-06-25 21:13:02 -05:00
Calvin Rose ffb83301c5 Handle bad ev/thread construction better.
We were incorrectly handling bad arguments to create a new thread
resulting in corruption.
2026-06-21 11:46:57 -05:00
Arthur Chan f2f77a4bd5 OSS-Fuzz: Add fuzzer targets dobytes function (#1765)
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-06-18 18:53:11 -05:00
Calvin Rose 0d3635f9f4 Format. 2026-06-10 17:22:22 -05:00
Arthur Chan 8b883d1304 OSS-Fuzz: Add new fuzzer targets unmarshal (#1762)
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-06-10 17:16:37 -05:00
Calvin Rose c6b802b082 Add #1737
Add some test cases and asserts for new pretty printing - we were not
properly handing the case when print formatter was not at the start of
the buffer.

A simple fix is to add a lookback_barrier, which is an index into the
buffer that backtracking print formatter can't go past. This ensures
that, whatever newlines are replace with spaces, we don't mess with any
explicit newlines that should be printed.

Also some tweaks to logic to try an make invariants more obvious and
simplify looping and indexing.
2026-04-03 08:38:12 -05:00
McSinyx 0c512ab128 Increase pretty printing line density (#1733)
* Increase pretty printing line density

* Allow specifying width for multiline pretty format
2026-04-01 18:55:22 -05:00
Calvin Rose 29474b915d Begin work on adding kqueue functionality to filewatch.
kqueue-based filewatch is more limited than inotify, but is still
useful in many cases. Notably absent is any ability to monitor
directories automatically without wasting a lot of file descriptors.
2026-03-25 22:16:30 -05:00
Calvin Rose 6c2f08ef49 Add unit tests for variable shadowing. 2026-03-15 13:34:12 -05:00
Calvin Rose 980999c97b Make test suite not shadow any variables. 2026-03-15 13:14:10 -05:00
Calvin Rose c63c6740d9 First pass at linting binding shadowing.
Prevent redefining bindings by accident. There are
a few cases where we want to allow this, such as the `default` macro, so
we allow a keyword :shadow to be included in the `def` expression to
turn off this lint.

TODO:
* Clean up test suite to remove binding shadowing
* Make sure that we don't get lints with *redef* turned on
* Add positive and negative tests for lint messages.
* Add location of shadowed binding in message
2026-03-15 11:24:07 -05:00
McSinyx b96350f132 Align items in multiline pretty format (%m and %p) (#1721)
Indentation levels are not sufficiently clear for deeply nested
data structures.  Instead, align items in a collection
with its opening bracket, also known as hanging indentation.

To avoid guessing the length of a "short" collection to print it
on one line, items are now always printed on separate lines.
2026-03-05 19:34:05 -06:00
Calvin Rose 7fc12ff167 Use ConnectEx for non-blocking connect on windows when available.
Still fallback to blocking connect with WSAConnect when ConnectEx is not
available or applicable, but ConnectEx is preferred and recommended by
Microsoft.

Also make some changes to our use of OVERLAPPED in various places in the
ev code, replacing all uses with JanetOverlapped. This also let's us
avoid reusing internal fields for OVERLAPPED which may or may not be
used in various places.
2026-03-02 19:39:21 -06:00
Calvin Rose 32d75c9e49 Dup io file descriptors when marshalling closable files.
For unclosable files, no need to dup, but for closable files we can get
a resource leak. Valgrind and similar tools won't catch this but IO will
unexpectedly start going to the wrong descriptor if a file was
transferred to a new thread, closed, and then a new file was created.
2026-03-01 10:39:50 -06:00
Calvin Rose 5fec2aa9df Move some files around code more defensively for mitigation. 2026-02-27 18:19:40 -06:00
BrettandBrett Adams 54fbd7607f Fix GC collecting active fiber during nested janet_continue (#1720)
janet_collect() marks janet_vm.root_fiber but not janet_vm.fiber.
When janet_pcall (or janet_continue) is called from a C function,
the inner fiber becomes janet_vm.fiber while root_fiber still points
to the outer fiber. If GC triggers inside the inner fiber's execution,
the inner fiber is not in any GC root set and can be collected —
including its stack memory — while actively running.

This also affects deeply nested cases: F1 -> C func -> janet_pcall ->
F2 -> C func -> janet_pcall -> F3, where F2 is saved only in a C
stack local (tstate.vm_fiber), invisible to GC.

Fix: in janet_continue_no_check, root the fiber with janet_gcroot
when this is a nested call (root_fiber already set). Each nesting
level roots its own fiber, handling arbitrary depth. Top-level calls
(event loop, REPL) skip the root/unroot entirely since root_fiber
is NULL.

Add test/test-gc-pcall.c: standalone C test covering both single
and deep nesting cases.

Co-authored-by: Brett Adams <brett@bletia-9.local>
2026-02-27 18:13:46 -06:00
Calvin Rose b2c9fc123c Generate JOP_PUT_INDEX in the compiler when possible. 2026-02-17 09:07:01 -06:00
Calvin Rose fa0c039cd3 Add regression test for issue #1714 2026-02-17 07:59:08 -06:00
Calvin Rose c7c3821aa6 Remove extra output from peg test. 2026-02-06 00:23:45 -06:00
Calvin Rose d2685594f9 VERBOSE=1 caused tests to fail as we did more asserts inside the assert.
Thenc checked stderr for messages. Since the helper makes assert write
to stderr, this caused extra cruft in our test output.
2026-02-06 00:17:11 -06:00
Calvin Rose ca5c617fba More tweaks to peg suite for arm32 failures. 2026-02-06 00:04:18 -06:00
Calvin Rose 16b449a137 Print "actual" output on verbose mode for suite-peg 2026-02-05 23:52:28 -06:00
Calvin Rose 2e8dd90a51 Line endings in tests. 2026-02-05 23:38:55 -06:00
Calvin Rose 0194115412 Auto-format janet. 2026-02-05 00:33:52 -06:00
Calvin Rose f33697d6a0 Show accumulation buffer and tagged capture in peg debug rule. 2026-02-04 21:17:08 -06:00
Calvin Rose b2bf70eace Move peg debug output to stderr in line with other internal debug tools.
Also allow disabling color in the debug output.
2026-02-04 18:52:20 -06:00
0xbec163andCopilot 416bba9bd9 Add ??/debug PEG rule (#1710)
* Add debug (short-form ??) PEG rule

* Display capture stack to debug PEG rule

* Revise spec_debug to emit just the rule

* Update to proper indentation

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add a marshal/unmarshal test for ??/debug

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-04 18:44:46 -06:00
Calvin Rose d47f82713b More tweaks for named arity linting.
Handle more edge cases where &named is combined with &opt
2026-01-31 23:57:08 -06:00
Calvin Rose 497e363401 Make sure named argumnets are compiled before destructured params.
This handles an edge-case when combing destructured and named
parameters that produced spurious and confusing compiler lints.
2026-01-31 19:34:26 -06:00
Calvin Rose 8f8382eead Partially address issue #1654 - better linting for named arguments.
While there are still cases that we could improve here, this change will
help in most cases with minimal overhead.
2026-01-31 13:16:02 -06:00
Calvin Rose 0c1585fdfe Preserve tuple type to fix #1709
Macro expansion as done by `macex1` was incorrectly losing the semantic
tuple information inside the `set` form. Since macro expansion is
usually done by the compiler, and `macex1` is mainly used for debugging
and deep transformations inside other macros, this only surfaced with
certain usage of short-fn macro.
2026-01-29 06:52:43 -06:00
Calvin Rose 7366fbed1f Disallow scheduling already modified fibers.
While not strictly needed for correctness, this discourages misuse of
fibers and mixing both coroutine, error handling, and scheduling
purposes.
2026-01-28 10:55:00 -06:00
Calvin Rose 33f5a0b319 Add test case to help address #1705 2026-01-24 12:23:01 -06:00
Calvin Rose 0f285855f0 Address #170 - strchr was not properly checking for 0 byte. 2026-01-23 08:13:15 -06:00
Calvin Rose c43e06672c Address #1700 and move test cases to suite-compile.janet 2026-01-23 08:01:22 -06:00
Calvin Rose 2fabc80151 Address #1699 and improve test case for #1702 2026-01-23 07:46:31 -06:00
Calvin Rose 4dd08a4cde Address #1702 with extra bounds check.
The buffer overflow happened because we were creating many upvalue
slots in the compiler without using them, along with some faulty logic
that used the wrong length to check for the bitmap's bounds.
2026-01-23 07:33:05 -06:00