[RFC] Bug related to thread switch
Aditya Kamath
Aditya.Kamath1@ibm.com
Mon Sep 23 14:55:23 GMT 2024
Respected community members,
Hi,
I am currently debugging an issue related to thread switch.
Consider a program,
# cat test.c
#include <iostream>
void *thread_main(void *) {
std::cout << getpid() << std::endl;
sleep(20);
return nullptr;
}
int main(void) {
pthread_t thread;
pthread_create(&thread, nullptr, thread_main, nullptr);
pthread_join(thread, nullptr);
return 0;
}
When we run this code in GDB we get,
Reading symbols from ./test...
(gdb) r
Starting program: /current_gdb/binutils-gdb/gdb/test
12845542
[New Thread 258 (tid 24510773)]
Thread 2 received signal SIGINT, Interrupt.
[Switching to Thread 258 (tid 24510773)]
0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
(gdb) info threads
Id Target Id Frame
1 Thread 1 (tid 23658761) ([sleeping]) 0x00000000 in ?? ()
* 2 Thread 258 (tid 24510773) ([running]) 0xd0611d70 in _p_nsleep () from /usr/lib/libpthreads.a(_shr_xpg5.o)
If we see this frame in thread 1 is not loaded. Also note that thread 2 received a signal and gdb switched to that thread. Ideally, I thought we should not switch threads until a user manually does so.
So, my question is first did AIX miss a hook during recent GDB updates that we see this. Is GDB supposed to switch threads when a interrupt comes and hence the frame was not loaded?
Also, is there a way we can load the frames of thread 1 after the switch?
Actually, after aix_sighandle_frame_sniffer () code, debugging what GDB tried to was difficult.
Any inputs or help or document to read? Kindly let me know. It will be of help to solve this in AIX and GDB.
Have a nice day ahead.
Thanks and regards,
Aditya.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20240923/73e54094/attachment.htm>
More information about the Gdb-patches
mailing list