mock加qemu-user-static打包有时卡死问题

经gzlug robin li的建议,此文提到这是一个已知问题,可以暂时避免。

记录内容片断如下:

QEMU user mode

QEMU is a powerful, open source machine emulator. In “user mode”, it allows a single running Linux kernel to run binaries built for other architectures, without needing a full virtual machine. The binaries can be executed transparently using the kernel’s 

1
binfmt_misc
 feature. Following our instructions, the whole BuildStream build process can run on an x86_64 machine and produce working RISC-V binaries and images.

While running our first builds with this method, we encountered a bug that caused some programs to hang. We first noticed the issue in 

1
cargo
, the build tool for Rust. The hang can be triggered when a program uses 
1
fork()
 and threads, and when we investigated we saw it was inside GLib, a dependency used in a lot of Linux desktop software. This library is used by QEMU itself, but it might also be used in the process being emulated. When a 
1
fork()
 call happens, GLib’s memory allocator hits a situation that it isn’t designed to handle, and its thread synchronization locks up completely.

We discussed this upstream in a GLib issue and a QEMU issue, and we hope that QEMU can eventually work around the problem.

In the meantime, you can work around it manually by telling GLib to use 

1
malloc()
 instead of its own allocator – 
1
malloc()
 isn’t necessarily safe to use in a forked process either, but the GNU C Library guarantees that it is. To enable this workaround you set a special environment variable: 
1
G_SLICE=always-malloc
.

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据