[R-sig-DB] sqlUpdate causing crash with RODBC

Tomoaki NISHIYAMA tomo@k|n @end|ng |rom kenroku@k@n@z@w@-u@@c@jp
Wed May 4 06:48:33 CEST 2011


Hi,

>    (void)SQLFreeStmt(thisHandle->hStmt, SQL_RESET_PARAMS);
>    (void)SQLFreeHandle(SQL_HANDLE_STMT, thisHandle->hStmt);

This is very strange code. SQLFreeStmt is superseded by SQLFreeHandle in ODBC v3 and 
should not be used simultaneously. They are for the same purpose and may cause 
double free. Furthermore, the code contains SQLAllocHandle but not SQLAllocStmt.
So, there is no justification to use SQLFreeStmt.

You might test with just one
	SQLFreeHandle(SQL_HANDLE_STMT, thisHandle->hStmt);

-- 
Tomoaki NISHIYAMA

Advanced Science Research Center,
Kanazawa University,
13-1 Takara-machi, 
Kanazawa, 920-0934, Japan


On 2011/05/04, at 4:34, Harlan Harris wrote:

> Hi all,
> 
> I'm trying to get writing/updates to an Oracle 10g database to work via
> RODBC on Mac OSX. I've confirmed that I can write SQL and use sqlQuery to
> update a simple table, but when I try to do the equivalent with sqlUpdate, R
> crashes hard.
> 
> The testone table has two columns: id is a number (and primary key), and
> asdf is a varchar2(40).
> 
> When I do this:
> sqlUpdate(hdl, data.frame(id=4, asdf='zoom'), 'testone', verbose=TRUE,
> test=TRUE)
> 
> I get a segfault and the following stack trace:
> 
> Process:         R [8486]
> Path:            /Applications/R64.app/Contents/MacOS/R
> Identifier:      org.R-project.R
> Version:         R 2.12.2 GUI 1.36 Leopard build 64-bit (5691)
> Code Type:       X86-64 (Native)
> Parent Process:  launchd [153]
> 
> Date/Time:       2011-05-03 15:15:08.360 -0400
> OS Version:      Mac OS X 10.6.6 (10J567)
> Report Version:  6
> 
> Interval Since Last Report:          173376 sec
> Crashes Since Last Report:           5
> Per-App Interval Since Last Report:  184150 sec
> Per-App Crashes Since Last Report:   2
> Anonymous UUID:                      C49D451E-9024-4368-9216-C5DE32F331B0
> 
> Exception Type:  EXC_CRASH (SIGABRT)
> Exception Codes: 0x0000000000000000, 0x0000000000000000
> Crashed Thread:  0  Dispatch queue: com.apple.main-thread
> 
> Application Specific Information:
> abort() called
> 
> Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
> 0   libSystem.B.dylib                 0x00007fff81287616 __kill + 10
> 1   libSystem.B.dylib                 0x00007fff81327cca abort + 83
> 2   libSystem.B.dylib                 0x00007fff8123f6f5 free + 128
> 3   atoradb.so                        0x000000010234c021 SQLFreeEnv + 501
> 4   atoradb.so                        0x000000010234c175 SQLFreeStmt + 71
> 5   RODBC.so                          0x000000010111c698
> SQLFreeStmt_Internal + 305
> 6   RODBC.so                          0x000000010111d2fb SQLFreeStmt + 312
> 7   RODBC.so                          0x00000001011066f2 RODBCUpdate + 194
> (RODBC.c:1184)
> 8   libR.dylib                        0x000000010011a5b1 do_dotcall + 16145
> (dotcode.c:857)
> 
> Looking at RODBC.c, it's crashing assigning a NULL:
> 
>    /* free the buffers */
>    cachenbind_free(thisHandle);
>    (void)SQLFreeStmt(thisHandle->hStmt, SQL_RESET_PARAMS);
>    (void)SQLFreeHandle(SQL_HANDLE_STMT, thisHandle->hStmt);
>    thisHandle->hStmt = NULL;
>    return ScalarInteger(stat);
> 
> Has anyone seen this before?
> 
> Note that if I take out the test=TRUE, it still crashes, and the database is
> not updated.
> 
> -Harlan
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-DB mailing list -- R Special Interest Group
> R-sig-DB using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
> 




More information about the R-sig-DB mailing list