Skip to content

Clearer diagnostics, no output after an error, and two UBSan fixes. - #4

Merged
fjtrujy merged 4 commits into
ps2dev:masterfrom
glampert:fix/diagnostics
Oct 20, 2026
Merged

fjtrujy merged 4 commits into
ps2dev:masterfrom
glampert:fix/diagnostics

Conversation

@glampert

Copy link
Copy Markdown

Four small changes, one commit each. This change only affects diagnostics and simple Sanitizer fixes.

1. Errors are now tagged error:, as warnings are tagged warning:. Errors were printed as file(line) : message, so searching a build log for "error:" found nothing, and a failed VU build was easy to miss. Now:
x.vcl(8) : error: Invalid argument (clipw.xyz fA, >>> fA[x] <<< [x ])
Errors without a location read openvcl: error: ....

2. Running out of registers names the variable. The message was only openvcl: Register allocation ran out of registers. It now gives the register type, how many registers .init_vf/.init_vi leave to the allocator, and the first line that uses the variable that couldn't be placed:
x.vcl(9) : error: Register allocation ran out of VI registers (2 available) for iC (ilw.x >>> iC <<<, 2(vi00))
For example, Tyra's stapip_cull_td_vu1, which only SCE vcl compiles, now accurately reports running out of VF registers (31 available) for outputColor3 at its line 171.

3. A failed build writes no output. When tokenizing reported an error, openvcl exited with failure but still wrote the .vsm, minus the bad instruction. The fresh file looked up to date to make, so the next build used it. Now nothing is written once an error has been reported, to a file or to stdout, and an existing output file is left as it was.

4. Two UBSan fixes, found by building with -fsanitize=address,undefined and running the tests and the PS2 examples:

  • Tokenizer's constructor never initialized m_newSyntax. Parser sets it before tokenizing, but the Tokenizer unit tests read it first. It now starts false.
  • The gasp temp-file name computed (getpid() + rand()) << 8 as an int, which overflows. It's now computed unsigned, which gives the same bits and so the same names.

Testing

🤖 Co-authored by Claude Code

glampert and others added 4 commits October 20, 2026 12:32
Errors were printed as `file(line) : message` and warnings as
`file(line) : warning: message`, so searching a build log for "error:"
found nothing, and a failed VU build was easy to miss. Errors now read
`file(line) : error: message`, or `openvcl: error: message` when they
have no location.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Running out of registers printed only `openvcl: Register allocation ran
out of registers`, with no variable, register type or location, so
finding the pressure point meant bisecting the source. The error now
names the register type and how many registers .init_vf/.init_vi leave
to the allocator, and points at the first line that uses the variable
it could not place:

  x.vcl(9) : error: Register allocation ran out of VI registers
    (2 available) for iC (ilw.x >>> iC <<<, 2(vi00))

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When tokenizing reported an error (an invalid operand, say), openvcl
exited with failure but still wrote the .vsm, minus the bad instruction.
The fresh file then looked up to date to make, so the next build used it,
and a VU change could seem not to take effect. Now nothing is written
once an error has been reported, to a file or to stdout, and an existing
output file is left as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Tokenizer's constructor left m_newSyntax uninitialized. Parser always
  sets it before tokenizing, but the Tokenizer unit tests read it first
  (UBSan: "load of value 78, which is not a valid value for type 'bool'").
  It now starts false, the default without -n.
- The gasp temp-file name computed ((getpid() + rand()) << 8) in int,
  which overflows. It is now computed unsigned, which gives the same
  bits, so the same names, without the undefined behaviour.

Found by building with -fsanitize=address,undefined and running the test
suite and the PS2 examples; both reports are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fjtrujy
fjtrujy merged commit 34bada3 into ps2dev:master Oct 20, 2026
5 checks passed
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