PS. Not sure for windows - on linux no physical memory will be given to such buffer as long as no data is written to it. I.e. if actual response is small only single page of RAM is used.
On 25/04/2025 11:21, Alex Peshkoff wrote:
On 4/25/25 11:46, 'Mark Rotteveel' via firebird-devel wrote:
Isn't the buffer allocation done for information requests in void rem_port::info(P_OP op, P_INFO* stuff, PACKET* sendL) (server.cpp) a bit too naive?
A client can request a buffer of up to 0xFFFE_FFFF (4,294,901,759) bytes, and the server will happily allocate that, even if the actual response will be *much* smaller.
Shouldn't this be allocated more incrementally up to the requested length?
Mark, no. Correct answer here is 'quotas'. One of them can be max size of information buffer. Without quotas we may again&again find places where client can violate normal server operation.
The point is, if I release a Jaybird version that requests information items with 0xFFFE_FFFF, that version will happily seem to work (against 64-bit servers only), but it will be slower (the Jaybird tests took 3 minutes longer),
and could randomly produce unable to allocate memory errors on connections (which may or may not be connections of that Jaybird version).
This would effectively be a form of DDoS, even though it doesn't crash the server or cause any memory corruption.
The server is too trusting that the client asks for a reasonable size.
For example
insert into some_table select * from endless_stored_procedure;
Disk space is definitely not endless, and I'm afraid it's even more dangerous than too big info buffer :(
PS. Not sure for windows - on linux no physical memory will be given to such buffer as long as no data is written to it. I.e. if actual response is small only single page of RAM is used.
I don't think that is actually true, as the buffer allocation will write 0x00 on the last byte of the buffer (though I'm not sure if that will cause all memory to be allocated or not).
But besides that, have it occur often enough concurrently will make you run out of virtual memory space (which will happen in 32-bit Firebird, even if you request something more reasonable but still overly large).
On 25/04/2025 12:01, Alex Peshkoff wrote:
On 4/25/25 12:34, 'Mark Rotteveel' via firebird-devel wrote:
The point is, if I release a Jaybird version that requests information items with 0xFFFE_FFFF, that version will happily seem to work (against 64-bit servers only), but it will be slower (the Jaybird tests took 3 minutes longer),
Do you allocate 4Gb of RAM in JayBird for buffer (if yes - is that RAM initialized by JayBird?) or just pass very big size for actually small buffer?
No, Jaybird reads the `p_resp_data`, which is sized to the actual data. This is purely the server allocating 4 GiB+ as asked by the client instead of (for example) the 60 bytes the actual response was.
(Pet peeve: it's Jaybird, not JayBird.)
3 minutes - with how long tests?
Normal tests run in about 3 minutes, and a lot of those tests do not even touch the server.
How will affect tests runtime if in parallel suggested sample with table & procedure runs?
I'm not sure what you mean with that.
The server is too trusting that the client asks for a reasonable size.
As I've already said - it's too trusting in VERY many cases.
That is no reason to not want to fix that, even if you fix/improve only one case and not all cases.
PS. Not sure for windows - on linux no physical memory will be given to such buffer as long as no data is written to it. I.e. if actual response is small only single page of RAM is used.
I don't think that is actually true, as the buffer allocation will write 0x00 on the last byte of the buffer (though I'm not sure if that will cause all memory to be allocated or not).
On linux - definitely only one page. Suppose similiar behavior on windows but can't say for sure.
As Vlad already commented, the server memsets the entire buffer to zero, so it will touch everything.
But besides that, have it occur often enough concurrently will make you run out of virtual memory space (which will happen in 32-bit Firebird, even if you request something more reasonable but still overly large).
The only known to me place where 32-bit engine is used is embedded access from old Delphi applications. Or may be someone installed not understanding own choice. And yes - I do not think we should care too much about 32 bit systems.
We release a 32-bit Firebird server, and it gets downloaded quite a lot.
For example, for Windows:
- Firebird-5.0.2.1613-0-windows-x86.exe (the installer, so likely not used for embedded) - 8132 (GitHub)
- Firebird-5.0.2.1613-0-windows-x86.zip (zip, so possibly server, possibly embedded) - 4772 (GitHub)
For comparison, 64-bit Windows 5.0.2 is 23276 (installer) and 6028 (zip).