salesforce / p4-fusion

A fast Perforce to Git conversion tool written in C++ using Perforce Helix Core C++ API and Libgit2
BSD 3-Clause "New" or "Revised" License
78 stars 15 forks source link

Rare cases when `~P4API()` crashes while p4-fusion is shutting down #36

Closed twarit-waikar closed 2 years ago

twarit-waikar commented 2 years ago

In rare cases, p4-fusion crashes when running ThreadPool::ShutDown(), where the P4API destructor (defined in the Helix Core C++ API library) runs into a segmentation fault.

Version: 1.9 OS: CentOS 7

Crash backtrace from gdb:

Program terminated with signal 11, Segmentation fault.
#0  Signaler::DeleteOnIntr (this=0x55a7a6720460 <signaler>, ptr=0x7f1b1893c3b0) at ../p4/sys/signaler.cc:229
229 ../p4/sys/signaler.cc: No such file or directory.
(gdb)
(gdb) where
#0  Signaler::DeleteOnIntr (this=0x55a7a6720460 <signaler>, ptr=0x7f1b1893c3b0) at ../p4/sys/signaler.cc:229
#1  0x000055a7a62c4b13 in Rpc::~Rpc (this=0x7f1b1893c3b0, __in_chrg=<optimized out>) at ../p4/rpc/rpc.cc:312
#2  0x000055a7a62a3ef7 in Client::~Client (this=0x7f1b1893c3b0, __in_chrg=<optimized out>) at ../p4/support/strbuf.h:369
#3  0x000055a7a629c8ac in ClientApi::~ClientApi (this=0x7f1b188df100, __in_chrg=<optimized out>) at ../p4/client/clientapi.cc:21
#4  0x000055a7a6298d4c in _Destroy<P4API> (__pointer=0x7f1b188df100) at /usr/include/c++/10.3.1/bits/stl_construct.h:135
#5  __destroy<P4API*> (__last=<optimized out>, __first=0x7f1b188df100) at /usr/include/c++/10.3.1/bits/stl_construct.h:152
#6  _Destroy<P4API*> (__last=<optimized out>, __first=<optimized out>) at /usr/include/c++/10.3.1/bits/stl_construct.h:185
#7  _Destroy<P4API*, P4API> (__last=<optimized out>, __first=<optimized out>) at /usr/include/c++/10.3.1/bits/alloc_traits.h:738
#8  _M_erase_at_end (__pos=0x7f1b188df100, this=0x55a7a671f750 <ThreadPool::GetSingleton()::singleton+112>) at /usr/include/c++/10.3.1/bits/stl_vector.h:1796
#9  clear (this=0x55a7a671f750 <ThreadPool::GetSingleton()::singleton+112>) at /usr/include/c++/10.3.1/bits/stl_vector.h:1499
#10 ThreadPool::ShutDown (this=0x55a7a671f6e0 <ThreadPool::GetSingleton()::singleton>) at /tmp/tmp.CjOLdF/p4-fusion-src/p4-fusion/thread_pool.cc:78
#11 0x000055a7a6299385 in ThreadPool::ShutDown (this=<optimized out>) at /tmp/tmp.CjOLdF/p4-fusion-src/p4-fusion/thread_pool.cc:58
#12 0x000055a7a6289fc1 in Main(int, char**) () at /tmp/tmp.CjOLdF/p4-fusion-src/p4-fusion/main.cc:308
#13 0x000055a7a627b027 in main () at /tmp/tmp.CjOLdF/p4-fusion-src/p4-fusion/main.cc:344
#14 0x00007f1b18d31a03 in ?? ()
#15 0x00007f1b18d319dc in ?? ()
#16 0x00007ffc0b6fce20 in ?? ()
#17 0x0000000000000000 in ?? ()
twarit-waikar commented 2 years ago

This usually doesn't corrupt any data because the cloning is complete by the time when ThreadPool::ShutDown() is called

twarit-waikar commented 2 years ago

Related:

  1. https://www.perforce.com/manuals/p4api/Content/P4API/p4libraries.html?Highlight=thread
  2. https://www.perforce.com/manuals/p4api/Content/P4API/chapter.clientprogramming.signaler.html