Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 915827 - app-misc/utimer-0.4-r1 with glibc 2.38-r5: deadlock at exit in countdown mode
Summary: app-misc/utimer-0.4-r1 with glibc 2.38-r5: deadlock at exit in countdown mode
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard:
Keywords: PATCH, PMASKED
Depends on:
Blocks: glibc-2.38
  Show dependency tree
 
Reported: 2023-10-15 16:58 UTC by Maciej S. Szmigiero
Modified: 2024-02-02 16:44 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Workaround fix (utimer-use-unlocked-io-in-thread.patch,252 bytes, patch)
2023-10-15 16:58 UTC, Maciej S. Szmigiero
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej S. Szmigiero 2023-10-15 16:58:02 UTC
app-misc/utimer-0.4-r1 with (at least) sys-libs/glibc-2.38-r5 deadlocks at exit in the countdown mode.

How to reproduce:
utimer -c 1s

Expected result:
Program counts down to zero, then exits

Actual result:
Program counts down to zero, then locks up (sometimes pressing ENTER a few times lets it exit).

Analysis:
(gdb) thread 1
(gdb) bt
#0  0x00007ffff7c64f16 in __lll_lock_wait_private () at /lib64/libc.so.6
#1  0x00007ffff7c625b5 in _IO_flush_all () at /lib64/libc.so.6
#2  0x00007ffff7c629a6 in _IO_cleanup () at /lib64/libc.so.6
#3  0x00007ffff7c1c270 in __run_exit_handlers () at /lib64/libc.so.6
#4  0x00007ffff7c1c2ac in  () at /lib64/libc.so.6
#5  0x00007ffff7c03e13 in __libc_start_call_main () at /lib64/libc.so.6
#6  0x00007ffff7c03ec5 in __libc_start_main () at /lib64/libc.so.6
#7  0x0000555555556b6a in _start ()
(gdb) thread 2
(gdb) bt
#0  0x00007ffff7cddf8d in read () at /lib64/libc.so.6
#1  0x00007ffff7c5f6f2 in _IO_file_underflow () at /lib64/libc.so.6
#2  0x00007ffff7c61afb in _IO_default_uflow () at /lib64/libc.so.6
#3  0x00007ffff7c5c008 in getc () at /lib64/libc.so.6
#4  0x0000555555557c2c in check_exit_from_user ()
#5  0x00007ffff7e575bd in g_thread_proxy () at /usr/lib64/libglib-2.0.so.0
#6  0x00007ffff7c681ea in start_thread () at /lib64/libc.so.6
#7  0x00007ffff7ceb4a8 in clone3 () at /lib64/libc.so.6

There seems to be no code in utimer to terminate at utimer exit that second thread - which is reading stdio via fgetc().
This causes its fgetc() call to deadlock with glibc atexit handlers run from main thread when it is trying to exit.

A simple patch of switching to fgetc_unlocked() in that second thread seems to let it exit cleanly for me (patch attached).
This might not be THE right solution - cleanly terminating the second thread would be required for that.
Comment 1 Maciej S. Szmigiero 2023-10-15 16:58:40 UTC
Created attachment 872938 [details, diff]
Workaround fix
Comment 2 Larry the Git Cow gentoo-dev 2023-12-31 17:21:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ebee5f9ed8c1f7393becbf0de2c15948887eadb8

commit ebee5f9ed8c1f7393becbf0de2c15948887eadb8
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2023-12-31 16:00:03 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2023-12-31 17:21:48 +0000

    package.mask: Last rite app-misc/utimer
    
    Bug: https://bugs.gentoo.org/915827
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 profiles/package.mask | 6 ++++++
 1 file changed, 6 insertions(+)
Comment 3 Larry the Git Cow gentoo-dev 2024-02-02 16:44:54 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9e57c0fda087323a434a3bfc389873c530594697

commit 9e57c0fda087323a434a3bfc389873c530594697
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2024-02-02 16:41:40 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2024-02-02 16:41:40 +0000

    app-misc/utimer: Remove last-rited pkg
    
    Closes: https://bugs.gentoo.org/915827
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 app-misc/utimer/Manifest                          |  1 -
 app-misc/utimer/files/utimer-0.4-fno-common.patch | 29 ----------------------
 app-misc/utimer/files/utimer-0.4-locale.patch     | 10 --------
 app-misc/utimer/metadata.xml                      |  5 ----
 app-misc/utimer/utimer-0.4-r1.ebuild              | 30 -----------------------
 profiles/package.mask                             |  6 -----
 6 files changed, 81 deletions(-)