[PD-dev] Tips on debugging dip crashes?

Christof Ressi info at christofressi.com
Sun Feb 9 02:29:49 CET 2020


 > by applying a union used in one part of the code to another to 
replace a dereferencing cast

Type punning via pointer casts often violates the "strict aliasing 
rules" and the compiler might do wonky optimizations. Type punning via 
unions, on the other hand, is explicitly allowed in C. It is *not* 
allowed in C++, although in practice I haven't encountered a case where 
it didn't work. (The legal way to do type punning in C++ has been 
memcpy() , which gets fully optimized away; C++20 finally has 
std::bit_cast()).

You probably know this anyway. Just writing for other people who are 
reading :-)

Christof

On 09.02.2020 01:35, Dan Wilcox wrote:
> The stack trace was really not that useful, but I did look into the 
> dip-specific functions.
>
> In the end I think I fixed it, but I'm not 100% sure how. I did some 
> simple cleanup in the float sample conversion by applying a union used 
> in one part of the code to another to replace a dereferencing cast. 
> That seems to have helped, at least in my testing so far.
>
>> On Feb 8, 2020, at 12:00 PM, pd-dev-request at lists.iem.at 
>> <mailto:pd-dev-request at lists.iem.at> wrote:
>>
>> Message: 2
>> Date: Sat, 8 Feb 2020 11:06:30 +0100
>> From: Christof Ressi <info at christofressi.com 
>> <mailto:info at christofressi.com>>
>> To:pd-dev at lists.iem.at <mailto:pd-dev at lists.iem.at>
>> Subject: Re: [PD-dev] Tips on debugging dip crashes?
>> Message-ID: <99ab2074-1961-26c3-7d75-1de6067435f6 at christofressi.com 
>> <mailto:99ab2074-1961-26c3-7d75-1de6067435f6 at christofressi.com>>
>> Content-Type: text/plain; charset="windows-1252"; Format="flowed"
>>
>> Hi Dan,
>>
>> if you're accidentally writing beyond the stack, then the backtrace
>> becomes useless. You can notice this by looking at the function
>> addresses/names. If they have low addresses like 0x9 or don't show a
>> name (although Pd is built with debug symbols), than this is strong
>> indication for a stack overflow. Sometimes GDB will detect a stack 
>> overflow.
>>
>> Two things you can do: 1) set appropiate breakpoints in the debugger to
>> find out where it crashes 2) good ol' printf-debugging :-)
>>
>> I'm currently working on a complicated external and I highly appreciate
>> the visual debugging tools IDEs like QtCreator give me.
>>
>> Maybe you can post the stacktrace?
>>
>> Christof
>
> --------
> Dan Wilcox
> @danomatika <http://twitter.com/danomatika>
> danomatika.com <http://danomatika.com>
> robotcowboy.com <http://robotcowboy.com>
>
>
>
>
> _______________________________________________
> Pd-dev mailing list
> Pd-dev at lists.iem.at
> https://lists.puredata.info/listinfo/pd-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20200209/472d322b/attachment-0001.html>


More information about the Pd-dev mailing list