Hi all,
I seem to be getting some very ugly segfaults from strange interactions between my chaos math externals (lorenz, henon, rossler).
Each external works perfectly on thier own, but if I put more than one in a patch, or changle the name of one to another in an object box I get strange values output (like + or nan) , or segfaults.
I'm just sending the henon external, the other two work just the same but with different equations.
Here is my Source: ------------------
#include "m_pd.h" #include <math.h> #include <stdlib.h>
t_class *myclass;
typedef struct thisismystruct { t_object myobj; double a,b,lx0,ly0; t_outlet *y_outlet; } mystruct;
void calculate(mystruct *x) { double lx0,ly0,lx1,ly1; double a,b;
a = x->a; b = x->b; lx0 = x->lx0; ly0 = x->ly0;
lx1 = (ly0 + 1) - (a * pow(lx0,2)); ly1 = b * lx0; x->lx0 = lx1; x->ly0 = ly1;
outlet_float(x->myobj.ob_outlet, (t_float)lx1); outlet_float(x->y_outlet, (t_float)ly1); }
void reset(mystruct *x, t_floatarg a, t_floatarg b) { x->a = (double)a; x->b = (double)b; x->lx0 = 1; x->ly0 = 1; }
void *henon_new(void) { mystruct *x = (mystruct *)pd_new(myclass); x->a = 1.4; x->b = 0.3; x->lx0 = 1; x->ly0 = 1;
outlet_new(&x->myobj, &s_float); /* Default float outlet */ x->y_outlet = outlet_new(&x->myobj, &s_float); return (void *)x; }
void henon_setup(void) { myclass = class_new(gensym("henon"), /* symname is the symbolic name */ (t_newmethod)henon_new, /* Constructor Function */ 0, /* Destructor Function */ sizeof(mystruct), /* Size of the structure */ CLASS_DEFAULT, /* Graphical Representation */ 0); /* 0 Terminates Argument List */
class_addbang(myclass, (t_method)calculate); class_addmethod(myclass,B (t_method)reset, gensym("reset"), A_DEFFLOAT, A_DEFFLOAT, 0); }
Here is my GDB Output: ----------------------
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1024 (LWP 5262)] 0x0808a0d7 in outlet_float (x=0x80e04e0, f=-0) at m_obj.c:343 343 pd_float(oc->oc_to, f); (gdb) where #0 0x0808a0d7 in outlet_float (x=0x80e04e0, f=-0) at m_obj.c:343 #1 0x400175a0 in calculate () from /usr/local/lib/pd/extra/rossler.pd_linux #2 0x0808a007 in outlet_bang (x=0x80e0288) at m_obj.c:311 #3 0x08072473 in bng_bout2 (x=0x80e01b8) at g_7_guis.c:1211 #4 0x08072681 in bng_click (x=0x80e01b8, xpos=184, ypos=115, shift=0, ctrl=0, alt=0) at g_7_guis.c:1254 #5 0x080726ce in bng_newclick (z=0x80e01b8, glist=0x80dfc00, xpix=184, ypix=115, shift=0, alt=0, dbl=0, doit=1) at g_7_guis.c:1260 #6 0x0806a54d in gobj_click (x=0x80e01b8, glist=0x80dfc00, xpix=184, ypix=115, shift=0, alt=0, dbl=0, doit=1) at g_editor.c:62 #7 0x0806b5e9 in canvas_doclick (x=0x80dfc00, xpos=184, ypos=115, which=1, mod=0, doit=1) at g_editor.c:455 #8 0x0806bd84 in canvas_mousedown (x=0x80dfc00, xpos=184, ypos=115, which=1, mod=0) at g_editor.c:606 #9 0x08089012 in pd_typedmess (x=0x80dfc00, s=0x80d41d0, argc=0, argv=0x80cb308) at m_class.c:669 #10 0x080681c7 in guiconnect_anything (x=0x80dfad8, s=0x80d41d0, ac=4, av=0x80cb2e8) at g_guiconnect.c:70 #11 0x08089218 in pd_typedmess (x=0x80dfad8, s=0x80d41d0, argc=4, argv=0x80cb2e8) at m_class.c:690 #12 0x0808c984 in binbuf_eval (x=0x80de808, target=0x80dfad8, argc=0, argv=0x0) at m_binbuf.c:570 #13 0x08091ca4 in socketreceiver_read (x=0x80de828, fd=8) at s_inter.c:307 #14 0x0809164a in sys_domicrosleep (microsec=0, pollem=1) at s_inter.c:144 #15 0x08092815 in sys_pollgui () at s_inter.c:732 #16 0x0808fee6 in m_scheduler (nodacs=0) at m_sched.c:441 #17 0x080904f9 in sys_main (argc=1, argv=0xbffff7e4) at s_main.c:258 #18 0x08094356 in main (argc=1, argv=0xbffff7e4) at s_entry.c:9 #19 0x4007a9ed in __libc_start_main () from /lib/libc.so.6
Thanks for your help, I would appriciate any help/pointers anyone would provide.
Thanks Ben
B. Bogart ---------