Boost logo

Boost :

Subject: Re: [boost] lexical_cast crashing on solaris
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2011-03-29 04:39:14


boostman wrote:
> Hi Boost Experts
>
> Below is the code that is causing crash on solaris:
>
> entity::VecObj getData(const message::Message& msg)
> {
> entity::VecObj odfs;
> util::MyString keyStr;
>
> keyStr = _T("Test msg");
> for(size_t i=2; msg.hasKey(keyStr) ; ++i)
> {
> util::MyString mdfAlias = msg.value(keyStr);
> entity::VecObj ret = storage::byAlias(mdfAlias);
> if(ret.size())
> odfs.push_back(ret[0]);
>
> keyStr = _T("Test msg") + util::convert(util::getString(i)) + _T("]");
>
> }
> if(!odfs.size())
> throw util::Exception(util::ERROR_MDFNOTFOUND,
> util::ERROR_MDFNOTFOUND_STR);
>
> return odfs;
> }
>
> template
> std::string getString(const T& val)
> {
> std::string res("");
> try {
> res = boost::lexical_cast(val);
> } catch(bad_lexical_cast&) {
> }
>
> return res;
> }
>
> Below is the stack trace corresponding to it.
>
> ----------------- lwp# 248 / thread# 248 --------------------
> fd5c6d10 waitid (0, 4b5d, fa2faf40, 3)
> fd5b9a34 waitpid (4b5d, 0, 0, 0, 1c800, fd5f3580) + 60
> 000c76e4 void handleSignal(int) (b, 35d4, fa2fb208, fd5f4604, fd5f3580,
> 4b5d) + 114
> fd5c5924 __sighndlr (b, 0, fa2fb208, c75d0, 0, 0) + c
> fd5ba868 call_user_handler (b, 0, 12, 0, fc395000, fa2fb208) + 3b8
> fd3df5d4 void std::ios::init(std::streambuf *) (fa2fb738, 0, 45, fab18, 3,
> fd4e30a8) + a8
> fd3dfce0 std::ios::basic_ios #Nvariant 1() (fa2fb738, fd4e52b8, 103408, 0,
> fd4e30a8, 348) + 44
> fd467648 std::stringstream::basic_stringstream(int) (fa2fb6c8, c, 1e4,
> fa2fb738, fd4e800c, fd4e30a8) + 48
> fc929ec8
> boost::detail::lexical_stream<std::string,unsigned>::lexical_stream
> #Nvariant 1() (fa2fb6c8, fcb1d710, 0, fdbfff58, fd0ee26c, fd0ee830) + 10
> fc929bd0 __type_0 boost::lexical_cast<std::string,unsigned>(__type_1)
> (fa2fb7f4, 2, fa2fb7fb, fcbcbd88, 57b5040, 0) + 28
> fc925844 std::string util::getString(const __type_0&) (fa2fb89c, fa2fb8b8,
> 3, 4, 4bac880, fd0ee8f8) + 64
> fca9cf00 std::vector<boost::shared_ptr<entity::Entity>
>> operation::getData(const message::Message&) (fa2fb964, 8195784, 1a86c,
> 4288d10, 4288d10, 4288d10) + 168
>
>
> I am wondering how can this crash can happen for a very simple case of
> converting from unsigned to string using lexical cast. Any help would be
> highly appreciated.

I've noticed _T macros. Are you using wxWidgets? This macro is used if
you want to have code working for unicode and byte character strings.
Maby you use unicode characters? I don't know if it's the problem but if
you use unicode, std::string won't work. wxString will.

Regards,
Adam


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk