[user] segfault w/ error 4

Jonathan Wakely jwakely.gcc@gmail.com
Tue Sep 11 09:26:00 GMT 2012


On 11 September 2012 09:52, U.Mutlu wrote:
> U.Mutlu wrote, On 09/11/2012 10:38 AM:
>
>> Jonathan Wakely wrote, On 09/11/2012 10:29 AM:
>>>
>>> On Sep 11, 2012 9:22 AM, "U.Mutlu" <for-gmane@mutluit.com> wrote:
>>>>
>>>>
>>>> Daniel Krügler wrote, On 09/11/2012 09:07 AM:
>>>>
>>>>> 2012/9/11 U.Mutlu <for-gmane@mutluit.com>:
>>>>>>
>>>>>>
>>>>>> U.Mutlu wrote, On 09/11/2012 07:52 AM:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> There was in a function a string comparisions whereby a const
>>>>>> std::string
>>>>>> was compared against a const ptr to char ("if (s == psz) ...").
>>>>>> Not sure if that could be the reason (IMHO yes), as it indeed looked
>>>>>> ugly &
>>>>>> dangerous
>>>>>
>>>>>
>>>>>
>>>>> There should be nothing wrong with this, *unless* the pointer to char
>>>>> was a null
>>>>> pointer. basic_string has overloaded operator== with const char* as a
>>>>> single argument as
>>>>> well.
>>>>>
>>>>>> I now have replaced the char ptr by an ordinary std::string.
>>>>>> Will wait & observe what happens... :-)
>>>>>
>>>>>
>>>>>
>>>>> I would expect no difference, if the std::string is initialized with
>>>>> the same char pointer.
>>>>
>>>>
>>>>
>>>> Right you are, the crashes continue... :-(
>>>
>>>
>>> Have you tried using a debugger?
>>
>>
>> It's a daemon program, and I have only basic experience with gdb,
>> and not sure how to debug such a daemon program in gdb.
>
>
> Last year or so I had a similar hard to find bug and at that time
> I had to tell the system to generate a coredump file, and later I had
> analysed
> it in gdb. But since I haven't done it for a long time now, the steps
> escaped me,
> so I have to research how it was done... :-)

Yes, you can use a core file, but you might already have one if it's segfaulted.

Basic debugging is off-topic for this mailing list though, it would be
slightly more appropriate on the gcc-help list or a more general
programming forum.



More information about the Libstdc++ mailing list