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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
qemu -daemonize crashes on macOS with "NSPlaceholderDate initialize may have been in progress in another thread"
Description of problem:
Context: I build [an open source project](https://tsduck.io/) on several operating systems and architectures. For riscv64, s390x, ppc64, I build in emulated virtual machines. The three emulated OS work correctly when running qemu manually and the project is correctly built.
Now, I want to automate the process in a script: for each target architecture, boot the VM (start qemu as a background process), connect to the VM using ssh, build the software, collect the binaries, shut down the VM.
Starting the same qemu command as used interactively as a background process with `&` does not work and fails immediately, apparently because of the lack of stdin. So, I added option `-daemonize` (and removed `-nographic` because an error message says the two options are incompatible).
Using `-daemonize` instead of `-nographic`, all qemu command immediately fail with the following error:
```
objc[1141]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[1141]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
```
Steps to reproduce:
```
$ qemu-system-riscv64 -machine virt -smp 8 -m 8192 -daemonize \
-bios fw_jump.bin -kernel u-boot.bin \
-device virtio-net-device,netdev=net \
-netdev user,id=net,hostfwd=tcp::2233-:22 \
-drive file=disk.qcow2,format=qcow2,if=virtio -device virtio-rng-pci
objc[1141]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[1141]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
$ qemu-system-s390x -machine s390-ccw-virtio -cpu max,zpci=on -smp 8 -m 8192 -daemonize \
-drive file=disk.qcow2,format=qcow2,if=none,id=drive-virtio-disk0,cache=none \
-device virtio-blk-ccw,devno=fe.0.0002,drive=drive-virtio-disk0,bootindex=1 \
-nic user,hostfwd=tcp::2288-:22
objc[1209]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[1209]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
$ qemu-system-ppc64 -smp 8 -m 8192 -daemonize \
-drive file=disk.qcow2,format=qcow2 -nic user,hostfwd=tcp::2299-:22
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-cfpc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-sbbc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-ibs=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-ccf-assist=on
objc[1166]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[1166]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
```
All the above commands work correctly when using `-nographic` instead of `-daemonize`. The virtual disks are the same as in the interactive runs, with a fully configured Linux OS (Ubuntu or Debian).
Additional information:
From a [report from here](https://stackoverflow.com/questions/63041445/python-os-high-sierra-nsplaceholderdate-error), I tried to define the environment variable `OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES` before running qemu. The `[__NSPlaceholderDate initialize]` errors disappear but qemu still crashes immediately.
|