Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard event may cause nemu deadlock #4

Closed
swordfeng opened this issue Feb 21, 2016 · 1 comment
Closed

Keyboard event may cause nemu deadlock #4

swordfeng opened this issue Feb 21, 2016 · 1 comment

Comments

@swordfeng
Copy link

My backtrace:

The executable is obj/game/game.
For help, type "help"
(nemu) c
.�[kernel/src/main.c,74,init_cond] {kernel} Hello, NEMU world!
.....................................^C
Program received signal SIGINT, Interrupt.
0x00007ffff651f66b in __lll_lock_wait_private () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff651f66b in __lll_lock_wait_private () from /usr/lib/libc.so.6
#1  0x00007ffff64a547a in malloc () from /usr/lib/libc.so.6
#2  0x00007ffff51a7fcc in ?? () from /usr/lib/libxcb.so.1
#3  0x00007ffff51a8548 in ?? () from /usr/lib/libxcb.so.1
#4  0x00007ffff53ffdc8 in ?? () from /usr/lib/libX11.so.6
#5  0x00007ffff53fff2b in ?? () from /usr/lib/libX11.so.6
#6  0x00007ffff540023d in _XEventsQueued () from /usr/lib/libX11.so.6
#7  0x00007ffff53e248a in XFlush () from /usr/lib/libX11.so.6
#8  0x00007ffff7390938 in ?? () from /usr/lib/libSDL-1.2.so.0
#9  0x00007ffff739214b in ?? () from /usr/lib/libSDL-1.2.so.0
#10 0x00007ffff736706c in SDL_PumpEvents () from /usr/lib/libSDL-1.2.so.0
#11 0x00007ffff73670a9 in SDL_PollEvent () from /usr/lib/libSDL-1.2.so.0
#12 0x0000000000430856 in device_update.lto_priv ()
#13 <signal handler called>
#14 0x00007ffff64a378e in _int_malloc () from /usr/lib/libc.so.6
#15 0x00007ffff64a53d4 in malloc () from /usr/lib/libc.so.6
#16 0x00007ffff76800e8 in operator new (sz=31) at /build/gcc-multilib/src/gcc-5-20160209/libstdc++-v3/libsupc++/new_op.cc:50
#17 0x00007ffff7711bed in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve (this=0x7fffffffd870, __res=<optimized out>)
    at /build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:297
#18 0x000000000043a180 in print_instr(InstructionContext&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ()
#19 0x0000000000422827 in int push<(OperandName)15>(InstructionContext&, unsigned int) [clone .lto_priv.73] ()
#20 0x000000000042efd5 in cpu_exec ()
#21 0x000000000043b2ae in cmd_c.lto_priv ()
#22 0x000000000040b3ae in main ()
(gdb) 

The signal came when in malloc(), and the handler called malloc() again so it sucks...

ghost pushed a commit that referenced this issue Feb 22, 2016
* SDL_PollEvent() may eventually call malloc(), therefore it is
  not async singal safe, which may cause deadlock in malloc().
* Timer_intr() should be called in the signal handler, else hlt()
  will get stuck.
* Now device_update() should be called in the for loop of cpu_exec()
  to finish the bottom half of the signal handler.
* This patch fixed issue #4.
ghost pushed a commit that referenced this issue Feb 22, 2016
* SDL_PollEvent() may eventually call malloc(), therefore it is
  not async singal safe, which may cause deadlock in malloc().
* timer_intr() should be called in the signal handler, else hlt()
  will get stuck.
* Now device_update() should be called in the for loop of cpu_exec()
  to finish the bottom half of the signal handler.
* This patch will fix issue #4.
@ghost
Copy link

ghost commented Feb 22, 2016

This issue has been fixed in #7.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant