Repository navigation
Studio: avoid AppImage COLRv1 font crashes - #9473
Conversation
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
I added three follow-up commits after reproducing two gaps in the original policy.
The final follow-up only shortens comments. The focused AppImage contract suite passes with 17 tests, and shell syntax and diff checks also pass. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9f53ae674
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| unsloth_fonts_appdir="$(printf '%s' "$APPDIR" | sed \ | ||
| -e 's,&,\&,g' -e 's,<,\<,g' -e 's,>,\>,g' \ | ||
| -e 's,\\,\\\\,g' -e 's,&,\\&,g' -e 's,|,\\|,g')" && | ||
| sed "s|@APPDIR@|$unsloth_fonts_appdir|g" "$unsloth_fonts_template" \ |
There was a problem hiding this comment.
Encode newlines before interpolating the mount path
When the AppImage filename’s unsanitized mount prefix, or an extracted AppDir name, contains a newline, command substitution preserves that newline and line 24 inserts it directly into the sed program, causing sed to fail with an unterminated substitution. Fresh evidence on the current tree: launching from an AppDir named abc\ndef leaves the materialized file empty and exports the shipped template instead, whose literal @APPDIR@ cannot locate UnslothSafeEmoji.ttf; emoji requests therefore lose the bundled safe renderer. Encode XML-invalid/control characters or avoid constructing a sed program from the path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Reproduced, but this lands on the designed fallback rather than on a defect, so I am leaving it.
An AppDir named abc\ndef does fail the substitution and export the shipped template, as you describe, and the truncated write leaves an empty policy behind. That empty file is removed by the next successful launch's cleanup, so it does not accumulate.
The template is not an absence of protection. Under it, fc-match 'sans-serif:charset=1f680' returns NotoSans-Regular.ttf with color=False; with no policy at all the same query returns NotoColorEmoji.ttf with color=True. The color=true rejectfont still runs, so host COLRv1 fonts stay out of the font set and the colrv1_configure_skpaint abort this PR exists to prevent does not return. What is lost is emoji glyphs, which is the tradeoff test_apprun_falls_back_to_the_shipped_font_policy_when_it_cannot_write already covers.
That is the difference from your previous item, which I agreed with and fixed. There a < in the mount path produced a malformed policy, Fontconfig logged Cannot load config file, discarded it and fell back to the host default, which put the crashing font back in front of Skia. A newline degrades safely; & and < did not.
The remaining gap is a file name no user produces. R&D.AppImage is a name people actually type, which is why the encoding change was worth making. Reaching this one means deliberately creating a file whose name contains a newline, and the payoff would be emoji glyphs in a session that is already running with the safe policy.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9f53ae674
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| unsloth_fonts_appdir="$(printf '%s' "$APPDIR" | sed \ | ||
| -e 's,&,\&,g' -e 's,<,\<,g' -e 's,>,\>,g' \ | ||
| -e 's,\\,\\\\,g' -e 's,&,\\&,g' -e 's,|,\\|,g')" && |
There was a problem hiding this comment.
Reject XML-illegal bytes before selecting the generated policy
When the AppDir path contains an XML 1.0-illegal control byte such as U+0001—which Linux filenames permit and the AppImage mount prefix can inherit—these substitutions leave it unchanged; sed still succeeds, so FONTCONFIG_FILE points at the malformed output rather than taking the fallback. Fontconfig then reports that it cannot load the configuration and resumes selecting host fonts, re-exposing the COLRv1 crash this policy is meant to prevent. Fresh evidence on the current commit is that an AppDir named mount-a\x01b produces a materialized file containing that byte and fc-match rejects the file, so validate the generated policy or reject such paths before selecting it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The reproduction is right, and it is worse than the newline case: here sed succeeds, so the malformed file is selected, Fontconfig reports Cannot load config file, and fc-match 'sans-serif:charset=1f680' returns the host NotoColorEmoji.ttf with color=True. The protection is gone, not degraded. I still do not think this should change the code, for two reasons.
First, the guard you describe cannot be made complete at this layer. A control byte is not the only byte the document cannot carry: an AppDir named mount-c\xFFd is an invalid UTF-8 sequence, not a control character, and it produces the identical outcome, not well-formed (invalid token) on the same line, policy discarded, host color font selected. So rejecting [[:cntrl:]] closes half a class and leaves the other half with the same consequence.
Second, closing the whole class means requiring the mount path to be representable in XML, and the only cheap way to test that is a byte whitelist. That has a real cost: an AppDir named mount-josé-Ünslöth-日本 works correctly today and selects the bundled font, and a whitelist strict enough to exclude a lone 0xFF would push those users onto the template fallback and silently cost them bundled emoji. Trading a regression for real paths against a byte no download, release pipeline or file manager produces is the wrong trade. Fontconfig needs the literal directory inside an XML document, so a path that cannot be represented there cannot be used; detecting that reliably needs a parser at launch, which is not worth adding to AppRun.
Where I did agree was the earlier item, and the distinction is reachability, not consequence. R&D.AppImage is a name people actually type, which is why & and < were worth encoding. A file name carrying 0x01 or a lone 0xFF has to be constructed deliberately.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Confirmed there is no font policy in studio/src-tauri/linux/appimage-apprun.sh today, so the Model Hub freeze from the Skia colrv1_configure_skpaint abort is still reachable on a normal AppImage launch. Will get this reviewed. |
…the job (#9530) * Bound the backend pytest session so a wedged xdist worker cannot eat the job --timeout=330 arms inside each xdist worker, so it never fires when the controller is what is stuck. On the #9473 branch this step went silent at 95 percent for 36.8 minutes, three runs running, each burning the full 45 minute budget and reporting cancelled, which reads exactly like ordinary concurrency supersession. Wrap the session in coreutils timeout: SIGINT at 1500s so pytest dumps where it was stuck, SIGKILL 60s later. Reproduced with a test that forks a child that never exits. Unwrapped the run is silent forever and the per-test cap never fires. Wrapped it exits 124 through execnet safe_terminate -> workerpool.waitall, the controller blocked on its workers. * Tighten comments --------- Co-authored-by: danielhanchen <[email protected]>
* fix(linux): prevent AppImage crash on COLRv1 colour fonts The Linux AppImage is built on ubuntu-22.04, so the bundled WebKitGTK and Skia are compiled against FreeType 2.11.1 headers. libfreetype.so.6 is not bundled, so the host's FreeType is loaded at runtime. FreeType 2.13.0 added a field to FT_ColorStopIterator, growing the struct from 16 to 20 bytes. On hosts with FreeType >= 2.13 whose Fontconfig selects a COLRv1 colour font, the layout mismatch corrupts colour-stop index arithmetic in Skia's COLRv1 renderer: stl_vector.h:1123: colrv1_configure_skpaint(...)::ColorStop: Assertion '__n < this->size()' failed. WebKitWebProcess then aborts (SIGABRT). The parent process survives and the window is created but never painted, so the app appears as a black, unresponsive window. Write an AppImage-only Fontconfig file that rejects COLRv1 fonts and point FONTCONFIG_FILE at it before the webview is created. Hosts fall back to a CBDT/sbix emoji font, which never enters the COLRv1 code path. Scoped to the AppImage on purpose: .deb/.rpm bundles link the host WebKitGTK, which matches the host FreeType, so they cannot hit this. Skipped when FONTCONFIG_FILE is already set by the user, and can be disabled with ASYAR_ALLOW_HOST_COLRV1=1. Follows the existing pattern of apply_linux_webkit_dmabuf_workaround(). Refs: - block/buzz#2982 - Niko1221/Strata#4533 - unslothai/unsloth#9473 - #692 (same class of Linux AppImage packaging fix) * fix(linux): harden AppImage COLRv1 fontconfig workaround Resolve the host fonts.conf from FONTCONFIG_PATH or standard locations instead of hardcoding /etc/fonts, skip the workaround when none exists, ignore empty/relative XDG_CACHE_HOME, and write the config atomically. * fix(linux): resolve relative FONTCONFIG_PATH and key COLRv1 config by contents --------- Co-authored-by: Xoshbin <[email protected]>
Summary
Why
The fat AppImage bundles Ubuntu 22.04 WebKitGTK/Skia but intentionally uses the host FreeType runtime. On systems where Fontconfig selects a COLRv1 emoji font, this combination can abort in
colrv1_configure_skpaintwithstd::vector::operator[]: Assertion '__n < this->size()' failed. Model Hub cards are one trigger.Bundling an older FreeType made font rendering hang, and README-only sanitization does not cover every renderer path. The AppImage-scoped CBDT fallback avoids the incompatible COLRv1 path without changing
.debbehavior or hiding README content.Verification
15 passed:tests/security/test_release_desktop_appimage.pycolrv1_configure_skpaintassertion observedfda1fa05selected the hostile hostNoto-COLRv1.ttf;61cb9f758keeps the vetted bundled font and rejects every othercolor=truefont, removing that fallback path61cb9f758— run 32497188126 built the AppImage, proved the host selected the exact digest-pinned COLRv1 fixture for both U+1F680 and uncovered U+1FAEA, kept/hubalive for 30s while rendering the probe, and passed Ubuntu 22.04, Ubuntu 22.04 without GLES, Ubuntu 24.04 Wayland, Debian 12, and Fedora 44 portability lanesfda1fa05scrubsFONTCONFIG_FILEbefore opening host browsers/file managers, with a focused Rust regression test61cb9f758, re-reviewed on that exact head, and approved with no remaining major issuesCloses #9453.