<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div apple-content-edited="true"><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks for the advice on the setup function. &nbsp;I spent a few hours debugging and seemed to have fixed the problem. &nbsp;Though it is still mysterious to me why the memory corruption was happening the way it did, I traced it down to how I had declared my C++ object. &nbsp;Initially, I had declared my object in a single function and sent data to the Pd class struct. &nbsp;Such as: &nbsp;</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">static myObject n; &nbsp;</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">x-&gt;someInt = n.someFunction();</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">&nbsp; I moved my C++ object declaration to the Pd class struct as a pointer then allocated its memory in the _new() function and deallocating in the _free() function. &nbsp;</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">&nbsp; This seems to have cleaned up the memory from my C++ object, since I need the initial instance of the object to last the lifetime of the Pd object. &nbsp;Though oddly, this didn't work the first time, I also had to do the same procedure with a std::vector&lt;double&gt; declaration too. &nbsp;Since then the error has not occurred again. &nbsp;Below is my class struct now. &nbsp;</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">&nbsp; Not sure why declaring my C++ object or the vector as a pointer is necessary but clearly it worked.</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks again for everyone's help. &nbsp;</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #bb2ca2">static</span> <span style="color: #78492a">t_class</span> *rhynamo_class;</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; <span style="color: #bb2ca2">typedef</span> <span style="color: #bb2ca2">struct</span> _rhynamo {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4f8187">t_object</span>&nbsp; x_obj;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #78492a">t_clock</span> &nbsp; *x_clock;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #78492a">t_outlet</span> *l_out;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #703daa">std</span>::<span style="color: #703daa">vector</span>&lt;<span style="color: #bb2ca2">double</span>&gt; *delay;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4f8187">_attributes</span> A;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #bb2ca2">int</span> x_hit;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #bb2ca2">int</span> x_increment;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #bb2ca2">double</span> x_delay;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #4f8187">Rhythm</span> *rhythm;</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; } t_rhynamo;</div></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">&nbsp;&nbsp;</div>
</div>
<br><div><div>On Feb 28, 2014, at 8:45 AM, Charles Z Henry &lt;<a href="mailto:czhenry@gmail.com">czhenry@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">You can make these changes (one from IOhannes and two of my suggestions in-line below) and see if the error is gone.&nbsp; My guess is: probably not.&nbsp; I didn't see any glaring problems that would cause memory corruption.&nbsp; <br>
<br>Could you also show us your rhynamo_set(symbol, float) function?&nbsp; Does the error occur *only* after the set function gets used?&nbsp; <br><div><br>If for some reason, these small changes do fix your issue, just back up and make one change at a time, and check if you can reproduce the error each time.&nbsp; I'd be interested to know what actually causes it.<br>
<div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 27, 2014 at 6:13 PM, GCC <span dir="ltr">&lt;<a href="mailto:robert@urbanstew.org" target="_blank">robert@urbanstew.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-size:14px;font-family:Calibri,sans-serif;word-wrap:break-word"><div style="font-family:Consolas;font-size:medium"><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">Below is my setup method. &nbsp;This object generates rhythmic phrases so it accesses the time scheduler in Pd as per the code [metro] or [delay], and outputs a bang. &nbsp;Perhaps this could be where it goes wrong? &nbsp;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; Thanks for your time and help. &nbsp;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">-Rob</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">-----------&nbsp;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color:#bb2ca2">void</span> rhynamo_setup(<span style="color:#bb2ca2">void</span>) {</div><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#4f8187">rhynamo_class</span> = <span style="color:#31595d">class_new</span>(<span style="color:#31595d">gensym</span>(<span style="color:#d12f1b">"rhynamo"</span>),</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (<span style="color:#4f8187">t_newmethod</span>)<span style="color:#31595d">rhynamo_new</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (<span style="color:#4f8187">t_method</span>)<span style="color:#31595d">delay_free</span>, <span style="color:#bb2ca2">sizeof</span>(<span style="color:#4f8187">t_rhynamo</span>),</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#78492a">CLASS_DEFAULT</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#31595d">A_GIMME</span>, <span style="color:#272ad8">0</span>);</div><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(209, 47, 27); "><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#31595d">post</span><span style="">(</span>"[rhynamo] a rhythmic generator v .02 : by Robert Esler 2014"<span style="">);</span></div><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#78492a">class_addbang</span>&nbsp; (<span style="color:#4f8187">rhynamo_class</span>, <span style="color:#31595d">rhynamo_bang</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(79, 129, 135); "><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#78492a">class_addfloat</span><span style="">(</span>rhynamo_class<span style="">, (</span>t_method<span style="">)</span><span style="color:#31595d">rhynamo_generate</span><span style="">);</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(79, 129, 135); "><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#78492a">class_addsymbol</span><span style="">(</span>rhynamo_class<span style="">, (</span>t_method<span style="">)</span><span style="color:#31595d">rhynamo_set</span><span style="">);</span></div>
</div></div></blockquote><div><br></div><div>^--I don't think you need the addsymbol line.&nbsp; The rhynamo_set function access is provided by the next addmethod line, immediately below.<br></div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-size:14px;font-family:Calibri,sans-serif;word-wrap:break-word"><div style="font-family:Consolas;font-size:medium"><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(49, 89, 93); "><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>class_addmethod<span style="">(</span><span style="color:#4f8187">rhynamo_class</span><span style="">,</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (<span style="color:#4f8187">t_method</span>)<span style="color:#31595d">rhynamo_set</span>, <span style="color:#31595d">gensym</span>(<span style="color:#d12f1b">"set"</span>), <span style="color:#78492a">A_DEFSYMBOL</span>, <span style="color:#31595d">A_DEFFLOAT</span>, <span style="color:#272ad8">0</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(49, 89, 93); "><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>class_addmethod<span style="">(</span><span style="color:#4f8187">rhynamo_class</span><span style="">,</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (<span style="color:#4f8187">t_method</span>)<span style="color:#31595d">rhynamo_generate</span>, <span style="color:#31595d">gensym</span>(<span style="color:#d12f1b">"generate"</span>), <span style="color:#31595d">A_FLOAT</span>, <span style="color:#272ad8">0</span>);</div>
</div></div></blockquote><div><br></div><div>^--This line should have A_DEFFLOAT instead of A_FLOAT.<br></div><div><br><br>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-size:14px;font-family:Calibri,sans-serif;word-wrap:break-word"><div style="font-family:Consolas;font-size:medium"><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(49, 89, 93); "><span style="">&nbsp; &nbsp; &nbsp; &nbsp; </span>class_sethelpsymbol<span style="">(</span><span style="color:#4f8187">rhynamo_class</span><span style="">, </span>gensym<span style="">(</span><span style="color:#d12f1b">"help-rhynamo"</span><span style="">));</span></div><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; }</div><div>-------------</div></div><div style="font-family:Consolas;font-size:medium"><br></div><div style="font-family:Consolas;font-size:medium">Date: Thu, 27 Feb 2014 14:15:05 -0600</div>
<div style="font-family:Consolas;font-size:medium">From: Charles Z Henry &lt;<a href="mailto:czhenry@gmail.com" target="_blank">czhenry@gmail.com</a>&gt;</div><div style="font-family:Consolas;font-size:medium">Subject: Re: [PD] Strange behavior using custom external</div>
<div style="font-family:Consolas;font-size:medium">To: Robert Esler &lt;<a href="mailto:robert@urbanstew.org" target="_blank">robert@urbanstew.org</a>&gt;</div><div style="font-family:Consolas;font-size:medium">Cc: pd-list &lt;<a href="mailto:pd-list@iem.at" target="_blank">pd-list@iem.at</a>&gt;</div>
<div style="font-family:Consolas;font-size:medium">Message-ID:</div><div style="font-family:Consolas;font-size:medium"><span style="white-space:pre-wrap">        </span>&lt;<a href="mailto:CAPfmNOFA_cprs4Ux0Yg1YY7hFsgrpt79B+FeLj5kzf1FRD0R4Q@mail.gmail.com" target="_blank">CAPfmNOFA_cprs4Ux0Yg1YY7hFsgrpt79B+FeLj5kzf1FRD0R4Q@mail.gmail.com</a>&gt;</div>
<div style="font-family:Consolas;font-size:medium">Content-Type: text/plain; charset="utf-8"</div><div class=""><div style="font-family:Consolas;font-size:medium"><br></div><div style="font-family:Consolas;font-size:medium">
The difference probably indicates that something is going on in your</div><div style="font-family:Consolas;font-size:medium">_setup() function.&nbsp;&nbsp;Once you've loaded a class in a patch, it stays in</div><div style="font-family:Consolas;font-size:medium">
memory.&nbsp;&nbsp;If you close the patch, and open another patch without the class,</div><div style="font-family:Consolas;font-size:medium">you may still see the effects---but if you close pd, and reopen without</div><div style="font-family:Consolas;font-size:medium">
using the class, you should not see the effects at all.</div><div style="font-family:Consolas;font-size:medium"><br></div><div style="font-family:Consolas;font-size:medium">The backtrace shows a seg fault from calls in "binbuf_eval", which is the</div>
<div style="font-family:Consolas;font-size:medium">code related to parsing and loading a patch.&nbsp;&nbsp;You might just have passed a</div><div style="font-family:Consolas;font-size:medium">struct as an argument, where it's expected to be an element of that struct.</div>
<div style="font-family:Consolas;font-size:medium"><br></div><div style="font-family:Consolas;font-size:medium">Although.... pointer type mismatches will definitely throw a compiler</div><div style="font-family:Consolas;font-size:medium">
warning you should have seen already.&nbsp;&nbsp;Would you post the _setup() function?</div><div style="font-family:Consolas;font-size:medium"><br></div><div style="font-family:Consolas;font-size:medium">Chuck</div></div></div>

</blockquote></div><br></div></div></div></div>
</blockquote></div><br></body></html>