I am facing a very weird behaviour in Max/MSP for an external I am writing. This external contains a DSP engine with a wavetable.
The external crashes (or makes Max/MSP crash - it crashes sometimes when my external function returns to Max/MSP) with a "BAD_ACCESS" error, each time my code tries to write within the wavetable (of course, I checked the pointers, they are ok)
The strange thing is that it crashes only when the DSP engine is allocated statically within the MSP object structure
typedef struct _MaxOctos
t_pxobject ob; // the object itself (t_pxobject in MSP)
float SFreq; // Sampling frequency
TOCTOS_ENGINE Engine1; // CRASH IF I WANT TO ACCESS THE WAVETABLE IN THIS OBJECT !!!!
TOCTOS_ENGINE* Engine2; // ACCESS TO WAVETABLE WORKS (after allocation in object_alloc of course...)
If I just change the Engine definition (becoming a pointer) and allocate Engine in the new() method after object_alloc, everything works fine.
The size of the t_MaxOctos object changes from 1.5Mbytes to 40 bytes only when I use dynamic allocation, that's the only change I can see.
I would be extremely surprized that Max can not deal with a 1.5MB structure, but honnestly I can not find any explanation in my code for this (I stripped almost everything from my code, just to make sure that it crashes when I access the "big" wavetable - I even stopped the DSP processing).
However, since using dynamic allocation seems to work, I prefer to ask here if such a memory limitation exists.