Skip to content

extern fn with_fs_read_file segfaults in user programs (D30-transitional seam) — std.fs works; CLAUDE.md still recommends the broken idiom #901

Closed

Description

@ehartford

Repro (rc=139, no output, both fn-main and implicit-main)

use std.builtins.print_i64
extern fn with_fs_read_file(path: str) -> str
fn main:
    let text = with_fs_read_file("tiny.txt")
    print_i64(text.len())

with run repro.w → exit 139 (SIGSEGV) before any output. File size is
irrelevant (2-line file). The identical program via the sanctioned route
works:

use std.fs
use std.builtins.print_i64
fn main:
    let text = read_file("tiny.txt")
    print_i64(text.len())

Pre-existing

Reproduces identically on the published with-darwin-aarch64 release
binary — not introduced by the 2026-08-30 reseeds. Likely the #747 str
flip changed str ownership across the extern boundary (the D30 notes
already say post-retirement str in an extern signature is a §16.3e
error; this seam appears to be broken ahead of its formal retirement).

Collateral

CLAUDE.md's tooling section still tells agents to reach the filesystem
via extern fn with_fs_read_file(path: str) -> str /
with_fs_write_file — following the docs produces a segfaulting
program. Until the D30 retirement lands, either fix the seam or update
CLAUDE.md to point at std.fs (read_file/write_file) now.

Workaround used

std.fs read_file/write_file.

Activity

  1. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    CLAUDE.md no longer recommends the broken idiom — the tooling guidance now points at std.fs (read_file/write_file/list_files) with an explicit 'never declare the with_fs_* externs' warning and the #909 caveat. The seam defect itself needs no standalone fix: the with_fs_* internal ABI is scheduled to die entirely with the D30 retirement (#761) — fixing a seam that is being removed is work against the grain. Folding the remaining defect into #761; if D30 slips far enough that the seam's lifetime matters, reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions