"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
tog atexit() infinite loop
To:
gameoftrees@openbsd.org
Date:
Fri, 20 May 2022 10:03:34 +0200

Download raw body.

Thread
I just found 'tog log file' spinning on the CPU after trying to quit tog.
Seems like libc's atexit() handler is looping on a spinlock.
Only the log thread is still left in the program.

Can anyone tell what is going on here?
Is the _dofork -> signal -> atexit codepath broken in libc?
Did tog do something wrong?

(gdb) bt
#0  _libc__spinlock (lock=0xcd1ac0fd848 <atexit_lock>) at /usr/src/lib/libc/thread/rthread.c:49
#1  0x00000cd1ac06dc3e in _libc___cxa_finalize (dso=0x0) at /usr/src/lib/libc/stdlib/atexit.c:155
#2  0x00000cd1ac0aa681 in _libc_exit (status=1) at /usr/src/lib/libc/stdlib/exit.c:54
#3  0x00000cd17cf3b5d7 in cleanup (sig=<optimized out>) at /usr/src/lib/libcurses/tty/lib_tstp.c:283
#4  <signal handler called>
#5  _thread_sys_fork () at /tmp/-:3
#6  0x00000cd1ac094d8c in _thread_dofork (sys_fork=0x246) at /usr/src/lib/libc/thread/rthread_libc.c:331
#7  0x00000cd11f85c4e4 in _dofork (sys_fork=<optimized out>) at /usr/src/lib/librthread/rthread_fork.c:78
#8  _thread_fork () at /usr/src/lib/librthread/rthread_fork.c:111
#9  0x00000ccf1b5ca3f2 in start_pack_privsep_child (pack=0xcd149c09230, packidx=0xcd129eeea00)
    at /home/stsp/src/got/tog/../lib/object.c:281
#10 0x00000ccf1b5ceb89 in read_packed_commit_privsep (commit=0xcd1cc0d1668, pack=0xcd149c09230, packidx=0xcd129eeea00, idx=4,
    id=0xcd17e255f88) at /home/stsp/src/got/tog/../lib/object.c:839
#11 0x00000ccf1b5cb3d2 in open_commit (commit=0xcd1cc0d1668, repo=0xcd149c09000, id=0xcd17e255f88, check_cache=0)
    at /home/stsp/src/got/tog/../lib/object.c:945
#12 0x00000ccf1b5cb256 in got_object_open_as_commit (commit=0xcd1cc0d1668, repo=0xcd149c09000, id=0xcd17e255f88)
    at /home/stsp/src/got/tog/../lib/object.c:975
#13 0x00000ccf1b5be0ac in detect_changed_path (changed=0xcd1cc0d16dc, commit=0xcd129eee200, commit_id=0xcd17e2568c0,
    path=0xcd125afeef0 "/lib/path.c", repo=0xcd149c09000) at /home/stsp/src/got/tog/../lib/commit_graph.c:129
#14 0x00000ccf1b5bd7ce in fetch_commits_from_open_branches (graph=0xcd16e6aa3c0, repo=0xcd149c09000, cancel_cb=0x0, cancel_arg=0x0)
    at /home/stsp/src/got/tog/../lib/commit_graph.c:507
#15 0x00000ccf1b5bd9ba in got_commit_graph_iter_next (id=0xcd1cc0d17f0, graph=0xcd16e6aa3c0, repo=0xcd149c09000, cancel_cb=0x0,
    cancel_arg=0x0) at /home/stsp/src/got/tog/../lib/commit_graph.c:600
#16 0x00000ccf1b5af6c2 in queue_commits (a=0xcd125ae7ec8) at /home/stsp/src/got/tog/tog.c:1547
#17 0x00000ccf1b5ae991 in log_thread (arg=0xcd125ae7ec8) at /home/stsp/src/got/tog/tog.c:2054
#18 0x00000cd11f85dfa1 in _rthread_start (v=<optimized out>) at /usr/src/lib/librthread/rthread.c:96
#19 0x00000cd1ac07556a in __tfork_thread () at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:84
(gdb) list
44       * internal support functions
45       */
46      void
47      _spinlock(volatile _atomic_lock_t *lock)
48      {
49              while (_atomic_lock(lock))
50                      sched_yield();
51              membar_enter_after_atomic();
52      }
53      DEF_STRONG(_spinlock);
(gdb) n
50                      sched_yield();
(gdb)
49              while (_atomic_lock(lock))
(gdb)
50                      sched_yield();
(gdb)
49              while (_atomic_lock(lock))
(gdb)
50                      sched_yield();
(gdb)
49              while (_atomic_lock(lock))
(gdb)
50                      sched_yield();
(gdb)
49              while (_atomic_lock(lock))
(gdb)
50                      sched_yield();
(gdb)
49              while (_atomic_lock(lock))
(gdb)
50                      sched_yield();
(gdb) info threads
  Id   Target Id         Frame
* 1    thread 428926     _libc__spinlock (lock=0xcd1ac0fd848 <atexit_lock>) at /usr/src/lib/libc/thread/rthread.c:50
(gdb)