Skip to content

Improve assert() failure output#956

Merged
McDutchie merged 3 commits intoksh93:devfrom
JohnoKing:debugging-aprimoration
Mar 31, 2026
Merged

Improve assert() failure output#956
McDutchie merged 3 commits intoksh93:devfrom
JohnoKing:debugging-aprimoration

Conversation

@JohnoKing
Copy link
Copy Markdown

@JohnoKing JohnoKing commented Mar 30, 2026

Changes:

  • _ast_assertfail(): Use glibc's backtrace() and backtrace_symbols() to produce a backtrace after a failed assertion.
  • nv_endsubscript(): Add an error message prior to calling assert to hopefully make the intermittent crashing bug easier to trace. (I can't trigger it manually at all, so hopefully the next CI crash produces more useful output.)
  • ci.yml: Compile CI builds with CCFLAGS=-Og (-g is required alongside -rdynamic for useful backtraces).

Changes:
- _ast_assertfail(): Use glibc's backtrace() and backtrace_symbols() to
  produce a backtrace after a failed assertion.
  - Compile with -rdynamic or -Wl,-export-dynamic when available.
    Glibc's backtrace_symbols() function will fail to print readable
    function names if this is not included in the linker's flags,
    resulting in significantly worse backtraces.
    (This flag should've been part of ksh93#357,
    but it appears to have been forgotten about/omitted accidentally.)
- nv_endsubscript(): Add an error message prior to calling assert
  to hopefully make the intermittent crashing bug easier to trace
  (I can't trigger it manually at all, so hopefully the next CI
  crash produces more useful output.)
- ci.yml: Compile CI builds with CCFLAGS=-Og and LDFLAGS=-g (required
  alongside -rdynamic for useful backtraces).
Comment thread src/lib/libast/comp/assert.c Outdated
Comment thread .github/workflows/ci.yml
@McDutchie McDutchie merged commit 8d24508 into ksh93:dev Mar 31, 2026
@JohnoKing JohnoKing deleted the debugging-aprimoration branch March 31, 2026 20:39
McDutchie pushed a commit that referenced this pull request Apr 1, 2026
Changes:
- _ast_assertfail(): Use glibc's backtrace() and
  backtrace_symbols() to produce a backtrace after a failed
  assertion.
  - Compile with -rdynamic or -Wl,-export-dynamic when available.
    Glibc's backtrace_symbols() function will fail to print
    readable function names if this is not included in the linker's
    flags, resulting in significantly worse backtraces. (This flag
    should've been part of #357,
    but it appears to have been forgotten about/omitted
    accidentally.)
- nv_endsubscript(): Add an error message prior to calling assert
  to hopefully make the intermittent crashing bug easier to trace
  (I can't trigger it manually at all, so hopefully the next CI
  crash produces more useful output.)
- ci.yml: Compile CI builds with CCFLAGS=-Og and LDFLAGS=-g
  (required alongside -rdynamic for useful backtraces).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants