如何解决Qt 无法调试 linux 原生 pthread 线程库的问题?

问题描述:

我现在是一起gdb调试就挂,release运行就没有问题。qt5.9,5.12版本上都试过,ubuntu系统18、20版本都试过都不行。

code:

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>


void *func(void *)
{
    while(1) {
        printf("hello world\n");
        sleep(2);
    }
    return NULL;
}

int main()
{
    pthread_t hello;
    pthread_create(&hello, NULL, &func, NULL);
    pthread_join(hello, NULL);
    return 0;
}

debug模式运行崩溃:

img

img

release模式下正常运行:

img