Commit Graph
5015 Commits
Author SHA1 Message Date
Calvin Rose 7575929fe3 Lead users to os/execute over os/shell for most cases. 2026-08-30 10:54:24 -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
Tw 38c555a6d3 ev: bugfix for free on invalid pointer (#1838)
I encountered this issue with `janet -e '(os/shell "echo")'` on Mac, system malloc lib will complain as follows:

```
janet(42817,0x7ff854547780) malloc: *** error for object 0x60000000b730: pointer being freed was not allocated
janet(42817,0x7ff854547780) malloc: *** set a breakpoint in malloc_error_break to debug
```

So I followed the suggestion and here's the backtrace:

```
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00007ff810cb6883 libsystem_malloc.dylib`malloc_error_break
    frame #1: 0x00007ff810ca76d3 libsystem_malloc.dylib`malloc_vreport + 761
    frame #2: 0x00007ff810caab31 libsystem_malloc.dylib`malloc_report + 151
    frame #3: 0x0000000100025402 janet`janet_ev_default_threaded_callback(return_value=JanetEVGenericMessage @ 0x00007ff7bfefad90) at ev.c:2412:13 [opt]
    frame #4: 0x0000000100024b1f janet`janet_loop1_impl [inlined] janet_ev_handle_selfpipe at ev.c:1643:13 [opt]
    frame #5: 0x0000000100024ac9 janet`janet_loop1_impl(has_timeout=<unavailable>, timeout=0) at ev.c:2028:13 [opt]
    frame #6: 0x0000000100024714 janet`janet_loop1 at ev.c:1588:13 [opt]
    frame #7: 0x00000001000497f5 janet`janet_loop_fiber at ev.c:1609:41 [opt]
    frame #8: 0x00000001000497b3 janet`janet_loop_fiber(fiber=0x0000600002903790) at run.c:150:5 [opt]
    frame #9: 0x0000000100075266 janet`main(argc=<unavailable>, argv=0x00007ff7bfeff210) at shell.c:1284:14 [opt]
    frame #10: 0x00007ff810b1041f dyld`start + 1903
```

Found out that it's actually a missing break in the code which leads to double free.

BTW, I'm thinking that if we can implement a debug allocator to be used in the test, so maybe this kind of bugs can be captured earlier.


Change-Id: I74d324b70b39ddc7d6f509b0382e2be36a6a6964

Signed-off-by: Tw <tw19881113@gmail.com>
2026-08-30 10:26:33 -05:00
Yohanan 710bfd0b2b add tests for nested declarations (#1837) 2026-08-29 18:58:24 -05:00
Calvin Rose 5f702d57f6 Add more sandbox asserts in os/open 2026-08-29 07:50:18 -05:00
Khang Nguyen Duy b534bd11e3 free realpath() result with libc allocator (#1836) 2026-08-29 06:28:35 -05:00
sogaiuandsogaiu 4d91c507c4 Make table/to-struct's docstring less wordy (#1834)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-26 20:07:02 -05:00
Calvin Rose 6e75146a8f Replace janet_malloc(A * X) with array_allocate(A, X) to avoid overflow
on 32 bit systems in some cases.

Since most internal arrays in Janet have 32 bit limits, this is is not
hit in practice on 64 bit systems, except in cases of user input. Apply
a fix more generally to simply avoid the issue by coding "defensively".
Some applications are not strictly needed.
2026-08-26 19:16:07 -05:00
Calvin Rose 9d14e34596 Avoid array underflow in marsh.c 2026-08-26 18:55:02 -05:00
Calvin Rose b5f40c5f73 Add sandboxing for os/setlocale and calls to janet_sandbox_assert in
several other places.

Address oversight of os/rm and os/readlink especially.
2026-08-26 18:27:13 -05:00
sogaiuandsogaiu 71f7e43009 Align local names in merge and merge-into (#1833)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-26 17:15:31 -05:00
sogaiuandsogaiu 5e23c99b0b Improve docstring for struct/with-proto (#1832)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-26 17:14:58 -05:00
sogaiuandsogaiu fbd313976c Improve docstring for table/to-struct (#1831)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-26 17:14:45 -05:00
Calvin Rose cea6dd2261 Handle degnerate range case gracefully. 2026-08-23 13:25:54 -05:00
Calvin Rose 021a17cda1 Fix stack overflow in deeply nested destructuring.
Instead, do a recursion depth check and give a normal compile error.
2026-08-23 13:14:47 -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 5b07408181 Undefined shift (literal 1 should be unsigned) 2026-08-23 13:14:47 -05:00
sogaiuandsogaiu d63d952bc4 Improve docstring for length (#1828)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-23 11:05:24 -05:00
sogaiuandsogaiu 96e07aab36 Improve docstring for last (#1829)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-23 11:05:00 -05:00
sogaiuandsogaiu 4815812827 Improve docstring for loop (#1830)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-23 11:04:49 -05:00
sogaiuandsogaiu 284990a043 Improve docstring for update (#1827)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-22 15:00:40 -05:00
sogaiuandsogaiu 92580fd453 Improve docstring for describe (#1826)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-22 15:00:27 -05:00
sogaiuandsogaiu f545c91581 Improve docstring for interleave (#1825)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-22 15:00:11 -05:00
sogaiuandsogaiu 2c630e0f5c Improve docstrings for sum and friends (#1824)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-21 08:26:26 -05:00
Calvin Rose 91ea14baa2 Update changelog 2026-08-21 08:22:20 -05:00
Calvin Rose 2c3995eb33 Make order of path resolution from JANET_PATH more intuitive.
Also match shell convention, with strict searching from left to right
instead of right to left by default. The _first_ element will be bound
to (dyn *syspath*), not the last.

Potentially breaking change for complicated, custom setups
2026-08-21 07:21:24 -05:00
Calvin Rose f47c7b9dce Remove more extra function stubs from float checking. 2026-08-20 17:27:49 -05:00
Calvin Rose ec48673f7c Revert float interface - #1822
It is superfluous since we have the double interface. Users can manually
cast and be aware they are losing precision.
2026-08-20 17:26:30 -05:00
sogaiuandsogaiu 3251197477 Improve docstrings for keep, map, and mapcat (#1821)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-20 09:39:48 -05:00
sogaiuandsogaiu 83558579ce Improve docstrings for all, some, and count (#1820)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-20 08:48:05 -05:00
sogaiuandsogaiu ef07dc347f Improve docstrings of every? and any? (#1819)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-20 08:47:54 -05:00
sogaiuandsogaiu 36db9988b0 Improve docstrings for reverse and reverse! (#1818)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-19 09:56:20 -05:00
sogaiuandsogaiu f9f7a529b2 Improve docstrings of reduce and friends (#1817)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-19 09:56:07 -05:00
sogaiuandsogaiu 16c6bb5fda Improve docstrings for each and friends (#1816)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-19 09:55:43 -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
sogaiuandsogaiu 59b72ba072 Improve docstrings of filter and friends (#1815)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-18 08:17:16 -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
sogaiuandsogaiu 04b48de8b4 Align find* and index-of details (#1811)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-17 20:24:24 -05:00
Calvin Rose c4b2278602 Update CHANGELOG 2026-08-17 20:21:58 -05:00
Calvin Rose b09aec83a2 Add t-switch to allow easily using libraries as CLI tools.
Rather than needing to create wrapper scripts for utilities, `janet -t
mylib <args...>` can be a simple, if somewhat awkward, alternative for
portable command line tooling. Also use spork/fmt on boot.janet.
2026-08-17 15:43:38 -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
Calvin Rose 073a036b16 Update CHANGELOG.md 2026-08-17 07:57:53 -05:00
sogaiuandsogaiu 3d03d083c7 Improve index-of docstring (#1809)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-17 07:56:24 -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
sogaiuandsogaiu 5229244a1b Improve completeness of *-in docstrings (#1805)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-16 14:12:26 -05:00
sogaiuandsogaiu 5b438d9440 Tweak frequencies and group-by (#1806)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-08-16 14:12:18 -05:00