Re: DBD::ODBC: crash in ping (after disconnect)
Jeff Urlwin wrote: That's probably the best thing, but there are probably more places... After reviewing the code, I think I don't like the duplication of the henv -- but the short term patch is whenever you see a SQLFreeEnv, also set the imp_dbh-henv to SQL_NULL_ENV. Sorry I haven't looked at better than that, but that resolves it for me. I've patched my svn copy and committed. I've also patched my t\05meth.t to add your tests. Can you use the svn source to test? Yes, and it works: D:\prj\DBD-ODBC\trunkperl -w -Mblib t\05meth.t Using D:/prj/DBD-ODBC/trunk/blib 1..13 ok 1 - use DBI; ok 2 - delete prepared statement ok 3 - Number of rows 0 ok 4 - Number of rows from DBI matches sth ok 5 - finished and rolled back ok 6 - no error ok 7 - ? ok 8 - ?? ok 9 - Active ok 10 - ping ok 11 - disconnect ok 12 - Active ok 13 - ping Steffen
Re: DBD::ODBC: crash in ping (after disconnect)
Steffen Goeldner wrote: O.k., attached. Looks like SQLError receives a freed SQL_HANDLE_ENV. Not sure, but I think I fixed the problem. In dbd_db_login6, I found: imp_dbh-henv = imp_drh-henv; /* needed for dbd_error */ In dbd_db_disconnect, I found: imp_drh-henv = SQL_NULL_HENV; and added imp_dbh-henv = SQL_NULL_HENV; At least my test script no longer crashes. Steffen
Re: DBD::ODBC: crash in ping (after disconnect)
Martin J. Evans wrote: Caught a SIGSEGV at C:/opt/perl/site/lib/DBD/ODBC.pm line 208 That is the tables call in the ping method. The only time you only have an environment handle dbd_error: err_rc=-1 rc=0 s/d/e: 0/0/21631648 is when not connected to the DSN. The driver manager is supposed to handle this. How can ping be called when there is no connection? i.e. the 0 for s/d. My test script explicitly calls ping after disconnect. Surely, a normal application may accept that the 'handle is of little use after disconnecting'. But hey, it's a test script: it's purpose is to ask for trouble. Perhaps an ODBC trace would be useful. You can turn this on from the ODBC driver manager tracing tab. O.k., attached. Looks like SQLError receives a freed SQL_HANDLE_ENV. Steffen perl 02cxn e64-d44 ENTER SQLAllocHandle SQLSMALLINT 1 SQL_HANDLE_ENV SQLHANDLE SQLHANDLE * 013B744C perl 02cxn e64-d44 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 1 SQL_HANDLE_ENV SQLHANDLE SQLHANDLE * 0x013B744C ( 0x014a1540) perl 02cxn e64-d44 ENTER SQLSetEnvAttr SQLHENV 014A1540 SQLINTEGER 200 SQL_ATTR_ODBC_VERSION SQLPOINTER 0x0003 SQLINTEGER -6 perl 02cxn e64-d44 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS) SQLHENV 014A1540 SQLINTEGER 200 SQL_ATTR_ODBC_VERSION SQLPOINTER 0x0003 (BADMEM) SQLINTEGER -6 perl 02cxn e64-d44 ENTER SQLAllocHandle SQLSMALLINT 2 SQL_HANDLE_DBC SQLHANDLE 014A1540 SQLHANDLE * 013B5474 perl 02cxn e64-d44 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS) SQLSMALLINT 2 SQL_HANDLE_DBC SQLHANDLE 014A1540 SQLHANDLE * 0x013B5474 ( 0x014a15e8) perl 02cxn e64-d44 ENTER SQLDriverConnectW HDBC014A15E8 HWND WCHAR * 0x1F7A9D2C [ -3] **\ 0 SWORD -3 WCHAR * 0x1F7A9D2C SWORD2 SWORD * 0x UWORD0 SQL_DRIVER_NOPROMPT perl 02cxn e64-d44 EXIT SQLDriverConnectW with return code -1 (SQL_ERROR) HDBC014A15E8 HWND WCHAR * 0x1F7A9D2C [ -3] **\ 0 SWORD -3 WCHAR * 0x1F7A9D2C SWORD2 SWORD * 0x UWORD0 SQL_DRIVER_NOPROMPT DIAG [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) DIAG [01S00] [Microsoft][ODBC Driver Manager] Invalid connection string attribute (0) perl 02cxn e64-d44 ENTER SQLErrorW HENV014A1540 HDBC014A15E8 HSTMT WCHAR * 0x0012ED04 (NYI) SDWORD *0x0012EF40 WCHAR * 0x0012E904 SWORD 511 SWORD * 0x0012EF46 perl 02cxn e64-d44 EXIT SQLErrorW with return code 0 (SQL_SUCCESS) HENV014A1540 HDBC014A15E8 HSTMT WCHAR * 0x0012ED04 (NYI) SDWORD *0x0012EF40 (0) WCHAR * 0x0012E904 [ 91] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified SWORD 511 SWORD * 0x0012EF46 (91) perl 02cxn e64-d44 ENTER SQLErrorW HENV014A1540 HDBC014A15E8 HSTMT WCHAR * 0x0012ED04 (NYI) SDWORD *0x0012EF40 WCHAR * 0x0012E904 SWORD 511 SWORD * 0x0012EF46 perl 02cxn e64-d44 EXIT SQLErrorW with return code 0 (SQL_SUCCESS) HENV014A1540 HDBC014A15E8
RE: DBD::ODBC: crash in ping (after disconnect)
Hi, Caught a SIGSEGV at C:/opt/perl/site/lib/DBD/ODBC.pm line 208 That is the tables call in the ping method. The only time you only have an environment handle dbd_error: err_rc=-1 rc=0 s/d/e: 0/0/21631648 is when not connected to the DSN. The driver manager is supposed to handle this. How can ping be called when there is no connection? i.e. the 0 for s/d. Perhaps an ODBC trace would be useful. You can turn this on from the ODBC driver manager tracing tab. BTW, your code works for me to MS SQL Server dsn but from older DBI/DBD::ODBC. Martin On 19-Jan-2005 Steffen Goeldner wrote: Hi Jeff, I have the following test script: use sigtrap; use DBI(); use Test::More tests = 5; my $dbh = DBI-connect or die $DBI::errstr; ok( $dbh-{$_}, $_) for 'Active'; ok( $dbh- $_ , $_) for 'ping'; ok( $dbh- $_ , $_) for 'disconnect'; ok(!$dbh-{$_}, $_) for 'Active'; ok(!$dbh- $_ , $_) for 'ping';; which I run (accidentally) with DBI_DSN=dbi:ODBC:test and got ok 1 - Active ok 2 - ping ok 3 - disconnect ok 4 - Active Caught a SIGSEGV at C:/opt/perl/site/lib/DBD/ODBC.pm line 208 The trace shows dbd_error: err_rc=-1 rc=0 s/d/e: 0/0/21631648 First I thought SQLError() doesn't like the NULL handles for hdbc and hstmt, but I see dbd_error2() 'climbs up the tree' anyway. Do you have any ideas? My platform: Windows 2000 perl 5.6.1 DBD::ODBC 1.13 DBI 1.46 Full trace attached. Steffen -- Martin J. Evans Easysoft Ltd, UK Development