FirebirdSQL / firebird

Firebird server, client and tools
https://firebirdsql.org
1.26k stars 217 forks source link

Crash at database restore due to failed system call #8315

Closed hvlad closed 1 week ago

hvlad commented 1 week ago

There reason is rase condition in Burp::IOBuffer::unlock().

The call stack #0 0x00007f561fbc541f in raise () from /lib64/libc.so.6 #1 0x00007f561fbaf895 in abort () from /lib64/libc.so.6 #2 0x000000000041408d in __gnu_cxx::__verbose_terminate_handler() [clone .cold] () #3 0x0000000000548976 in __cxxabiv1::__terminate(void (*)()) () #4 0x00000000005dfca9 in __cxa_call_terminate () #5 0x0000000000548621 in __gxx_personality_v0 () #6 0x00007f561fd833c4 in _Unwind_RaiseException_Phase2 () from /lib64/libgcc_s.so.1 #7 0x00007f561fd83a61 in _Unwind_RaiseException () from /lib64/libgcc_s.so.1 #8 0x0000000000548b27 in __cxa_throw () #9 0x000000000040a098 in Firebird::system_call_failed::raise (syscall=0x5ea0a7 "pthread_mutex_unlock", error_code=1) at /src/common/fb_exception.cpp:268 #10 0x0000000000418107 in Firebird::Mutex::leave (this=) at /src/include/../common/classes/locks.h:244 #11 Burp::IOBuffer::unlock (opt=true, this=) at /src/burp/../burp/BurpTasks.h:553 #12 Burp::RestoreRelationTask::Item::EnsureUnlockBuffer::~EnsureUnlockBuffer (this=, __in_chrg=) at /src/burp/BurpTasks.cpp:1102 #13 0x000000000041b492 in Burp::RestoreRelationTask::handler (this=, _item=...) at /src/burp/BurpTasks.cpp:88 #14 0x00000000004843be in Firebird::Worker::work (this=this@entry=0x7f55d956bfe0, thd=thd@entry=0x0) at /src/common/Task.cpp:149 #15 0x00000000004853cb in Firebird::Coordinator::runSync (this=0x7ffc23434440, task=0x7ffc23434960) at /src/common/Task.cpp:241 #16 0x000000000047a364 in (anonymous namespace)::get_relation_data (task=, coord=, tdgbl=) at /temp/Release/burp/restore.cpp:17783 #17 (anonymous namespace)::restore (tdgbl=0x7ffc23436260, provider=, file_name=, database_name=) at /temp/Release/burp/restore.cpp:21738 #18 0x000000000047a751 in RESTORE_restore (file_name=0x7f561f9f1924 "stdin", database_name=0x7f561f9f2610 "/home/db-5.0.fdb") at /temp/Release/burp/restore.cpp:5797 #19 0x000000000043fdfb in gbak (uSvc=) at /src/burp/burp.cpp:1492 #20 0x0000000000416446 in main (argc=, argv=0x7ffc234373c8) at /src/burp/main/burpMain.cpp:64

Thanks to @ilya071294 who reported the bug and provided call stack and initial analysis.