两次fork,第二次fork得父进程不退出

Offen
#3,188 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
cpp, linux

Rechercherichtung

Beginne mit utils/daemonize.h und client/main.cc, untersuche dann bvar/detail/sampler.cpp und butil/synchronization/lock.h im Umfeld des Mutex-Wartens, das im Stacktrace gezeigt wird. Reproduziere den Fall der Daemonisierung mit zwei Forks auf Ubuntu 22.04 und bestätige, dass der Elternprozess beendet wird, ohne während der Bereinigung des Samplers hängen zu bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug
两次fork,第二次fork得父进程不退出

To Reproduce
连接brpc得程序,通过两次fork来实现daemonize,多次运行之后可以复现

Expected behavior

父进程能够正常退出,

Versions
OS: Ubuntu 22.04
Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
brpc: 1.15.0
protobuf: tag: v3.25.5

Additional context/screenshots

`
[New LWP 437932]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007faab40873f0 in __lll_lock_wait () from /lib64/libc.so.6

Thread 2 (Thread 0x7faab3e79640 (LWP 437932) "bvar_sampler"):
#0 0x00007faab40d4655 in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6
#1 0x00007faab40d9247 in nanosleep () from /lib64/libc.so.6
#2 0x00007faab41050f9 in usleep () from /lib64/libc.so.6
#3 0x00000000015f98ba in bvar::detail::SamplerCollector::run (this=this@entry=0x4d270f0) at /dingo-eureka/brpc/src/bvar/detail/sampler.cpp:183
#4 0x00000000015fb7f0 in bvar::detail::SamplerCollector::sampling_thread (arg=0x4d270f0) at /dingo-eureka/brpc/src/bvar/detail/sampler.cpp:113
#5 0x00007faab408a19a in start_thread () from /lib64/libc.so.6
#6 0x00007faab410f210 in clone3 () from /lib64/libc.so.6

Thread 1 (Thread 0x7faab4227280 (LWP 437931) "dingo-client"):
#0 0x00007faab40873f0 in __lll_lock_wait () from /lib64/libc.so.6
#1 0x00007faab408d582 in pthread_mutex_lock@@GLIBC_2.2.5 () from /lib64/libc.so.6
#2 0x00000000015f9546 in butil::Mutex::lock (this=0x4f5c470) at /dingo-eureka/brpc/src/butil/synchronization/lock.h:74
#3 bvar::detail::Sampler::destroy (this=0x4f5c450) at /dingo-eureka/brpc/src/bvar/detail/sampler.cpp:214
#4 0x00000000005616eb in bvar::PassiveStatus::~PassiveStatus (this=0x3f22c00 bvar::g_size, __in_chrg=) at /root/.local/dingo-eureka/include/bvar/passive_status.h:112
#5 0x00007faab40412dd in __run_exit_handlers () from /lib64/libc.so.6
#6 0x00007faab4041430 in exit () from /lib64/libc.so.6
#7 0x0000000000555bef in dingofs::utils::Daemonize (chdir_root=, close_fds=) at /opt/dingofs/src/utils/daemonize.h:34
#8 0x0000000000521fb6 in main (argc=, argv=) at /opt/dingofs/src/client/main.cc:195
`

Vorherrschende Sprache
C++
Sterne
17.6k
Forks
4.2k
Ø Merge
3 T. 17 Std.
Gemergte PRs (30 T.)
72

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/brpc

Alle Issues in apache/brpc

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.