Skip to content

json_index.ts: readByKey/writeByKey, not read/write (Linux -mm=gc segfault) - #88

Merged
ASDAlexander77 merged 1 commit into
mainfrom
json-index-libc-names
Nov 9, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
json-index-libc-names

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Fixes the alpha121 release failure in Test Default Library (ubuntu-*, -mm=gc): release/compile and debug/compile of json_index.ts printed nothing.

Cause. A program's functions are global symbols, which keeps C-style linking (the ruling from TypeScriptCompiler #793). The test defined function read(value: JsonValue). In a compiled Linux exe that function took the place of libc's read(). libgc calls read() from GC_get_nprocs during GC_init, so the program segfaulted before main:

#0 JsonValue.get ()
#1 read ()
#2 GC_get_nprocs ()
#3 GC_thr_init ()
#4 GC_init ()

The JIT and rc/none/own were not affected. write() is another libc name, so it is renamed too.

Checked with the CI alpha121 ubuntu-26.04 package in WSL: json_index.ts now prints ALL DONE as a compiled exe under gc (release and --di --opt_level=0), rc and none.

Other test functions with libc/libm names: declare_read_write.ts declares libc's read/write on purpose. range_error_caught.ts has remainder (libm), which nothing in the runtime calls, so it is left as is.

🤖 Generated with Claude Code

…fault)

A program's functions are global symbols. On Linux the test's read() took the place of libc's,
which libgc calls from GC_get_nprocs when it starts, so the compiled exe segfaulted under -mm=gc
(release and debug; the JIT was fine).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 684258c into main Nov 9, 2026
2 of 10 checks passed
@ASDAlexander77
ASDAlexander77 deleted the json-index-libc-names branch November 9, 2026 22:22
ASDAlexander77 added a commit that referenced this pull request Nov 9, 2026
The Testing section now shows how to run the tests under one memory model
(tests.ps1 -Model, tests.sh <model>, TSLANG_MM), the first-line markers that
skip a test (// gc only, // not own, // linux only), and that a test function
named like a libc function (read, write) replaces it on Linux, which made a
test segfault under -mm=gc (#88).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant