Crash diagnostics

Ian Monroe ian.monroe at gmail.com
Fri Mar 20 13:58:25 CET 2009


2009/3/20 Jeff Mitchell <mitchell at kde.org>:
> If any of you guys can see what might be going wrong here, please let me
> know.  The crash takes place in the destructor of a KEncodingProber
> object allocated on the stack, in the line "delete encoding".  Here are
> the places "encoding" is used:
>
>
> In declaration of KEncodingProberPrivate:
> const char * encoding;
>
> In constructor:
> KEncodingProberPrivate(): encoding(strdup("")) ......
>
> In destructor of KEncodingProberPrivate:
> delete encoding;  <- crash
>
> In function KEncodingProberPrivate::unicodeTest:
> encoding = "UTF-8";
> encoding = "ISO-10646-UCS-4";
> (a few other similar assignments...these all depend on the cases in a
> switch)
> ...(then, later in the same function)...
> if (encoding && strlen(encoding))
> //stuff
>
>
> I've gone through the code and ensured that encoding is only ever
> deleted in the private class destructor, so it's not a double free.  One
> thing I noticed is that it's a const char pointer, and most of those
> assignments it is being assigned to pre-defined character strings,
> except for the initialization which is setting it to a strdup.  If
> nothing else, that could end up being a memory leak if it eventually is
> assigned to a different string and that original strdup-provided string
> goes into the ether.  But that shouldn't cause a crash.
>
> Anyone have ideas?
> --Jeff

Have you been able to replicate the crash?

Ian


More information about the Amarok-devel mailing list