Subject Firebird Embedded requires lots of stack space during restore / possibility of stack overflow
Author Antti Nivala
We encountered a stack overflow in our application that uses Firebird
Embedded. The overflow occured during restoring a database (100%
reproducable).

The stack reserve size of our process was 1 MB. Increasing it to 2 MB
fixed the problem. The Firebird Server process seems to use a stack
reserve size of 2 MB, so this is probably the recommended value.

My questions:

1. Is there official advice on setting the stack size when using
Firebird Embedded (i.e. is the requirement of "/STACK:2097152"
documented)?

2. Is 2 MB enough in all cases, or can we encounter a backup file which
causes a stack overflow during restoring even with the 2 MB setting?

Best regards,
Antti Nivala

PS Part of the call stack below (Firebird 2.0.1.12855):

gds32.dll!write_buffer(Jrd::thread_db * tdbb=0x0a3bf590, Jrd::BufferDesc
* bdb=0x0b97df8c, long page=12740, const bool write_thru=false, long *
status=0x00e0855c, const bool write_this_page=false) Line 6125 + 0xb
C++
gds32.dll!write_buffer(Jrd::thread_db * tdbb=0x020ce630, Jrd::BufferDesc
* bdb=0x0b97e05c, long page=12741, const bool write_thru=false, long *
status=0x00e0855c, const bool write_this_page=false) Line 6162 + 0x14
C++
gds32.dll!write_buffer(Jrd::thread_db * tdbb=0x020ce630, Jrd::BufferDesc
* bdb=0x0b97e12c, long page=12742, const bool write_thru=false, long *
status=0x00e0855c, const bool write_this_page=false) Line 6162 + 0x14
C++

<about 1000 similar lines omitted>

gds32.dll!write_buffer(Jrd::thread_db * tdbb=0x020ce630, Jrd::BufferDesc
* bdb=0x0b9309dc, long page=13737, const bool write_thru=false, long *
status=0x00e0855c, const bool write_this_page=false) Line 6162 + 0x14
C++
gds32.dll!write_buffer(Jrd::thread_db * tdbb=0x020ce630, Jrd::BufferDesc
* bdb=0x0b930aac, long page=13738, const bool write_thru=false, long *
status=0x00e0855c, const bool write_this_page=false) Line 6162 + 0x14
C++
gds32.dll!write_buffer(Jrd::thread_db * tdbb=0x020ce630, Jrd::BufferDesc
* bdb=0x0b930b7c, long page=13739, const bool write_thru=false, long *
status=0x00e0855c, const bool write_this_page=false) Line 6162 + 0x14
C++
gds32.dll!write_buffer(Jrd::thread_db * tdbb=0x020ce630, Jrd::BufferDesc
* bdb=0x0b930c4c, long page=13740, const bool write_thru=false, long *
status=0x00e0855c, const bool write_this_page=false) Line 6162 + 0x14
C++
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/