Subject | Example code for segfault |
---|---|
Author | Brad Pepers |
Post date | 2003-10-24T21:14:54Z |
Attached is a very short example program for the segfault problem with
FirebirdCS-1.5.0.3780-RC6 on Redhat 9. All it does is create a database
given the sysdba passed on the command line. I compiled it using:
g++ -c -Wall fb_test.cpp
This gave no errors or warnings. I then link it with:
g++ -o fb_test fb_test.o -lgds -lqt-mt
I know the qt-mt isn't really needed since the code doesn't even use Qt but
its there to show the problem. When you link it as I've done above you can
run the program as "./fb_test password" replacing password with the sysdba
password on your system and it will create a database called "test.fdb". Now
if you re-link the program like this:
g++ -o fb_test fb_test.o -lqt-mt -lgds
Run the program again and it will segfault even though nothing of qt-mt is
even used in the code! If you run it with gdb you will see the segfault
happens in ParsedPath::~ParsedPath and hopefully this will make the problem
easier to track down!
Here is the program:
#include <ibase.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char** argv)
{
char command[1024];
sprintf(command, "create database 'test.fdb' user 'sysdba' "
"password '%s' page_size 4096;", argv[1]);
ISC_STATUS status[20];
isc_db_handle db = 0L;
isc_tr_handle trans = 0L;
isc_dsql_execute_immediate(status, &db, &trans, 0, command,
SQL_DIALECT_V6, NULL);
if (status[0] == 1 && status[1]) {
isc_print_status(status);
exit(1);
}
isc_detach_database(status, &db);
return 0;
}
Thats it!
--
Brad Pepers
brad@...
FirebirdCS-1.5.0.3780-RC6 on Redhat 9. All it does is create a database
given the sysdba passed on the command line. I compiled it using:
g++ -c -Wall fb_test.cpp
This gave no errors or warnings. I then link it with:
g++ -o fb_test fb_test.o -lgds -lqt-mt
I know the qt-mt isn't really needed since the code doesn't even use Qt but
its there to show the problem. When you link it as I've done above you can
run the program as "./fb_test password" replacing password with the sysdba
password on your system and it will create a database called "test.fdb". Now
if you re-link the program like this:
g++ -o fb_test fb_test.o -lqt-mt -lgds
Run the program again and it will segfault even though nothing of qt-mt is
even used in the code! If you run it with gdb you will see the segfault
happens in ParsedPath::~ParsedPath and hopefully this will make the problem
easier to track down!
Here is the program:
#include <ibase.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char** argv)
{
char command[1024];
sprintf(command, "create database 'test.fdb' user 'sysdba' "
"password '%s' page_size 4096;", argv[1]);
ISC_STATUS status[20];
isc_db_handle db = 0L;
isc_tr_handle trans = 0L;
isc_dsql_execute_immediate(status, &db, &trans, 0, command,
SQL_DIALECT_V6, NULL);
if (status[0] == 1 && status[1]) {
isc_print_status(status);
exit(1);
}
isc_detach_database(status, &db);
return 0;
}
Thats it!
--
Brad Pepers
brad@...