bizstation / transactd

The high-speed and advanced NoSQL interface plugin for MySQL / MariaDB.
GNU General Public License v2.0
18 stars 1 forks source link

Example (exs_update_table_def) becomes segmentation fault. #2

Closed kjdev closed 11 years ago

kjdev commented 11 years ago

Example exs_update_table_def becomes segmentation fault.

Build

Can not build the remains of exs_update_table_def.

exp.cpp:64:16: error: expected initializer before 'onCopyData'
 void __stdcall onCopyData(database* db, int recordCount, int count, bool &cancel)
exp.cpp: In function 'int main(int, char**)':
exp.cpp:85:35: error: 'onCopyData' was not declared in this scope
                 db->setOnCopyData(onCopyData);

Build Change to void __STDCALL onCopyData from void __stdcall onCopyData.

Execute

Segmentation fault when run.

(gdb) r
Program received signal SIGSEGV, Segmentation fault.
bzs::db::protocol::tdap::client::dbdef::updateTableDef (this=0x63f050, TableIndex=-22568)
    at /path/to/transactd/source/bzs/db/protocol/tdap/client/dbDef.cpp:214
214         td->optionFlags.bitA = false; // reset valiable type

No problem in the other samples.

bizstation commented 11 years ago

Hi, kjdev. Thank you for reporting.

We have confirmed the problem, and fix sample some codes. These fix will be included in next release which will be done today. In addition, the sample page of SDK documents have been fixed already.

The cause of this segmentation fault is that : When insert key or fields to tabledef, realloc will be called. At this time, there is a possibility that the memory address of the tabledef is changed. To avoid this problem, we have been should use tableDefPtr instead of tableDefs. (But this way can be used by C++ only. Other languages can not use the way.)

The good way is that do not cache tabledef into the variable.

Regards, Kosaka@BizStation

kjdev commented 11 years ago

Thanks, Kosaka.

I was able to confirm that the sample code to work properly all.