14 messages in com.mysql.lists.plusplusRe: MYSQL++ ThreadSafe?
FromSent OnAttachments
Rune Solem18 Dec 2000 06:55 
Arturs Aboltins18 Dec 2000 23:14 
Rune Solem19 Dec 2000 00:29 
Sander Pilon19 Dec 2000 06:33 
Sinisa Milivojevic19 Dec 2000 08:30 
Sander Pilon19 Dec 2000 09:40 
Sinisa Milivojevic19 Dec 2000 10:04 
Alex Shi19 Dec 2000 10:33 
Don Thompson19 Dec 2000 11:40 
Alex Shi19 Dec 2000 11:52 
Alex Shi19 Dec 2000 17:18 
Stonix19 Dec 2000 19:47 
Sinisa Milivojevic20 Dec 2000 03:20 
Sinisa Milivojevic20 Dec 2000 03:20 
Subject:Re: MYSQL++ ThreadSafe?
From:Sinisa Milivojevic (sin@mysql.com)
Date:12/19/2000 08:30:07 AM
List:com.mysql.lists.plusplus

Sander Pilon writes:

Is MySQL++ really threadsafe?

We're having some serious problem on an RH6.1 SMP box with MySQL++. We've tried locally compiled (egcs / v2 stdc++) and gcc 2.95.2 static linked binaries, and both crash in the same way. We've tried MySQL++ 1.7.6a and 1.7.8

It seems to work fine with single processor Debian machines though.

We get the following dumps on the redhat box:

(Note that it ALWAYS crashes on the 'Clone' line in a 'store' call, and the 'len' field in the memcpy is always unrealistically large.)

(gdb) bt #0 0x40181117 in memcpy (dstpp=0x181c73a8, srcpp=0x400f8918, len=135962008) at ../sysdeps/generic/memcpy.c:55 #1 0x400dddac in basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::Rep::clone (this=0x400f8908) at ../../../libstdc++/std/straits.h:127 #2 0x40049f1c in MysqlResUse::MysqlResUse (this=0xbf1ff7a0, result=0x40303d18, m=0x0, te=false) at /usr/include/g++-2/std/bastring.h:75 #3 0x40045b70 in MysqlConnection::store (this=0x819e968, str=@0xbf1ff6d0, throw_excptns=true) at result1.hh:158 #4 0x80ca015 in MysqlConnection::store (this=0x819e968, str=@0xbf1ff6d0) at /usr/local/include/connection1.hh:92 #5 0x80c9f12 in MysqlQuery::store (this=0xbf1ff7f0, p=@0xbf1ff8cc, r=RESET_QUERY) at /usr/local/include/query2.hh:39 #6 0x80c93c4 in MysqlQuery::store (this=0xbf1ff7f0, r=RESET_QUERY) at /usr/local/include/query1.hh:74 #7 0x807d019 in BVariablesModuleMySQL::GetSkeletonVariable (this=0x81afe20, Domain=Domain_Page, pNamespace=0x40302e78, pName=0x4030b5c8, SkeletonId=0, pPageName=0x81c21e8, LanguageID=0, ContentType=@0x403094e8, LayoutType=@0xbf1ff9c8, pLayoutGroup=@0xbf1ff9d8, LayoutPosition=@0xbf1ff9c4, IsAdvanced=@0xbf1ff9cf, IsOverridable=@0xbf1ff9ce, pDescription=@0xbf1ff9d4, pContent=@0x403094f0) at BVariablesModuleMySQL.cpp:402 #8 0x80b3e9e in CRenderer::GetVariable (this=0x8194e58, pRenRequest=0x81ab198, pNamespace=0x40302e78, pName=0x4030b5c8, Domain=@0x403094e4, ContentType=@0x403094e8, pContent=@0x403094f0) at RenderVar.cpp:148 #9 0x80a7d6d in CQTVariable::CQTVariable (this=0x403094c8, pOwner=0x8194e58, pRenRequest=0x81ab198, pVarName=0x4030df09 "value.T34t\nVariable forum.test.value: V3test.value.T102t\nVariable account.test.value: \nVariable system.test.value: \nVariable test.value:", ' ' <repeats 13 times>, "V4test.value.T34t\nVariable page.test"..., VarNameSize=5, pVarNamespace=0x4030df04 "test.value.T34t\nVariable forum.test.value: V3test.value.T102t\nVariable account.test.value: \nVariable system.test.value: \nVariable test.value:", ' ' <repeats 13 times>, "V4test.value.T34t\nVariable page"..., VarNamespaceSize=4, VarDomain=Domain_Page) at QTVariable.cpp:82 #10 0x80a0e0a in CQT::ThawVariable (this=0x40305938, pRenRequest=0x81ab198, ppCodedString=0xbf1ffb94) at Thaw.cpp:331 #11 0x809fba3 in CQT::ThawNode (this=0x40305938, pRenRequest=0x81ab198, ppCodedString=0xbf1ffb94) at Thaw.cpp:112 #12 0x809fec6 in CQT::ThawSet (this=0x40305938, pRenRequest=0x81ab198, ppCodedString=0xbf1ffb94) at Thaw.cpp:157 #13 0x809fae3 in CQT::ThawNode (this=0x40305938, pRenRequest=0x81ab198, ppCodedString=0xbf1ffb94) at Thaw.cpp:70 #14 0x809f91d in CQT::Thaw (this=0x40305938, pRenRequest=0x81ab198, pCoding=0x40303e08) at Thaw.cpp:42 #15 0x809d16f in CRenderer::Compile (this=0x8194e58, pDbSession=0x819e948, pBordRequest=0x81a1078, pNewBody=@0xbf1ffcec, pNewHeader=@0xbf1ffce8) at Renderer.cpp:293 #16 0x8059334 in CTestThread::Main (this=0x81a0c80) at test.cpp:378 #17 0x40093621 in QpThread::invoke_main () from /usr/local/lib/libqpthr.so.1 #18 0x400b7eca in pthread_start_thread (arg=0xbf1ffe60) at manager.c:213

