Closed
Conversation
13 tasks
K900
pushed a commit
that referenced
this pull request
Jul 1, 2025
K900
pushed a commit
that referenced
this pull request
Jul 1, 2025
K900
pushed a commit
that referenced
this pull request
Feb 7, 2026
On my systems there is a path in the fonts list that looks like
/nix/store/<hash>-<font>.ttf. The previous code assumed that every font path
contains at least one more slash which isn't the case here.
The code matched on the / after the $out path of the derivation:
/nix/store/<hash>-<name>/share/X11/fonts/...
^
That slash only exists if the font lives in a subdirectory, which
isn't strictly required. In my case I've a few font files that are
located at /nix/store/<hash>-<name>.ttf and are assembled into a
folder as symlinks. (See example below)
Any attempt at calling realpath(3) on them (potentially recursively)
will result in the single file entry in the store being returned.
Whenever that font is being loaded flatpak segfaulted like so:
```
(gdb) bt
#0 0x00005583b3673763 in get_nix_closure ()
#1 0x00005583b3673711 in get_nix_closure ()
#2 0x00005583b36737dc in add_nix_store_symlink_targets ()
#3 0x00005583b36749a8 in add_font_path_args ()
NixOS#4 0x00005583b367b3f4 in flatpak_run_app ()
NixOS#5 0x00005583b35e4f08 in flatpak_builtin_run ()
NixOS#6 0x00005583b35a5970 in main ()
(gdb) x/5i $rip
=> 0x5583b3673763 <get_nix_closure+307>: movb $0x0,(%rax)
0x5583b3673766 <get_nix_closure+310>: call 0x5583b35a46a0 <g_hash_table_add@plt>
0x5583b367376b <get_nix_closure+315>: jmp 0x5583b3673699 <get_nix_closure+105>
0x5583b3673770 <get_nix_closure+320>: xor %edi,%edi
0x5583b3673772 <get_nix_closure+322>: lea 0x30475(%rip),%rsi # 0x5583b36a3bee
(gdb) x/s $rsi
0x5583e92d2180: "/nix/store/<hash>-A.ttf"
(gdb) print $rax
$1 = 0
```
RAX pointing to 0 here corresponds to the pointer `p` in the source
code. So the code attempted to dereference a null pointer as no further
slash (the return value of strchr(3)) could be found.
The modification in this commit ensures that we check for `p != 0` so
we don't run into this situation again.
Adding the path to the closure will still be done, even if no further
slash can be found, as that still points to a valid store path.
----
Nix code for custom fonts:
```nix
let
files = [
./A.ttf
./B.ttf
];
in
runCommandNoCC "custom-fonts" {} ''
mkdir -p $out/share/fonts/truetype
cd $out/share/fonts/truetype
${ lib.concatStringsSep "\n" (map (file: "ln -s ${file} ${baseNameOf file}") files)}
''
```
K900
pushed a commit
that referenced
this pull request
Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.