Commit 48dc9ea
Check arity before printing a fileref in its special spelling (Covered by dco/Brian_Egge.md)
A "fileref" type applied to one argument is printed as "t@?" and to two
as "t@off". showFileRef (lang/type.C) read targs[0] as soon as the
applied constructor was the "fileref" primitive, and only consulted the
arity afterwards to pick between those spellings. The compiler never
builds a fileref with any other arity, but the binary type decoder
builds a TApp from whatever the buffer says (decodeTApp), and nothing in
the encoding obliges a peer to supply an argument. Indexing the empty
argument vector binds a reference through its null data pointer, and the
show call through it is the null read OSS-Fuzz reports:
https://issues.oss-fuzz.com/issues/550998929 - hobbes::showFileRef
(fuzz-type-decode, null-dereference READ at 0x0)
The harness only calls hobbes::decode, so show() is reached without
leaving the decoder: the record layout validation rejects the
reproducer's record for an offset mismatch, and that diagnostic renders
the record it rejects, member types and all --
decodeRecord -> Record::make -> withResolvedMemoryLayout
-> "Actual/calculated member offset mismatch ... in record:"
-> showRecord -> Variant::show -> showFull -> TApp::show
-> showFileRef -> targs[0]
sizeOf's "Can't determine size of monotype" diagnostic shows the type
the same way. The bug is not confined to those messages, though: a
no-argument fileref decodes successfully, so any later rendering of a
decoded type reaches it, and the RPC layer (ipc/net.C) does render them
-- both sides feed peer-supplied type descriptions through the
typechecker, whose errors print the types involved, and Client::show
prints the decoded result types directly.
Old bug, not a regression: showFileRef is unchanged since the initial
import (f81d016, 2017), so every release carries it. The layout
diagnostics that let a bare decode() trip over it are recent (d45c864),
but the RPC path could always reach it by showing a decoded type. The
sibling special-case printer, Constraint::show, does not share the
defect -- it checks mts.size() before indexing; showFileRef was the only
unguarded one.
The fix: use the special spelling only when the arity fits it -- one or
two arguments -- and otherwise fall through to the generic constructor
form, so a no-argument application prints as "(fileref)". This also
corrects the over-applied case, which used to print "t@" and silently
drop the extra arguments.
TypeInf/ShowToleratesFileRefWithoutArguments drives everything through
hobbes::decode on encoded bytes, the surface the harness and the RPC
layer consume: a no-argument application shows in constructor form, an
over-applied one shows all its arguments, a record shaped like the
reproducer (a variant member carrying the no-argument application, at a
rejected offset) throws cleanly instead of crashing while the rejection
message is built, and the one- and two-argument spellings are unchanged.
It fails with the fix reverted (SIGSEGV). The minimized reproducer joins
the fuzz seed corpus in fuzz/corpus/type-decode/, which
oss-fuzz-build.sh now packages like the other corpora.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Cf5Cv9r1wqa2YcgCWoLC31 parent 3d08bc2 commit 48dc9ea
4 files changed
Lines changed: 71 additions & 2 deletions
File tree
- fuzz
- corpus/type-decode
- lib/hobbes/lang
- test
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
679 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
680 | 682 | | |
681 | 683 | | |
682 | 684 | | |
683 | 685 | | |
684 | | - | |
| 686 | + | |
685 | 687 | | |
686 | 688 | | |
687 | 689 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
414 | 477 | | |
415 | 478 | | |
416 | 479 | | |
| |||
0 commit comments