737 Commits
Author SHA1 Message Date
nabeel-dev21 dc0f243bb9 reject short sourcemap and symbolmap entries in janet_asm1 (#1927) 2026-10-23 18:21:37 -05:00
Calvin Rose cc57cf5bd7 Redo cleanup for too many closures.
With more fuzzing data and closer inspection, seems we were just not
properly balancing scope pops. Handling a NULL pop just hid the issue.
2026-10-23 05:35:41 -05:00
Calvin Rose e98c33b6b6 Handle compiler failure cleanup better.
After adding the "too many closures" error, we tried to pop a NULL scope
during cleanup - this can segfault. Handle bad scope state better during
cleanup.
2026-10-23 05:19:55 -05:00
nabeel-dev21 a2fa318663 reject function env count that disagrees with funcdef in unmarshal (#1925) 2026-10-22 20:49:50 -05:00
nabeel-dev21 3606abc6d7 reject oversized bytecode length in peg unmarshal (#1921)
* reject oversized bytecode length in peg unmarshal

* trim peg unmarshal size check and cover the abstract header
2026-10-19 20:01:47 -05:00
nabeel-dev21 aebd5d71b7 reject negative argument index in peg unmarshal (#1920) 2026-10-17 07:30:45 -05:00
jcates14andjcates 6e4217836a Register streams with the event loop on unmarshal on all Unix backends (#1919)
Streams sent to another thread with ev/thread were only re-registered with the receiving thread's event loop on the poll backend. On kqueue and epoll, waiting on them hung forever, and on epoll closing them raised "No such file or directory".

Co-authored-by: jcates <jcates@>
2026-10-16 21:21:19 -05:00
Calvin Rose b7e32da0aa Formatting. 2026-10-10 13:21:42 -05:00
Calvin Rose af2471cefb peg undefined behavior fixes. 2026-10-10 11:39:05 -05:00
Arthur Chan 8357f71519 OSS-Fuzz: Add new fuzzer targets assembly process (#1913)
Signed-off-by: Arthur SC Chan <arthur.chan@adalogics.com>
2026-10-08 08:01:48 -05:00
Arthur Chan f73474eb2f OSS-Fuzz: Update fuzz_fiber for breakpoint calls (#1912)
Signed-off-by: Arthur SC Chan <arthur.chan@adalogics.com>
2026-10-08 08:01:30 -05:00
Arthur Chan 3bc551a29d OSS-Fuzz: Add new fuzzer targets fiber functions (#1908)
Signed-off-by: Arthur SC Chan <arthur.chan@adalogics.com>
2026-10-07 07:50:34 -05:00
Calvin Rose c495f11f15 Prefer janet_buffer_extra over janet_buffer_ensure. 2026-10-05 22:02:49 -05:00
sogaiuandsogaiu 809355fcf7 Support inttypes in JDN (#1905)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-10-05 21:46:28 -05:00
sogaiuandsogaiu f63cc1df29 More suite inttypes work (#1900)
* Split assert-error into pieces and remove a piece

* Add helpful reminder in comment

* Format hack

* Use underscores to help readability

---------

Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-10-04 08:39:06 -05:00
sogaiuandsogaiu 6e8bb2df15 Modify suite inttypes (#1898)
* Stop using abbreviations

* Put parser tests first

* Fix incorrect code

* Deal with linting

* Change some comments and labels

* Improve test

* Use syntax literals for int/u64 and int/s64

---------

Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-10-03 13:39:30 -05:00
Calvin Rose 0d018921ca Format. 2026-09-30 21:11:32 -05:00
Arthur Chan 3ca0253c10 OSS-Fuzz: Add new fuzzer targets peg processing (#1890)
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-09-29 08:13:29 -05:00
Calvin Rose 65a64a3b72 Add threaded channel memory leak test.
Found by @pepe with Claude. This makes some changes to the initial AI
suggested fix but is mostly verbatim. The memory leak was of the form of
ever increase GC roots with threaded channels.
2026-09-28 18:03:50 -05:00
Calvin Rose cd946c4541 Apply fix for threaded channels "eating" values.
Reported by @pepe with help from Claude.
2026-09-28 17:35:18 -05:00
Calvin Rose ffebf2c497 Add test cases for missing programs with os/spawn and os/execute. 2026-09-28 16:53:09 -05:00
Calvin Rose d2560d538b Add bytecode slot compaction pass.
Codegen may allocate and then never use slots. Free up those slots
and rewrite bytecode to be smaller. The resulting bytecode will be
slightly faster, result in better inlining, and be somewhat normalized
for further optimizations.
2026-09-24 06:19:53 -05:00
Calvin Rose b0acda4fa5 Add bytecode inlining at optimization >= 2.
Currently very simple hueristic, and not supported
on many functions that instatiate closures or load/set upvalues.

We also now, more than ever, need a slot-compaction routine to reduce
the number of slots used by functions.
2026-09-24 06:19:38 -05:00
Calvin Rose 6e79ac9f62 Expose optimization level
This exposes the optimization level for a few reasons.

First, Local value numbering exposed some bad codegen. Playing with
optimiaztion level exposes this more easily.

When compiling dead code in a known unused scope, we
would generate code that tried to load invalid slots.

Make sure that unused code will still pass `janet_verify()` as
invalid code could trigger bad behavior in our optimizer or garbage
collector.

Since the code was proven dead, this would not trigger any runtime
behavior issues though.

Second, even trivial optimizations tend to break debug information. For
example, constant propogation will eliminated symbol mappings which can
be useful for debugging. By default, don't eliminate any symbol map
debug info.
2026-09-19 11:22:33 -05:00
Calvin Rose 0432110572 Improve the constant propogation.
However, we will likely need to gate some of these optimizations
behind a switch as they are beginning to destruct debug info. For
example, local value number maybe should be off by default or at the
very least turned off for named loads.
2026-09-19 11:22:33 -05:00
Calvin Rose 02f0718460 Expose bytecode optimization in the assembler.
Also fix value numbering missing some cases due to bad encoding
routines.
2026-09-19 11:22:32 -05:00
Pietro Cerutti d8be849671 Don't hardcode 127.0.0.1 in tests (#1849)
How about we resolve through the special host name "localhost." instead of assuming that the loopback interface is bound to 127.0.0.1 (which might not be the case, especially in FreeBSD jails)?

See RFC6761 for how "localhost." is treated, especially:

Name resolution APIs and libraries SHOULD recognize localhost
names as special and SHOULD always return the IP loopback address
for address queries and negative responses for all other query
types.  Name resolution APIs SHOULD NOT send queries for
localhost names to their configured caching DNS server(s).
2026-09-13 07:53:42 -05:00
Calvin Rose c8c8afedd2 Reduce spurious error messages in test suite.
Prevent the possibility of closing the server socket
before calling net/accept-loop in net/server by adding
a call to (ev/sleep 0).
2026-09-12 14:11:05 -05:00
Pietro Cerutti 0bfcc9fc97 Fix a couple of imprecisions in the file/ docs (#1848)
* Fix a couple of imprecisions in the file/ docs

The `+` flag to `(file/open)` was incorrectly documented as being for
appending. Instead, this allows to read to files opened with `:w` or
`:a`, and to write to files opened with `:r`. This is the same as the
`+` flag in `fopen(3)`.

The `(file/seek)` function was documented as having both `whence` and
`n` as optional arguments. It also didn't say what the default for `n`
was. Anyway, this doesn't make sense, as a default of `:cur` and `0`
would effectively make `(file/seek f)` a no-op. I also amended a test so
both `(file/seek f :set 0)` and `(file/seek f :set)` are covered and
checked to move to the beginning of the file.

* Remove useless check for argc >= 2

We already determined it is between 2 and 3 with `janet_arity(argc, 2, 3)`.

* Dump args in assertion

* Unroll loop in test

* Differentiate failure messages
2026-09-10 17:12:54 -05:00
Calvin Rose ee5d2cd99c Address #1838
Add testcase for os/shell to test/suite-ev.janet

While we may not want to completely deprecate os/shell, we should at
least try to redirect users to better and safer interfaces like
os/execute.
2026-08-30 10:49:05 -05:00
Calvin Rose 6e04aaaa59 Add test-case for os/shell.
At the very least, add test case for valgrind/sanitizer targets.
2026-08-30 10:41:23 -05:00
Yohanan 710bfd0b2b add tests for nested declarations (#1837) 2026-08-29 18:58:24 -05:00
Calvin Rose cea6dd2261 Handle degnerate range case gracefully. 2026-08-23 13:25:54 -05:00
Calvin Rose d177131c84 Handle empty tuple as lhs in def/var without fatal error.
While an odd construct, this should not cause an abort in the
interpeter. Instead, we should just create no bindings and compile as
normal.
2026-08-23 13:14:47 -05:00
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