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

Embedded engine hangs or crashes on queries that work against classic server [CORE4221] #1513

Closed
firebird-automations opened this issue Sep 18, 2013 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Gareth Marshall (garethm)

Attachments:
TEST.zip

I am using Firebird 2.5.2 Security Update 1 build 26540, 64-bit on Windows 7 64-bit. I am testing using application developed with Delphi XE2 Update 4 Hotfix 1 and IBObjects 5.2.0 Build 6. I am running my tests on Windows 7 SP1 64-bit. The same database file is used for all tests.

The database is using the UTF8 character set, and a page size of 8192 bytes. The connections are done using the UTF8 character set. The database contains just a single table with the following schema:

CREATE TABLE TEST ( NAME varchar(50) );

The table contains no data.

I generate a query that includes a number of tests ORed to each other. Each test just checks to see if the NAME field is equal to the string form of a number one larger that the one before, producing n terms in the WHERE clause.

For example, if n is 5, the following query is used:

SELECT * FROM Test T WHERE
http://T.Name = '1'
OR http://T.Name = '2'
OR http://T.Name = '3'
OR http://T.Name = '4'
OR http://T.Name = '5'

When run against classic server, I can have at most 3173 terms in the WHERE clause before the query string itself reaches a length of 65530 characters and then returns an error. This is pretty much expected behaviour.

When run using the embedded engine, I can successfully have 1052 terms in the WHERE clause. In my tests, 1053, 1054, and 1056 terms in the WHERE clause cause Firebird to hang when attempting to prepare the query (1052 terms would prepare in less than a second; after 30 seconds I killed the test for these values). Testing with 1088 or more terms causes the test application to crash with a stack overflow in the fbembed.dll. 1052 terms has a query string of length 20989 characters, while 1053 terms has a query string of length 21010.

I have not tested any other configurations.

@firebird-automations
Copy link
Collaborator Author

Commented by: Gareth Marshall (garethm)

Database file used for this test.

@firebird-automations
Copy link
Collaborator Author

Modified by: Gareth Marshall (garethm)

Attachment: TEST.zip [ 12372 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

This is not a bug but the expected behavior.

The embedded engine is a dynamic library and thus it does not have any stack settings, it's the host application that defines a stack size necessary for its execution. Standalone Firebird server (fbserver.exe and fb_inet_server.exe) use a larger than default stack size, as the engine is highly recursive during parsing. But for fbembed.dll, this is up to your application to use a large enough stack. The workable settings are 2MB for 32-bit builds and 4MB for 64-bit builds. You need to specify that value in the linker options of your Delphi.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

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

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

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

No branches or pull requests

1 participant