[Bug libc/24963] deadlock between freopen and fclose

nsz at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Mon Sep 23 10:35:00 GMT 2019


https://sourceware.org/bugzilla/show_bug.cgi?id=24963

--- Comment #6 from Szabolcs Nagy <nsz at gcc dot gnu.org> ---
lock order should be either

list_all_lock -> fp
and then list_all_lock must not be locked while
an fp is already locked, i.e. freopen should be
fixed (by taking list_all_lock before the fp lock).

or

fp -> list_all_lock
and then current _IO_un_link and fflush(0) are wrong
since they take list_all_lock first then the fp lock.
fixing this is harder (before all _IO_un_link call fp
should be locked and fflush should somehow lock all fps)

(i assumed both locks are recursive, if list_all_lock
is not recursive then fixing freopen may be trickier).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list