A list for the developers of CellML tools

Text archives Help


[cellml-dev] segfault in Telicems


Chronological Thread 
  • From: lpsmith at spod-central.org (Lucian Smith)
  • Subject: [cellml-dev] segfault in Telicems
  • Date: Wed, 10 Aug 2011 22:25:13 +0100

I am getting an odd segfault in Telicems when I have compiled CellML on
red hat linux to have a 32-bit runtime (-m32). I don't have the problem
at all on ubuntu.

Here's the gdb stack trace from the segfault:

(gdb) bt
#0 0x00c04919 in __gnu_cxx::__exchange_and_add(int volatile*, int) ()
from /usr/lib/libstdc++.so.6
#1 0x00be7f9e in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_M_mutate(unsigned int, unsigned int, unsigned
int) ()
from /usr/lib/libstdc++.so.6
#2 0x00be800a in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_M_replace_safe(unsigned int, unsigned int, char
const*, unsigned int) () from /usr/lib/libstdc++.so.6
#3 0x00be80a5 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::assign(char const*, unsigned int) () from
/usr/lib/libstdc++.so.6
#4 0x00be8225 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::operator=(char const*) () from
/usr/lib/libstdc++.so.6
#5 0xf78b4e32 in TeLICeMSLValue::release_storage (this=0xf78d3a88)
at /user3/lpsmith/cellml-api/TeLICeMS/sources/TeLICeMStateScan.hxx:94
#6 0xf78b4fc9 in TeLICeMSLValue::string (this=0xf78d3a88, aStr="g_init")
at /user3/lpsmith/cellml-api/TeLICeMS/sources/TeLICeMStateScan.hxx:168
#7 0xf78b427e in TeLICeMStateScan::yylex (this=0xffffceb8)
at TeLICeMS/sources/TeLICeMScan.l:286
#8 0xf789d226 in telicem_lex (aLValue=0xffffc99c, aLexer=0xffffceb8)
at /user3/lpsmith/cellml-api/TeLICeMS/sources/TeLICeMSImpl.cpp:1268
#9 0xf78bb9d9 in telicem_parse (aLexer=0xffffceb8,
aParseTarget=0xffffcf40)
at /user3/lpsmith/cellml-api/TeLICeMParse.gen.cpp:2361
#10 0xf78aa002 in CDA_TeLICeMService::parseMaths (this=0x805edc8,
aDoc=0x8060c3c, aMathText=0x8059acc L"g_init = 3 * x")
at /user3/lpsmith/cellml-api/TeLICeMS/sources/TeLICeMSImpl.cpp:102
#11 0xf7f78971 in Module::AddCellMLMathTo (this=0x8055260, formula=
Traceback (most recent call last):
File "/usr/share/gdb/python/libstdcxx/v6/printers.py", line 469, in
to_string
return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
Runtime

The 'AddCellMLMathTo' function is mine; the source code is:

RETURN_INTO_OBJREF(ts, iface::cellml_services::TeLICeMService,
CreateTeLICeMService());
std::wstring wform(makeUTF16(formula));
RETURN_INTO_OBJREF(tmr, iface::cellml_services::TeLICeMMathResult,
ts->parseMaths(doc, wform.c_str()));
// XXX it would be good to check tmr->errorMessage() and log the error -
Andrew Miller
RETURN_INTO_OBJREF(math, iface::mathml_dom::MathMLElement,
tmr->mathResult());

(the offending line is the 'RETURN_INTO_OBJREF(tmr,[...]);' bit.)

Running it through valgrind gives an error at the exact same moment, but
perhaps it's helpful:

==25453==
==25453== Process terminating with default action of signal 11 (SIGSEGV)
==25453== Bad permissions for mapped region at address 0x662D43D
==25453== at 0xC04919: __gnu_cxx::__exchange_and_add(int volatile*,
int) (in /usr/lib/libstdc++.so.6.0.8)

(and then the same back trace as gdb)

The problem seems to be, weirdly enough:

(gdb) frame 5
#5 0xf78b4e32 in TeLICeMSLValue::release_storage (this=0xf78d3a88)
at /user3/lpsmith/cellml-api/TeLICeMS/sources/TeLICeMStateScan.hxx:94
94 mString = "";

So there has to be something weird with memory management going on.

It doesn't seem to matter what string I'm asking Telicems to parse; they
all crash at the same point.

-Lucian




Archive powered by MHonArc 2.6.18.

Top of page