1
0
mirror of https://github.com/janet-lang/janet synced 2026-05-11 07:52:17 +00:00

4925 Commits

Author SHA1 Message Date
Calvin Rose bef6cb5d74 Address issue #1746
This will have the side effect of breaking loading image dicts from
older Janet versions with these contents.
2026-05-08 18:42:50 -05:00
jsks 27807d4456 Fix mmap return value check (#1745) 2026-05-01 17:49:49 -05:00
Calvin Rose d9b1d711ea Add fix for #1744
Usually, we try to pre-allocate a few extra stack values for
convenience, but we don't actually need to. Avoid a buffer overflow in
the case where this "extra" was causing us to go over INT32_MAX.
2026-04-26 13:23:03 -05:00
Calvin Rose ed17dd2c59 Add runtime checks for bug #1743
This also expands janet_verify to check slotmapping (debuginfo) in
function definitions.
2026-04-26 08:53:06 -05:00
Calvin Rose fcf3186c7d Add missing offset to temp registers. 2026-04-23 05:20:14 -05:00
Calvin Rose e118f57220 Add conservative checks large registers in emit.c
We make some assumptions about the index range of slots in emit.c that
is not tracked by the C type system, so add some asserts and conversions
to be safe.
2026-04-22 20:01:18 -05:00
sarna 5b5844b469 Try to use clearer language in buffer docs (#1738)
* Clarify buffer limits in docs

* Wording
2026-04-20 08:31:55 -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
Calvin Rose a261a8f6b4 Update CHANGELOG.md 2026-04-02 23:22:18 -05:00
Calvin Rose 2d1b54da37 Add more printing cases to pp_runner fuzz harness. 2026-04-01 19:02:51 -05:00
Calvin Rose 9a9cf981ed Add some afl stubs. 2026-04-01 18:58:14 -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 19e1dc494d Mitigation against mutated repl history. 2026-03-28 18:22:25 -05:00
Calvin Rose c67dee7329 strncpy mitigations in mainclient.c 2026-03-28 09:47:46 -05:00
Calvin Rose 16f4f40d8e Update CHANGELOG 2026-03-27 11:34:50 -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 ec5a78d3dc Add pointer shift option for more nanboxing on arm64.
We now try to detect this and do it by default. This is important
as arm64 becomes more common and dominant.
2026-03-23 13:57:43 -05:00
Calvin Rose e42b3c667f Reduce maximum size of parse number to something more manageable.
Parsing large number can have non-linear runtime behavior, and is
messing with our fuzzing.
2026-03-18 17:09:12 -05:00
Calvin Rose 93436bf973 Weaken variable shadowing to a "strict" lint.
Only get compiler lints/errors in strict mode. Also distinguish between
different kinds of shadowing for slightly different warnings and
lint-levels that better align with idiomatic code.
2026-03-17 20:28:16 -05:00
Calvin Rose df32109eea Small typo fixes in comments. 2026-03-15 20:22:20 -05:00
Calvin Rose 8b89901298 Deduplicate lints.
Why see the same message twice?
2026-03-15 18:27:13 -05:00
Calvin Rose 079776d39e Elaborate comment. 2026-03-15 15:34:52 -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 1197cfe433 Check redef only once per compile call. 2026-03-15 12:56: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
Calvin Rose 612971503d Add LLM, AI and tool usage section to contribution guide. (#1730)
* Add LLM, AI and tool usage section to contribution guide.

* Word order and punctuation.

* Add suggestions.

- No bot PRs
- Define "Large" code contribution

Also try to disuade users from using AI for one-line or simple changes, instead
preferring to treat that as "feedback" and rewrite instead.

* Remove wiggle room for any AI code in the Janet runtime.

Still leave open the possibity for AI / tool usage for static analysis
and bug repots. However, the 5-15 lines of code limitation is fuzzy and
arbitrary. We can just say no.

* Remove word.
2026-03-14 23:13:29 -05:00
PinieP df56efbae0 Fix: add missing :symbolmap keyword to disasm function (#1729) 2026-03-12 19:25:51 -05:00
sogaiu b160f4f5c0 Macro hygiene tweaks (#1727)
* Tweak hygiene for when-with, if-with, when-let

* Tweak hygiene for loop1 helper

* Tweak hygiene for repeat

* Tweak hygiene for seq and catseq

* Tweak hygiene for -?> and -?>>

* Tweak hygiene for varfn

* Tweak hygiene for ev/with-deadline

* Tweak hygiene for ffi/defbind-alias + ffi/defbind

---------

Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-03-11 19:06:43 -05:00
Calvin Rose a0cc867f14 Improve macro hygiene in boot.janet. 2026-03-09 19:46:55 -05:00
Calvin Rose 8f446736ed Fix #1723 - handle prompt longer than terminal is wide.
When this happened, we tried to print a buffer with a negative length
that resulted in invalid memmove call. This fix both checks that we
don't tried to append a negative buffer, and truncates a prompt that is
too long for the termimal so that one can still enter text with at least
16 visible characters for data entry.
2026-03-07 15:28:59 -06:00
PinieP decd7078af fix janet_make_threaded to return threaded channel (#1724)
janet_make_threaded previously created a channel with threaded set to 0
2026-03-07 15:01:03 -06: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 aa63adccb4 Update CHANGELOG.md 2026-03-02 19:39:21 -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 39f8cf207c Cast for warning on mingw DWORD printing. 2026-03-01 12:24:03 -06:00
Calvin Rose 95f2e233c5 Try io.h on windows 2026-03-01 12:20:15 -06:00
Calvin Rose e8f9c12935 Fix regression where private main was not run. 2026-03-01 10:52:52 -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
Brett 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
sogaiu 019829fdf9 Tweak a docstring and a comment (#1718)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-02-25 17:51:54 -06:00
Calvin Rose 2602bec017 Check stderr for redirection before turning on/off color. 2026-02-21 08:17:12 -06:00
Calvin Rose 403b2c704a Add sanitizer test to github actions and sr.ht builds.
This will run both clang and gcc sanitizers as part of ordinary testing.
2026-02-20 18:08:09 -06:00
Calvin Rose ca9ffaa5bb Avoid memory leak when canceling fibers with threaded channels.
Objects in channels are sent as messages that need to be freed by the
consumer. However, in certain cases, no consumer is available and the
messages were being discarded without properly being freed. This should
also fix `-fsanitize=address` on GCC and CLANG with the default test
suite.
2026-02-20 14:47:00 -06:00
Calvin Rose e61194a8d9 Remove older extra channel unlocks. 2026-02-20 08:17:25 -06:00
Calvin Rose 08e4030487 Add builders for issue #1716 2026-02-20 08:00:36 -06:00
Calvin Rose 56b5998553 Suspicious locking behavior with select.
This looks like it could cause deadlocks with threaded channels
(normal channels are unaffected, locking/unlocking is a no-op).
2026-02-20 07:35:18 -06:00
R Fisher ea997d585b fix multicast on illumos (#1717)
illumos, like BSD, expects IP_MULTICAST_TTL to be
an unsigned char
2026-02-20 07:30:30 -06:00
Calvin Rose fc725e2511 Prepare for next patch release. 2026-02-18 08:46:17 -06:00