Open sv641 opened 2 years ago
I looked into this problem for a while.
I found that the code was calling fputs() on km_log_file even though the line numbers in the backtrace seemed to indicate we were writing on stderr (which is closed in this case).
There is a lock inside of the FILE structure that is apparently held by another thread. I ran pthread_self() from gdb to find out the thread's pthread_t and compared with the lock owner field in the lock.
That would seem to be impossible since there are no other threads in the process.
In addition I looked at the fork code in glibc to see what it did about reseting these FILE structure locks in the child and found that it has code to handle that. Look for the function fresetlockfiles() in file posix/fork.c
I don't know the cause of this problem.
Is it possible the lock was taken in the parent before fork()
duplicated the memory? In other words child inherits the lock in already taken state.
I understand there isn't enough data to prove or disprove this hypothesis. We could sort of guess by the numeric value of the lock owner, maybe...
Is it possible the lock was taken in the parent before
fork()
duplicated the memory? In other words child inherits the lock in already taken state.I understand there isn't enough data to prove or disprove this hypothesis. We could sort of guess by the numeric value of the lock owner, maybe...
I think fork() in glibc has code to handle the problem. The function fresetlockfiles() is called to have all of the FILE structure locks marked as unlocked. And, the locks in the FILE structure are futex's. The stdio functions don't use pthread_mutex's for the lock that is causing trouble.
popen test hangs occasionally with kvm running on ubuntu 20.04 guest running on windows 10 hyper-v host
no core file is generated
test command is popen_test.kmd /etc/group /tmp/f13839098 /tmp/f23839098