Commit Graph
14 Commits
Author SHA1 Message Date
Brad Arant 9f3349b671 Fix a real crash: an uncaught error from inside a custom tag's own
expansion terminated the whole process instead of reporting cleanly

Found while verifying documentation for #[name] vs $[%name] (writing the
new tag-hierarchy section surfaced that my own published example was
factually wrong about which sigil reads a keyword attribute - #[name]
actually reads local->variables, a separate store; $[%name] is the real
keyword sigil, confirmed against Tag::getVariable directly). Referencing
an uninitialized #[name] from inside a custom tag's own template crashed
the process outright (SIGABRT) rather than reporting a normal error -
confirmed via a real gdb backtrace, not guessed:

1. Tag::getVariable's "#[" branch and Tag::assignVariable's "local"/
   "parent" scope branches all dereferenced `local` unconditionally.
   `local` is genuinely NULL at the true top level (jet-2.0.cpp's own
   `new jet::__jet(data, out, global, NULL, NULL)`) and stays NULL through
   any tag that doesn't establish its own local scope (most don't -
   <if>/<while>/<until> are the exception, passing `this` as local via
   their splitTagName constructor path). Added NULL checks with clear
   messages instead of an unconditional dereference.

2. The real root cause of the actual crash observed, though: jet-2.0.cpp's
   own top-level catch(coreutils::Exception) handler unconditionally calls
   data.setCursor(global.errorCursor) to show precise source-line context
   - but global.errorCursor is updated by every Tag's own construction, so
   it can (and, for an error originating inside a custom tag's own
   expanded template - container3 in __dotag.cpp - always does) point
   into a completely different ZString buffer than `data` (the top-level
   script). ZString::setCursor() correctly rejects a cursor outside its
   own buffer by throwing - but that throw happens while the ORIGINAL
   exception is still being handled inside this same catch block, and a
   second exception escaping an active catch block calls std::terminate()
   immediately, regardless of any enclosing try/catch. Confirmed via gdb:
   the abort's own stack showed __cxa_throw called from
   ZString::setCursor, called from the catch block itself.
   Fixed by wrapping the precise-location diagnostics in their own
   try/catch, falling back to just the error text (already printed first)
   plus a note that precise context isn't available, rather than crashing
   the whole process. The error text is the useful part either way - the
   line-context is a bonus only available when the cursor genuinely
   belongs to the top-level buffer.

Verified via a full regression pass (9 real jet-2.0 runs covering custom
tag scoping at 1/2/3 nesting levels, the dump tag tree, <try>/<catch>,
<if>/<else>, and the corrected $[%name] keyword sigil) - all still work,
plus the specific crash reproduction now reports a clean error instead of
aborting.
2026-08-26 09:48:43 -07:00
brad Arant 9a9abab92d fixed scoping for local on for tag. 2024-12-21 20:26:46 -08:00
brad Arant 6d2da98024 major scope work completed. Works well!!! 2024-11-27 09:47:17 -08:00
Brad Arant bd8aa1c089 fixed some bugs. Added resolveContainerParent flag to resolve set container issue not reading local variables appropriately. 2024-11-26 13:32:15 -08:00
Brad Arant e3d788bc92 error reporting now reports accurately to the line. 2024-11-26 11:17:22 -08:00
Brad Arant b0453fe0cb worked on error output just a little. 2024-11-18 16:59:32 -08:00
Brad Arant 5a7f7f2d18 fixed up call tag. Should be complete. 2024-11-18 12:44:41 -08:00
Brad Arant ad48c530a0 Added parent tag pointer throughout call hierarchy.Cleaned up output hierarchy parameter names. 2024-10-30 15:23:13 -07:00
Brad Arant 339c975595 Removed line on output. 2024-09-30 14:23:12 -07:00
brad Arant cc904693ab More work on output and some cleanup of temporary cout messages. 2024-09-26 21:21:21 -07:00
Brad Arant 5a97da3d1c Fixed some Expression and Operand memory issues. 2024-09-26 16:58:55 -07:00
Brad Arant 3db9227adc Finished up whilerow. Added hearder tag. 2024-09-26 10:29:33 -07:00
brad Arant 9977ca188c sql variables work now. 2024-09-25 19:57:51 -07:00
Brad Arant e655173a8f Worked on exception reporting. 2024-09-25 17:15:03 -07:00