Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in fbtracemgr when closing it using ctrl-C [CORE6045] #6295

Closed
firebird-automations opened this issue Apr 9, 2019 · 11 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @artyom-smirnov

Depends on CORE6027

When embedded access is used (specially to embedded services manager) fb_shutdown() should be invoked before exit is called (including return from main()). Unfortunately in out utilities at_exit() function is used for it which is not good cause using it fb_shutdown() is called _during_ exit which appears to be too late in some cases.

Commits: ad190a8 5fbf07e

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

description: When embedded access is used (specially to embedded services manager) fb_shutdown() should be invoked before exit is called (including return from main()). Unfortunately => When embedded access is used (specially to embedded services manager) fb_shutdown() should be invoked before exit is called (including return from main()). Unfortunately in out utilities at_exit() function is used for it which is not good cause using it fb_shutdown() is called _during_ exit which appears to be too late in some cases.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

Link: This issue depends on CORE6027 [ CORE6027 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Server hang in 6027 is not directly related to segfault in fbtracemgr but in provided test case caused by it.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

reporter: Alexander Peshkov [ alexpeshkoff ] => Artyom Smirnov [ artyom.smirnov ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

I've fixed utilities working with services manager. They are primary candidates for causing segfaults.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0.5 [ 10885 ]

Fix Version: 4.0 Beta 2 [ 10888 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @artyom-smirnov

I still see segfaults if AuditTraceConfigFile defined in firebird.conf

@firebird-automations
Copy link
Collaborator Author

Commented by: @artyom-smirnov

Some backtraces from cores I've observed:

Core was generated by `./bin/fbtracemgr -se service_mgr -user SYSDBA -password ********* -start -c fbt'.
Program terminated with signal SIGABRT, Aborted.
#⁠0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f3d859c1700 (LWP 461))]
(gdb) bt
#⁠0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#⁠1 0x00007f3d86e41535 in __GI_abort () at abort.c:79
#⁠2 0x00007f3d83cac706 in Firebird::system_call_failed::system_call_failed (this=0x7f3d74000e50, syscall=0x7f3d83d05f01 "pthread_mutex_destroy", error_code=16)
at /workspace/rdb/firebird_3_0/src/common/fb_exception.cpp:244
#⁠3 0x00007f3d83cac751 in Firebird::system_call_failed::raise (syscall=0x7f3d83d05f01 "pthread_mutex_destroy", error_code=16)
at /workspace/rdb/firebird_3_0/src/common/fb_exception.cpp:250
#⁠4 0x00007f3d83cab1df in Firebird::Mutex::~Mutex (this=0x7f3d83d76518 Firebird::MemPool::init\(\)::mpBuffer\+664\, __in_chrg=<optimized out>)
at /workspace/rdb/firebird_3_0/src/include/../common/classes/locks.h:220
#⁠5 0x00007f3d83cc1e31 in Firebird::MemPool::~MemPool (this=0x7f3d83d76280 Firebird::MemPool::init\(\)::mpBuffer\, __in_chrg=<optimized out>)
at /workspace/rdb/firebird_3_0/src/common/classes/alloc.cpp:2089
#⁠6 0x00007f3d83cc4fbc in Firebird::MemPool::cleanup () at /workspace/rdb/firebird_3_0/src/common/classes/alloc.cpp:1845
#⁠7 0x00007f3d83cc179e in Firebird::MemoryPool::cleanup () at /workspace/rdb/firebird_3_0/src/common/classes/alloc.cpp:2031
#⁠8 0x00007f3d83cc0c2b in (anonymous namespace)::allClean () at /workspace/rdb/firebird_3_0/src/common/classes/init.cpp:157
#⁠9 0x00007f3d83cc0cef in (anonymous namespace)::Cleanup::~Cleanup (this=0x7f3d83d76010 <(anonymous namespace)::global>, __in_chrg=<optimized out>)
at /workspace/rdb/firebird_3_0/src/common/classes/init.cpp:172
#⁠10 0x00007f3d86e63a77 in __cxa_finalize (d=0x7f3d83d75480) at cxa_finalize.c:83
#⁠11 0x00007f3d83c689b3 in __do_global_dtors_aux () from /workspace/rdb/firebird_3_0/gen/Debug/firebird/plugins/libfbtrace.so
#⁠12 0x00007f3d859bf870 in ?? ()
#⁠13 0x00007f3d87513995 in _dl_close_worker (map=<optimized out>, force=<optimized out>) at dl-close.c:288
Backtrace stopped: frame did not save the PC

Core was generated by `./bin/fbtracemgr -se service_mgr -user SYSDBA -password ********* -start -c fbt'.
Program terminated with signal SIGSEGV, Segmentation fault.
#⁠0 0x00007fb954312c46 in Firebird::Array<Jrd::TraceManager::FactoryInfo, Firebird::EmptyStorageJrd::TraceManager::FactoryInfo\ >::begin (this=0x0)
at /workspace/rdb/firebird_3_0/src/jrd/trace/../../jrd/trace/../../common/classes/array.h:201
201 T* begin() { return data; }
[Current thread is 1 (Thread 0x7fb956a59d40 (LWP 1491))]
(gdb) bt
#⁠0 0x00007fb954312c46 in Firebird::Array<Jrd::TraceManager::FactoryInfo, Firebird::EmptyStorageJrd::TraceManager::FactoryInfo\ >::begin (this=0x0)
at /workspace/rdb/firebird_3_0/src/jrd/trace/../../jrd/trace/../../common/classes/array.h:201
#⁠1 0x00007fb95430fb62 in Jrd::TraceManager::update_session (this=0x7fb953d9efa0, session=...) at /workspace/rdb/firebird_3_0/src/jrd/trace/TraceManager.cpp:317
#⁠2 0x00007fb95430f522 in Jrd::TraceManager::update_sessions (this=0x7fb953d9efa0) at /workspace/rdb/firebird_3_0/src/jrd/trace/TraceManager.cpp:222
#⁠3 0x00007fb953eeb185 in Jrd::TraceManager::needs (this=0x7fb953d9efa0, e=15) at /workspace/rdb/firebird_3_0/src/jrd/../jrd/trace/TraceManager.h:125
#⁠4 0x00007fb95407d240 in Jrd::Service::query2 (this=0x7fb953da5d50, send_item_length=8, send_items=0x7fff409c55e0 "@\004", recv_item_length=2,
recv_items=0x7fff409c55de "?\001@\004", buffer_length=16383, info=0x7fff409c5611 "") at /workspace/rdb/firebird_3_0/src/jrd/svc.cpp:1519
#⁠5 0x00007fb953fd71f0 in Jrd::JService::query (this=0x7fb953da0560, user_status=0x7fff409c5140, sendLength=8, sendItems=0x7fff409c55e0 "@\004",
receiveLength=2, receiveItems=0x7fff409c55de "?\001@\004", bufferLength=16383, buffer=0x7fff409c55f0 "?\034")
at /workspace/rdb/firebird_3_0/src/jrd/jrd.cpp:3932
#⁠6 0x00007fb953ffffa2 in Firebird::IServiceBaseImpl<Jrd::JService, Firebird::CheckStatusWrapper, Firebird::IReferenceCountedImpl<Jrd::JService, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IVersionedImpl<Jrd::JService, Firebird::CheckStatusWrapper, Firebird::InheritFirebird::IService\ > > > >::cloopqueryDispatcher (self=0x7fb953da0568, status=0x7fff409c52f8, sendLength=8, sendItems=0x7fff409c55e0 "@\004", receiveLength=2, receiveItems=0x7fff409c55de "?\001@\004",
bufferLength=16383, buffer=0x7fff409c55f0 "?\034") at /workspace/rdb/firebird_3_0/src/include/firebird/IdlFbInterfaces.h:9128
#⁠7 0x00007fb9572626f4 in Firebird::IService::queryFirebird::CheckStatusWrapper\ (this=0x7fb953da0568, status=0x7fff409c52f0, sendLength=8,
sendItems=0x7fff409c55e0 "@\004", receiveLength=2, receiveItems=0x7fff409c55de "?\001@\004", bufferLength=16383, buffer=0x7fff409c55f0 "?\034")
at /workspace/rdb/firebird_3_0/src/include/firebird/IdlFbInterfaces.h:1998
#⁠8 0x00007fb95725092b in Why::YService::query (this=0x7fb9571d3e00, status=0x7fff409c52f0, sendLength=8, sendItems=0x7fff409c55e0 "@\004", receiveLength=2,
receiveItems=0x7fff409c55de "?\001@\004", bufferLength=16383, buffer=0x7fff409c55f0 "?\034") at /workspace/rdb/firebird_3_0/src/yvalve/why.cpp:5605
#⁠9 0x00007fb957246a4e in isc_service_query (userStatus=0x7fff409c5530, handle=0x7fff409c9f28, sendItemLength=8, sendItems=0x7fff409c55e0 "@\004",
recvItemLength=2, recvItems=0x7fff409c55de "?\001@\004", bufferLength=16383, buffer=0x7fff409c55f0 "?\034")
at /workspace/rdb/firebird_3_0/src/yvalve/why.cpp:3337
#⁠10 0x000056429ff537c9 in Firebird::TraceSvcUtil::runService (this=0x7fff409c9f20, spbSize=159, spb=0x7fb956a476e0 "\026\003\233")
at /workspace/rdb/firebird_3_0/src/utilities/fbtracemgr/traceMgrMain.cpp:229
#⁠11 0x000056429ff53151 in Firebird::TraceSvcUtil::startSession (this=0x7fff409c9f20, session=...)
at /workspace/rdb/firebird_3_0/src/utilities/fbtracemgr/traceMgrMain.cpp:168
#⁠12 0x000056429ff55d90 in Firebird::fbtrace (uSvc=0x7fb956a474c0, traceSvc=0x7fff409c9f20) at /workspace/rdb/firebird_3_0/src/jrd/trace/TraceCmdLine.cpp:408
#⁠13 0x000056429ff53b69 in main (argc=10, argv=0x7fff409ca0e8) at /workspace/rdb/firebird_3_0/src/utilities/fbtracemgr/traceMgrMain.cpp:325

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Component: TRACEMGR [ 10140 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

thread apply all bt
command to be used instead plain
bt
in order to see what other threads are doing and fix races

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment