Skip to content

Adds optional static fbclient libraries, including symbol-collision prevention#9104

Open
asfernandes wants to merge 3 commits into
masterfrom
work/fbclient-static
Open

Adds optional static fbclient libraries, including symbol-collision prevention#9104
asfernandes wants to merge 3 commits into
masterfrom
work/fbclient-static

Conversation

@asfernandes

Copy link
Copy Markdown
Member

Static linking cannot expose Firebird’s internal global symbols, including C++ allocation operators, which can override symbols supplied by the host application. The post-processing pipeline preserves the public API while isolating internal symbols.

The static build is optional (requires specific options).

Details:

  • Add the client_static POSIX build target.
  • Add Windows DebugStatic and ReleaseStatic configurations.
  • Slim static archives to symbols reachable from the public API.
  • Rename non-public symbols with a __fbclient_ prefix.
  • Replace Windows DLL_THREAD_DETACH cleanup with FLS-based thread cleanup.
  • Add Linux, macOS, and Windows static-build CI manual workflows.

@hvlad

hvlad commented Jul 24, 2026

Copy link
Copy Markdown
Member

Is it possible to debug app linked with static fbclient (or analyze its memory dump) ?
Does debug files (.pdb .debug) contains renamed symbols ?

@asfernandes

Copy link
Copy Markdown
Member Author

Is it possible to debug app linked with static fbclient (or analyze its memory dump) ? Does debug files (.pdb .debug) contains renamed symbols ?

Tested only in Linux yet, and yes:

08:56:11 asfernandes@shark firebird-master.git ±|work/fbclient-static ✗|→ gdb --args ./01.create 

(gdb) catch throw
Catchpoint 1 (throw)
(gdb) r
Starting program: /home/asfernandes/fb/dev/firebird-master.git/01.create 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff77ff6c0 (LWP 648336)]
[New Thread 0x7ffff6ffe6c0 (LWP 648337)]

Thread 1 "01.create" hit Catchpoint 1 (exception thrown), 0x00007ffff7cc38ca in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff7cc38ca in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x0000555555696d56 in Firebird::status_exception::raise (statusVector=...) at /home/asfernandes/fb/dev/firebird-master.git/src/common/fb_exception.cpp:143
#2  0x00005555555c52e8 in Firebird::Arg::StatusVector::raise (this=0x7fffffffbc68) at /home/asfernandes/fb/dev/firebird-master.git/src/common/StatusArg.cpp:332
#3  0x00005555556ab20d in Remote::analyze (cBlock=⚠️ warning: can't find linker symbol for virtual table for `ClntAuthBlock' value
..., attach_name=..., flags=5, pb=⚠️ warning: can't find linker symbol for virtual table for `Firebird::ClumpletWriter' value
..., parSet=..., node_name=..., ref_db_name=0x0, cryptCb=0x0)
    at /home/asfernandes/fb/dev/firebird-master.git/src/remote/client/interface.cpp:8056
#4  0x00005555556ae33d in Remote::RProvider::create (this=0x7ffff7fafe70, status=0x7fffffffc808, 
    filename=0x7ffff7f3d250 "/home/asfernandes/fb/dev/firebird-master.git/fbtests.fdb", dpb_length=41, dpb=0x7fffffffcec0 "\001\004\004", loopback=false)
    at /home/asfernandes/fb/dev/firebird-master.git/src/remote/client/interface.cpp:1924
#5  0x00005555556ae816 in Remote::RProvider::createDatabase (this=0x7ffff7fafe70, status=0x7fffffffc808, 
    fileName=0x7ffff7f3d250 "/home/asfernandes/fb/dev/firebird-master.git/fbtests.fdb", dpbLength=41, dpb=0x7fffffffcec0 "\001\004\004")
    at /home/asfernandes/fb/dev/firebird-master.git/src/remote/client/interface.cpp:1972
#6  0x00005555556df3e7 in Firebird::IProviderBaseImpl<Remote::RProvider, Firebird::CheckStatusWrapper, Firebird::IPluginBaseImpl<Remote::RProvider, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IReferenceCountedImpl<Remote::RProvider, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IVersionedImpl<Remote::RProvider, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IProvider> > > > > > >::cloopcreateDatabaseDispatcher (self=0x7ffff7fafe78, status=0x7fffffffd070, 
    fileName=0x7ffff7f3d250 "/home/asfernandes/fb/dev/firebird-master.git/fbtests.fdb", dpbLength=41, dpb=0x7fffffffcec0 "\001\004\004")
    at /home/asfernandes/fb/dev/firebird-master.git/src/include/firebird/IdlFbInterfaces.h:13052
#7  0x000055555560cb45 in Firebird::IProvider::createDatabase<Firebird::CheckStatusWrapper> (this=0x7ffff7fafe78, status=0x7fffffffd068, 
    fileName=0x7ffff7f3d250 "/home/asfernandes/fb/dev/firebird-master.git/fbtests.fdb", dpbLength=41, dpb=0x7fffffffcec0 "\001\004\004")
    at /home/asfernandes/fb/dev/firebird-master.git/src/include/firebird/IdlFbInterfaces.h:3046
#8  0x00005555555f7ad9 in Why::Dispatcher::attachOrCreateDatabase (this=0x7ffff7fa8bf0, status=0x7fffffffd068, createFlag=true, filename=0x55555575d019 "fbtests.fdb", 
    dpbLength=26, dpb=0x7ffff7fa8d48 "\001\004\004") at /home/asfernandes/fb/dev/firebird-master.git/src/yvalve/why.cpp:6583
#9  0x00005555555de409 in Why::Dispatcher::createDatabase (this=0x7ffff7fa8bf0, status=0x7fffffffd068, filename=0x55555575d019 "fbtests.fdb", dpbLength=26, 
    dpb=0x7ffff7fa8d48 "\001\004\004") at /home/asfernandes/fb/dev/firebird-master.git/src/yvalve/why.cpp:6502
#10 0x00005555555a2187 in Firebird::IProviderBaseImpl<Why::Dispatcher, Firebird::CheckStatusWrapper, Firebird::IPluginBaseImpl<Why::Dispatcher, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IReferenceCountedImpl<Why::Dispatcher, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IVersionedImpl<Why::Dispatcher, Firebird::CheckStatusWrapper, Firebird::Inherit<Firebird::IProvider> > > > > > >::cloopcreateDatabaseDispatcher (self=0x7ffff7fa8bf8, status=0x7fffffffd168, fileName=0x55555575d019 "fbtests.fdb", 
    dpbLength=26, dpb=0x7ffff7fa8d48 "\001\004\004") at /home/asfernandes/fb/dev/firebird-master.git/src/include/firebird/IdlFbInterfaces.h:13052
#11 0x000055555559bfa7 in Firebird::IProvider::createDatabase<Firebird::ThrowStatusWrapper> (this=0x7ffff7fa8bf8, status=0x7fffffffd160, fileName=0x55555575d019 "fbtests.fdb", 
    dpbLength=26, dpb=0x7ffff7fa8d48 "\001\004\004") at src/include/firebird/IdlFbInterfaces.h:3046
#12 0x000055555559b2b1 in main () at examples/interfaces/01.create.cpp:80
(gdb) b interface.cpp:1922
Breakpoint 2 at 0x5555556ae2c0: file /home/asfernandes/fb/dev/firebird-master.git/src/remote/client/interface.cpp, line 1922.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/asfernandes/fb/dev/firebird-master.git/01.create 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff77ff6c0 (LWP 649231)]

Thread 1 "01.create" hit Breakpoint 2, Remote::RProvider::create (this=0x7ffff7fafe70, status=0x7fffffffc808, 
    filename=0x7ffff7f3d250 "/home/asfernandes/fb/dev/firebird-master.git/fbtests.fdb", dpb_length=41, dpb=0x7fffffffcec0 "\001\004\004", loopback=false)
    at /home/asfernandes/fb/dev/firebird-master.git/src/remote/client/interface.cpp:1922
1922			ClntAuthBlock cBlock(&expanded_name, &newDpb, &dpbParam);
(gdb) n
[New Thread 0x7ffff6ffe6c0 (LWP 649232)]
1923			PathName node_name;

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants