summary refs log tree commit diff stats
path: root/results/classifier/gemma3:12b/kernel/2935
blob: 2b253343b0797f52869c129a27c9c9bad9fabffe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
strchrnul detection not suitable for macOS
Description of problem:
When qemu is compiled on macOS 15.4, targeting an earlier macOS version (e.g., 15.1), and then run on this earlier macOS version (15.1), it segfaults. This is because:

- the meson test for strchrnul succeeds (the function is present in the library)
- the strchrnul function is therefore used
- but that function was introduced in the system's libc in 15.4 only

The root cause for the bug is that the meson test for strchrnul does not include the appropriate header. Indeed, see the documentation for meson on compiler.has_function (https://mesonbuild.com/Compiler-properties.html#does-a-function-exist)

> Note that, on macOS programs can be compiled targeting older macOS versions than the one that the program is compiled on. It can't be assumed that the OS version that is compiled on matches the OS version that the binary will run on.
> 
> Therefore when detecting function availability with compiler.has_function(), it is important to specify the correct header in the prefix argument.

The correct fix would be, in qemu's meson.build, to change:

`cc.has_function('strchrnul')`

into `cc.has_function('strchrnul', prefix : '#include <string>')`

This is the recommended best practice and would allow correct detection on all platforms, including macOS.
Steps to reproduce:
1. Install qemu from Homebrew, which is built on macOS 15.4
2. Run it on a machine with macOS < 15.4