[PD-dev] [PD] Fwd: external help, please

IOhannes m zmölnig zmoelnig at iem.at
Sun Feb 25 10:45:19 CET 2018


On 02/25/2018 09:54 AM, Alexandre Torres Porres wrote:
> 2018-02-23 13:02 GMT-03:00 Alexandre Torres Porres <porres at gmail.com>:
> 
> 
> Well, it got hard again. I actually needed an extra main signal inlet, so,
> when I added it, I managed to make it work and build and stuff... but now,
> if I  change the number of channels (that is, if I recreate the object with
> a different argument), Pd can freeze or blow up... so I screwed it somehow.
> Here's the code:
> https://github.com/porres/pd-else/blob/master/classes/mtx~.c - I don't know
> if it's something to do with the "free" method, or something inside the
> "dsp" method, that's all I can think but I've also already done all I could
> take a wild guess on.
> 


you probably should learn how to use a debugger (other than pd-list or
stackoverflow; don't get me wrong - both are valuable resources when it
comes to debugging non-trivial things, but there are tools out there
that allow you to automate the hunt for more trivial things).

#1 printf debugging.
your code crashes? add printf() statements (or "post()" for that
matter). to monitor which lines are reached (and which not, and to print
the values (esp. of pointers) to see whether they are not what you expect.
since a crash of Pd will take down the Pd-console, it's usually not a
good idea to put any crash-debugging printout there.
instead, start Pd from the cmdline with the "-stderr" flag.

#2 valgrind
your code crashes? more often than not this is due to memory corruption.
valgrind makes it easy to see where you have access violations.
it's also super-easy to use, just add "valgrind" before the actual
command when starting from the cmdline.

#3 gdb
your code crashes? or does something bonkers? gdb to the rescue!
gdb can be a tricky beast, and there is much to learn, but even if you
only use the "backtrace" feature, you get at least an idea which line
causes the crash (which can help tremendously).
two things to keep in mind:
a) you must compile the code to be debugged with "-g", so the debugging
symbols don't get stripped away.
for whatever reasons, the pd-lib-builder Makefile doesn't set this by
default (most likely size- or speed-constraints; there was some
discussion, i don't remember the details), unless you build with "make
alldebug"
b) you should run Pd with "-nrt" inside the debugger, unless you want a
stream of "watchdog: signaling Pd" message to garble all your output.

fgamdsr
IOhannes


PS: is there any specific reason to post on both pd-dev and pd-list?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20180225/f1c64e96/attachment.sig>


More information about the Pd-dev mailing list