当我跑步时
qemu-arm -L /usr/arm-linux-gnueabi/ ./foo
在MacOS 10.13上的docker Linux 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
中,
然后出现此错误:
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
qemu-arm版本信息为:
# qemu-arm --version
qemu-arm version 2.5.1, Copyright (c) 2003-2008 Fabrice Bellard
foo
二进制信息为:
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=86eb0b9c5fb202aad4f915699afc36e7bd209743, not stripped
然后,我用gdb
调试了qemu-arm
,得到了详细信息:
gdb-peda$ r -L /usr/arm-linux-gnueabi/lib ./foo
Starting program: /qira/tracers/qemu/qemu-2.5.1/arm-linux-user/qemu-arm -L /usr/arm-linux-gnueabi/lib ./foo
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff65ab700 (LWP 1980)]
Thread 1 "qemu-arm" received signal SIGSEGV, Segmentation fault.
...
Stopped reason: SIGSEGV
__GI__IO_fwrite (buf=0x7ffff45c6720, size=size@entry=0x1, count=count@entry=0x8e0, fp=fp@entry=0x0) at iofwrite.c:37
37 iofwrite.c: No such file or directory.
gdb-peda$ bt
#0 __GI__IO_fwrite (buf=0x7ffff45c6720, size=size@entry=0x1, count=count@entry=0x8e0, fp=fp@entry=0x0) at iofwrite.c:37
#1 0x0000000000418470 in write_out_base (env=env@entry=0x2e128a0, id=0x0) at /qira/tracers/qemu/qemu-latest/tci.c:895
#2 0x0000000000419fb5 in tcg_qemu_tb_exec (env=env@entry=0x2e128a0, tb_ptr=0x7985f0 <static_code_gen_buffer> "\f\b") at /qira/tracers/qemu/qemu-latest/tci.c:947
#3 0x000000000040ccec in cpu_tb_exec (tb_ptr=<optimized out>, cpu=0x2e0a630) at /qira/tracers/qemu/qemu-latest/cpu-exec.c:157
#4 cpu_arm_exec (cpu=cpu@entry=0x2e0a630) at /qira/tracers/qemu/qemu-latest/cpu-exec.c:520
#5 0x000000000042e6e4 in cpu_loop (env=env@entry=0x2e128a0) at /qira/tracers/qemu/qemu-latest/linux-user/main.c:676
#6 0x0000000000409d63 in main (argc=argc@entry=0x4, argv=argv@entry=0x7fffffffe588, envp=<optimized out>) at /qira/tracers/qemu/qemu-latest/linux-user/main.c:4695
#7 0x00007ffff683c830 in __libc_start_main (main=0x409710 <main>, argc=0x4, argv=0x7fffffffe588, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe578)
at ../csu/libc-start.c:291
#8 0x000000000040a2e9 in _start ()
我对此错误进行了很多搜索,但没有帮助。仍然无法正确运行。
PS:在我同事的Ubuntu-VM上,./foo
可以使用具有相同版本的qemu-arm
正常运行,因此我很困惑这个segv是否由docker环境引起?如果没有,如何在我的docker中正确运行./foo
?谢谢!
============ 更新更多信息:
# qemu-arm -strace -L /usr/arm-linux-gnueabi/ ./foo
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
# strace qemu-arm -L /usr/arm-linux-gnueabi/ ./foo
...(lots of logs)
rt_sigaction(SIGRT_25, {0x44aa80, ~[RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f0f3f13d390}, NULL, 8) = 0
rt_sigaction(SIGRT_26, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGRT_26, {0x44aa80, ~[RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f0f3f13d390}, NULL, 8) = 0
rt_sigaction(SIGRT_27, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGRT_27, {0x44aa80, ~[RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f0f3f13d390}, NULL, 8) = 0
rt_sigaction(SIGRT_28, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGRT_28, {0x44aa80, ~[RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f0f3f13d390}, NULL, 8) = 0
rt_sigaction(SIGRT_29, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGRT_29, {0x44aa80, ~[RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f0f3f13d390}, NULL, 8) = 0
rt_sigaction(SIGRT_30, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGRT_30, {0x44aa80, ~[RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f0f3f13d390}, NULL, 8) = 0
rt_sigaction(SIGRT_31, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGRT_31, {0x44aa80, ~[RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f0f3f13d390}, NULL, 8) = 0
stat("/tmp/qira_logs/0", 0x7ffde8aed530) = -1 ENOENT (No such file or directory)
open("/tmp/qira_logs/0_env", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 ENOENT (No such file or directory)
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0} ---
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
getrlimit(RLIMIT_CORE, {rlim_cur=0, rlim_max=RLIM64_INFINITY}) = 0
getrlimit(RLIMIT_CORE, {rlim_cur=0, rlim_max=RLIM64_INFINITY}) = 0
setrlimit(RLIMIT_CORE, {rlim_cur=0, rlim_max=RLIM64_INFINITY}) = 0
futex(0x7f0f3f128880, FUTEX_WAKE_PRIVATE, 2147483647) = 0
write(2, "qemu: uncaught target signal 11 "..., 67qemu: uncaught target signal 11 (Segmentation fault) - core dumped
) = 67
rt_sigaction(SIGSEGV, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7f0f3f13d390}, NULL, 8) = 0
kill(2035, SIGSEGV) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_USER, si_pid=2035, si_uid=0} ---
+++ killed by SIGSEGV +++
Segmentation fault
整个日志文件位于strace-log。