not getting past object_new

TristanShepherd's icon

c external compiles, uses a framework (libsamplerate.dylib)

here's the crash report and the _new routine

confused!? maybe don't understand enough about the crash report??? or how objects are created in max?

void *resamp_new(t_symbol *s, long outchns)
{
    int i, c, error;
    t_resamp *x = (t_resamp *)newobject(resamp_class);

    dsp_setup((t_pxobject *)x, 1);
    //intin((t_object *)x,1);

    outchns=1;
    x->outchns = outchns;
    for(i=0; i
        outlet_new((t_object *)x, "signal");

    x->l_sym = s;
    x->sr = sys_getsr();
    x->r_sr = 1.0/x->sr;

    x->ptr = 0;
    x->pos = 0;
    x->ratio = 0.8;
    x->numout = 0;
    x->frames = 0;
    x->loop = x->stop = 0;

    x->src_state = src_new(1, outchns, &error);

    x->out_buf = (float **)malloc(2 * sizeof(float *));

    for(c=0; c
        x->out_buf[c] = (float *)malloc((200*30.0+100)*sizeof(float));

    x->in_buf = (float *)malloc(200 * sizeof(float *));
    return (x);
}

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000030
Crashed Thread: 0

Thread 0 Crashed:
0 com.cycling74.MaxMSP     0x000b7190 class_obexoffset_get + 6
1 com.cycling74.MaxMSP     0x000b7fe4 object_obex_get + 26
2 com.cycling74.MaxMSP     0x000b8041 object_obex_lookup + 39
3 com.cycling74.MaxAPI     0x00f0fc64 object_obex_lookup + 45
4 com.cycling74.MaxAudioAPI     0x1520cce4 z_dsp_setup + 68
5 com.cycling74.resamp~     0x00da8d9b resamp_new + 51 (resamp~.c:300)

AlexHarker's icon

Hmmm. You should probably post your object structure and your main routine here.

The crash is in class_obexoffset_get, which should not be crashing if you have set up your object correctly.
You are calling newobject, which is the old-style method, as opposed to using object_alloc after setting up your object with class_setup / class_addmethod / class_dspinit and class_register in your main routine.

In max 4 land there were a set of routines for setting up objects (setup addmess etc.). Later came the obex routines (as described above). In max 5 I think it is considered preferable to use obex routines, although the old ones still work. The two methods don't mix, so without seeing main it's impossible to tell if you've matched the two parts correctly.

You might also want to check:

1 - That the first structure in your object is a t_pxobject.
2 - That any attribute stuff is correct (if there is any - in which case you'll need the obex style routines)
3 - That you have properly setup (and possibly registered) your class

Beyond that I don't think we can help without the main routine and object structure.

HTH

A.