gdb freezes in malloc

前端 未结 2 936
眼角桃花
眼角桃花 2020-12-21 08:04

Suppose I have some C program like this:

#include 
#include 

int main()
{
    while (true) {
        void *p = malloc(1000)         


        
2条回答
  •  轮回少年
    2020-12-21 08:50

    The reason you're froze is probably a lock that's being held by your program, and is also required by printf. When you try to aquire it twice - you fail.

    A possible WA is when breaking your program to call printf, just before you make the call, type finish - it will cause the current function to complete and return to the main frame. This will ensure the lock is free before you call printf.

提交回复
热议问题