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.
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.
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
* 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.
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.
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.
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.
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.
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>
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.
for abstract types.
Abstract types whose get/put/length/etc. implementations allocated fiber
slots could break the VM by invalidating the stack pointer in the
interpreter. This is admittedly a bit unusual but is something most
users would probably expect to work. Debugging this would be a real pain.