Skip to content

param_cnt: fix segfault on missing transcript source; guard corpus dir setters - #68

Merged
lenzo-ka merged 1 commit into
masterfrom
kal-param-cnt-sentdir-crash
Aug 16, 2026
Merged

param_cnt: fix segfault on missing transcript source; guard corpus dir setters#68
lenzo-ka merged 1 commit into
masterfrom
kal-param-cnt-sentdir-crash

Conversation

@lenzo-ka

Copy link
Copy Markdown
Contributor

Fixes #67.

param_cnt segfaulted whenever -lsnfn was omitted: it read -sentdir /
-sentext, which it never registered, so cmd_ln_str() returned NULL and
corpus_set_sent_dir() dereferenced it in strrchr(dir, ',') — crashing before
the control file was opened. This is a hard crash, separate from the
silent-failure work in #65/#66.

What changes

  • Register -sentdir / -sentext in param_cnt's argument table, matching
    agg_seg and bw. This restores the per-utterance sent-directory transcript
    path that the code already tried to use.
  • Require a transcript source in initialize(): -lsnfn, else -sentdir
    (with -sentext), else a named error — instead of passing a null directory
    onward.
  • Null-guard corpus_set_sent_dir() and corpus_set_seg_dir() so a null
    directory returns S3_ERROR rather than dereferencing null. These are shared
    libio setters, so the guard protects every caller, not just param_cnt.

Verification

Builds clean (no new warnings). Before: param_cnt -paramtype phone -ctlfn …
without -lsnfn exits 139 (SIGSEGV). After: it prints You must specify a word transcript source: -lsnfn, or -sentdir with -sentext and exits 1. Supplying
-lsnfn is unchanged; supplying -sentdir now reaches corpus_set_sent_dir()
with a real path.

Relationship to #66: independent. #66 (issue #65) makes -segdir required only
for state/cb counting; this PR fixes the transcript-source crash and hardens
the shared corpus setters. The two touch adjacent lines in initialize() and
may need a trivial merge resolution depending on merge order.

…r setters

param_cnt read -sentdir/-sentext without registering them, so omitting -lsnfn
passed a null directory into corpus_set_sent_dir(), which dereferenced it in
strrchr() and crashed before the control file was even opened.

- Register -sentdir/-sentext in param_cnt's argument table (as agg_seg and bw
  already do), restoring the per-utterance sent-directory transcript path.
- Require a transcript source in initialize(): -lsnfn, else -sentdir/-sentext,
  else a named error instead of passing a null directory onward.
- Null-guard corpus_set_sent_dir() and corpus_set_seg_dir() so a null directory
  returns an error rather than dereferencing null, defending every caller.

Fixes #67.
@lenzo-ka
lenzo-ka force-pushed the kal-param-cnt-sentdir-crash branch from c883b2c to 8f56df6 Compare August 16, 2026 23:16
@lenzo-ka
lenzo-ka merged commit cffd8fd into master Aug 16, 2026
7 of 8 checks passed
@lenzo-ka
lenzo-ka deleted the kal-param-cnt-sentdir-crash branch August 17, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

param_cnt segfaults on a null directory (unregistered -sentdir/-sentext) when -lsnfn is omitted

1 participant