Repository navigation
fix(libSceFont): accept overlapping render surface rows - #8250
oneandonlydean merged 4 commits into
Conversation
3289ac8 to
1d20721
Compare
|
Thank you. Rebased #8250 on main and resolved the documentation conflict. All seven focused Font tests pass with zero skips; the full Windows library/relinker build and negative control also pass. A fresh Astra high review found no issues. The branch is ready for full upstream CI. |
|
@vittoriosalvadore #9992 has just merged, and it changes one case your test checks. On main, a render surface with a zero width or height (and a nonnegative stride) now returns SCE_FONT_OK and leaves the buffer untouched, because a title renders a glyph into a zero-extent surface to measure it. Your new FontRenderSurface.cpp:128 still expects NO_SUPPORT_SURFACE for the height-0 surface, so font_render_surface aborts there once this branch includes main. Could you merge main and change that height-0 row to expect SCE_FONT_OK with the pixels untouched? The stride check this PR adds is unaffected; it only applies to surfaces with positive width and height. There is also a small conflict at the top of docs/dev/debt/libSceFont.md where both PRs add a bullet; keeping both is right. |
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 522e32e and core/libs/prx/libSceFont/src/Layout.cpp / Render.cpp on main:
- Besides the debt-file conflict and the #9992 test row already mentioned, Render.cpp merges cleanly, and the stride guard's early returns (width/height <= 0, stride <= 0) agree with main's zero-extent rule.
- A question on the premise: the API doesn't pass a buffer size, and main writes at
buffer + row*widthByte + column*bpp, clipped to width/height (Layout.cpp:164-188). With height 1, width 80 and stride 16, main only touches bytes 0-79, which is in bounds for an 80-byte buffer, yet this PR throws. With more rows, a short stride makes rows overlap but stays within(h-1)*stride + w*bpp. The "wrote beyond buffer" result comes from the test treating the buffer asstride*height. Could the description and debt entry describe this as a guard for an unverified case rather than an overflow fix? Has any title been seen passing such a surface? - Small one: in
sceFontRenderCharGlyphImagethe guard now runs before the style-frame/baseline errors (preRc), so that error code is replaced by a throw when both conditions hold.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
|
@vittoriosalvadore @harisibrar1 I agree that our earlier overflow claim was too broad. The API has no allocation length; a short stride can overlap rows while staying inside an allocation covering (height - 1) * stride + width * bytesPerPixel. The existing negative control demonstrates an overrun of the test’s stride-times-height allocation, not every possible caller allocation. Please describe this as a conservative guard for an unverified surface layout, and separate the measured test result from the assumed allocation convention. I still need the guard to preserve earlier error precedence: sceFontRenderCharGlyphImage currently throws before style-frame/baseline preRc failures are checked. Please retain those errors, add a mixed-invalid regression and ensure locks are released on a throw. The rebase/debt conflict and zero-height fixture update after #9992 also remain open. I’m changing the prior overall PASS to CHANGES until these are addressed. |
|
Data for the open question about the surface layout. I ran firmware 13.42's
So 13.42's module treats a short stride as a valid surface: the rows overlap, nothing is refused, and the writes stay in the (height − 1) × stride + width × pixel size extent. On that evidence, the throw guards a case the module accepts and draws, not one it rejects. For the error-order point, these surfaces got no stride error from the module, so there was none to order against the style-frame/baseline errors. |
|
Thanks @BunnyFl, that settles the layout question. @vittoriosalvadore, on 13.42 a stride shorter than width × pixel size is a valid surface: the module draws with overlapping rows and its writes stay within (height − 1) × stride + width × pixel size. So instead of throwing for a short stride, please accept it and bound the writes to that extent, with a test that checks the overlapping-row result against BunnyFl's numbers. A negative stride would write before the buffer, so it can stay an explicit refusal noted in the debt entry. That also removes the error-order question. The zero-height expectation after #9992 is still open. |
|
@vittoriosalvadore this branch now conflicts with The reason is a behaviour change on Could you merge |
|
Thank you for the measurements and review. #8250 now accepts short/zero strides, preserves earlier errors and covers zero extents. All 17 focused Windows tests pass with zero skips, and the full library/relinker build passes. The four-byte raster gap is documented. @oneandonlydean Could you run full Linux/Windows CI ( |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
What
Accept a zero row stride and preserve short positive strides in Font character rendering. Rows may overlap: for positive dimensions their address range is
(height - 1) * stride + width * pixelSize, rather thanheight * stride. An allocation covering that range is sufficient; the API has no allocation length to validate the caller's actual storage. Clipping by surface dimensions and scissor keeps raster writes inside it.Remove the earlier short-stride rejection and keep main's style-frame/baseline error precedence. Zero width or height retains main's successful metrics-only result, an empty update rectangle and no pixel writes. Negative strides still return
SCE_FONT_ERROR_NO_SUPPORT_SURFACE; the difference from the measured module is explicit in technical debt.Source: BunnyFl's native x86-64 execution of firmware 13.42 Font/FontFt modules and the collaborator's requested correction. This is a published firmware-module harness result, not our own measurement or a console-hardware run. The reported four-byte surface metadata with one-byte coverage writes remains an unresolved format difference; this patch preserves the existing host four-byte raster and records that gap.
Tested
Windows x86-64, WinLibs GCC 15.2.0 r7 (UCRT/POSIX), CMake 4.3.1 and Ninja 1.13.2; root Release configuration, BUILD_TESTING=ON, relinker-only OFF, system dependencies OFF, pinned bundled submodules. Final head
6b6a14635c38229ac220ea51a2b2b7a8d96458c8, based on mainf7f03daf52f11191174b1be089a56e268390a707.cmake --build build --parallel 3 --target libs relinker, plus all focused Font test targets.ctest --test-dir build -R '^(font_render_surface|guest_font.*|guest_system_font|font_face_lifetime.*|guest_freetype)$' -V --timeout 30 --parallel 2.0x80460050. Negative control 2: reinsert only the old early stride guards into the current Render.cpp. It fails in the mixed-invalid style-frame case by throwing instead of retaining the earlier error. Restore committed production sources, rebuild and rerun all 17: pass, zero skips. The production baseline used for these controls is byte-identical in the final main snapshot.gpt-6-astra, reasoning high) final review completed before push.The regression uses an asymmetric generated TrueType glyph with the real Font/FontFt/FreeType libraries. It compares the complete buffer with a wide-stride reference projected into overlapping rows in drawing order, including zero coverage inside the update rectangle. Guards surround the declared extent. Coverage includes all three character-rendering exports; strides 0, 1, 16, 64, 130, exact, padded and row-size-minus-one; one- and four-byte host pixels; scissor; 0x00/0xEE initial buffers; height 1; zero width/height; invalid descriptors; mixed-invalid errors and a missing driver with an active style frame followed immediately by a valid rendering.
The one-byte address rule is checked against the formula reported by BunnyFl. The fixture is not their DFHEI5-SONY2022.ttf, so it does not claim to reproduce that font's 309 changed bytes. Four-byte cases verify the current host raster's addressing and extent, not equivalence with the reported firmware raster.
pr_overlapexamined 1490 open PRs and found no confirmed overlap. Its only uncompleted shared-file comparison was #12757's Font debt file; its complete diff was reviewed manually: it adds GetLibrary/SetFontsOpenMode test/debt entries, not surface rendering or this regression. No dependency is required. The collaborator's existing branch merge is preserved in history.No title, proprietary font, console-hardware run, Linux/macOS execution of this revision, GPU execution or full repository CTest run is claimed. Full upstream Linux/Windows CI requires a maintainer dispatch under CONTRIBUTING.md.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)