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

a call to isc_create_database may crash the program when using fbembed.dll [CORE1966] #2404

Closed
firebird-automations opened this issue Jun 26, 2008 · 6 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Vincent Schmid (biscotte)

I have created a program that just loads fbembed.dll, make a call to isc_create_database with minimal parameters and unloads the dll. The program almost always crashes under Windows XP SP2, although it seems to work on Vista.
This program was made as an atempt to find why my application crashed when using isc_dsql_execute_immediate to create a database. I decided to check whether it would crash with isc_create_database and this is the case. The test program is written in Delphi, I give it below in case it is useful.
The program crashes after the call to FreeLibrary returns, as it just has time to show the dialog which says "done" before disappearing.

var isc_create_database: function(user_status: Pointer; file_length: Smallint;
file_name: PChar; handle: Pointer; dpb_length: Smallint; dpb: PChar;
db_type: Smallint): longint; stdcall;
procedure TForm2.Button1Click(Sender: TObject);
var FileName:string;
StatusVector:longint;
DBHandle:PPointer;
GDS32Lib:cardinal;
errcode:integer;
begin
FileName := 'c:\test1\test.fdb';
DeleteFile(FileName);
DBHandle := nil;
GDS32Lib := LoadLibrary('c:\test1\fbembed.dll');
try
isc_create_database := GetProcAddress(GDS32Lib, 'isc_create_database');
if not assigned(isc_create_database) then
raise exception.create('isc_create_database = nil');
errcode := isc_create_database(@StatusVector, Length(FileName), PChar(FileName), @DBHandle, 0, nil, 0);
if errcode <> 0 then raise exception.create('error ' + inttostr(errcode));
finally
sleep(1000); // when we sleep for 1 second the program does not crashes...
FreeLibrary(GDS32Lib);
end;
MessageDlg('done', mtInformation, [mbok], 0);
end;

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

You see yourself - it's not isc_create_database() who crashes embedded server, but unload of dynamically loaded library. This is fixed in 2.5, but in 2.1 - please do not use LoadLibrary() to work with ebmedded library, instead link it with your application.

@firebird-automations
Copy link
Collaborator Author

Commented by: prenosil (prenosil)

* status vector must be defined as
StatusVector:array[0..19] of longint;
* you should also call
isc_detach_database(...)

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Not a bug.

@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 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Vincent Schmid (biscotte)

Thank you all,
That's right, my demo code is wrong as Ivan has reported. Once corrected, however, the problem remains.

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