(gdb) p q $2 = {<SQLQuery> = {<strstream> = {<strstreambase> = {<ios> = {<_ios_fields> = {_strbuf = 0x9fd2994, _tie = 0x0, _width = 0, _flags = 53, _fill = -1073744168, _state = 225 'á', _exceptions = 26 '\032', _precision = 173663060, _arrays = 0x9e2f544}, _vptr. = 0x9fd2994}, _vb.ios = 0xbf1ff8e4, __my_sb = {<streambuf> = {<_IO_FILE> = { _flags = -72548352, _IO_read_ptr = 0x40309c18 "SELECT type+0, layout_type+0, layout_group, layout_position, flags+0, description, content FROM skeleton_variables WHERE domain = 3 AND namespace = 'test' AND name = 'value' AND skeleton_id = 0 AND pa"..., _IO_read_end = 0x40309d07 "", _IO_read_base = 0x40309c18 "SELECT type+0, layout_type+0, layout_group, layout_position, flags+0, description, content FROM skeleton_variables WHERE domain = 3 AND namespace = 'test' AND name = 'value' AND skeleton_id = 0 AND pa"..., _IO_write_base = 0x40309c18 "SELECT type+0, layout_type+0, layout_group, layout_position, flags+0, description, content FROM skeleton_variables WHERE domain = 3 AND namespace = 'test' AND name = 'value' AND skeleton_id = 0 AND pa"..., _IO_write_ptr = 0x40309c18 "SELECT type+0, layout_type+0, layout_group, layout_position, flags+0, description, content FROM skeleton_variables WHERE domain = 3 AND namespace = 'test' AND name = 'value' AND skeleton_id = 0 AND pa"..., _IO_write_end = 0x40309d44 "é\003", _IO_buf_base = 0x40309c18 "SELECT type+0, layout_type+0, layout_group, layout_position, flags+0, description, content FROM skeleton_variables WHERE domain = 3 AND namespace = 'test' AND name = 'value' AND skeleton_id = 0 AND pa"..., _IO_buf_end = 0x40309d44 "é\003", _IO_save_base = 0x0, _IO_backup_base = 0x0, _IO_save_end = 0x0, _markers = 0x0, _chain = 0x0, _fileno = 1, _blksize = 1076888628, _old_offset = 1076888624, _cur_column = 0, _unused = 0 '\000', _shortbuf = "@", _lock = 0x40305b70, _offset = 4614976862099048996, _unused2 = {1074543228, 135945016, 1075901520, 136022192, 1075901540, 1074508346, 1074543228, 135876192, 135876184, 1074508346, 1074543228, 135876192, 135876184, 1076888628, 1, -1088423788}}, static _list_all = <optimized out>, _vptr. = 0x400f9100 <strstreambuf virtual table>}, _s = {_allocate_buffer = 0x400edf50 <default_alloc(unsigned int)>, _free_buffer = 0x400edf70 <default_free(void *)>}}}, <iostream> = {<istream> = {<ios> = {<_ios_fields> = { _strbuf = 0x9fd2994, _tie = 0x0, _width = 0, _flags = 91, _fill = -1073744444, _state = 225 'á', _exceptions = 26 '\032', _precision = 173845192, _arrays = 0x9e2f544}, _vptr. = 0x9fd2994}, _vb.ios = 0xbf1ff8e4, _gcount = 238}, <ostream> = {_vb.ios = 0xbf1ff8e4}, <No data fields>}, <No data fields>}, Success = true, errmsg = 0x0, parsed = {start = 0x0, finish = 0x0, end_of_storage = 0x0}, parsed_names = {start = 0x0, finish = 0x0, end_of_storage = 0x0}, parsed_nums = {t = {node_count = 0, header = 0x403006a8, key_compare = {<binary_function<basic_string<char,string_char_traits<char>,__default_alloc _template<true,0>

,basic_string<char,string_char_traits<char>,__default_alloc_template<true,0

,bool>> = {<No data fields>}, <No data fields>}}},

def = {<vector<SQLString,__default_alloc_template<true,0> >> = {start = 0x0, finish = 0x0, end_of_storage = 0x0}, parent = 0xbf1ff7f0}}, mysql = 0x819e968, throw_exceptions = true}

Hi!

It should be thread-safe, provided you do not use single Connection for each thread. You should also have built libmysqlclient to be thread safe.

You should use only gcc 2.95 with mysql++, with latest libstdc++.

However the error is quite evident in backtrace.

Your string length is 1.3 Gbytes !!

Regards,

Sinisa