Forums > Javascript

[Crash] deleting bpatchers through javascript – log attached

October 10, 2007 | 6:29 am

Hello,

I am getting a crash when trying to delete 1 or more bpatchers that I have dynamically created through Javascript.

MacBookPro, 2.4 GHz Core 2 Duo, OS 10.4.10, Max 4.6.3

The code is too convoluted to post, but basically I’m assigning the bpatcher’s object name to an index of an array when it is created. To delete all, I am trying to iterate through the Array.

The delete function looks like this:

function DeleteAll()
{
var i;

///"Obj_MaxName" is the name of my array
for(i = 0; i < Obj_MaxName.length; i++){

this.patcher.remove(Obj_MaxName[i]);

}
}

For some reason this function crashes every time. Admittedly, the bpatchers are pretty hefty DSP patches themselves, but this is happening even with DSP turned off.

Any help would be greatly appreciated. I have attached the log from the crashed thread below.

Thanks
Dan

Date/Time: 2007-10-09 23:19:55.586 -0700
OS Version: 10.4.10 (Build 8R2232)
Report Version: 4

Command: MaxMSP
Path: /Applications/MaxMSP 4.6/MaxMSP.app/Contents/MacOS/MaxMSP
Parent: WindowServer [70]

Version: ??? (4.6.3)

PID: 516
Thread: 0

Exception: EXC_BAD_ACCESS (0×0001)
Codes: KERN_PROTECTION_FAILURE (0×0002) at 0×00000000

Thread 0 Crashed:
0 com.cycling74.MaxJSRef 0x31744a89 JS_GetClass + 17
1 com.cycling74.jsui 0x314d38e1 js_valtoobj + 51
2 com.cycling74.jsui 0x314d3a29 jspatcher_remove + 71
3 com.cycling74.MaxJSRef 0×31773326 js_Invoke + 1744
4 com.cycling74.MaxJSRef 0x3176ff3f js_Interpret + 28723
5 com.cycling74.MaxJSRef 0x3177337f js_Invoke + 1833
6 com.cycling74.MaxJSRef 0x3177358b js_InternalInvoke + 178
7 com.cycling74.MaxJSRef 0×31746989 JS_CallFunctionName + 92
8 com.cycling74.js 0x302eff0c js_calljsfun + 1440
9 com.cycling74.js 0x302f0017 js_doanything + 67
10 com.cycling74.MaxMSP46 0×00077495 defer + 111 (defer.c:84)
11 com.cycling74.MaxMSP46 0×00077725 defer_medium + 77 (defer.c:141)
12 com.cycling74.MaxAPI 0x0180b38b defer_medium + 66
13 com.cycling74.js 0x302f03d9 js_messagehandler + 568
14 com.cycling74.js 0x302f0559 js_anything + 47
15 com.cycling74.MaxMSP46 0×00030755 typedmess_fun + 1487 (message.c:631)
16 com.cycling74.MaxMSP46 0x000e8585 outlet_anything + 355 (inletoutlet.c:967)
17 com.cycling74.MaxMSP46 0×00030755 typedmess_fun + 1487 (message.c:631)
18 com.cycling74.MaxMSP46 0x00030c96 typedmess + 80 (message.c:399)
19 com.cycling74.MaxMSP46 0x000316f4 aeval + 1242 (message.c:1061)
20 com.cycling74.MaxMSP46 0×00009750 atombuf_eval + 204 (atombuf.c:234)
21 com.cycling74.MaxMSP46 0x000b6b0d vmessage_bang(_vmessage*) + 57 (vmessage.c:58)
22 com.cycling74.MaxMSP46 0x000b83a7 vmessage_click(_vmessage*) + 439 (vmessage.c:238)
23 com.cycling74.MaxMSP46 0x0000fbe8 box_click + 148 (box.c:123)
24 com.cycling74.MaxMSP46 0x000363b4 patcher_boxclick + 436 (patcher.c:2175)
25 com.cycling74.MaxMSP46 0x000382a1 patcher_click + 1195 (patcher.c:2424)
26 com.cycling74.MaxMSP46 0x0006a7c5 wind_click + 143 (window.c:1118)
27 com.cycling74.MaxMSP46 0x0006f880 wind_event + 394 (window.c:818)
28 com.cycling74.MaxMSP46 0x0002807d app_eventhandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 1273 (main.c:1658)
29 com.apple.HIToolbox 0x92df1617 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1093
30 com.apple.HIToolbox 0x92df0cbc SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 304
31 com.apple.HIToolbox 0x92df809c SendEventToEventTarget + 56
32 com.apple.HIToolbox 0x92df852f ToolboxEventDispatcherHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 1169
33 com.apple.HIToolbox 0x92df19ce DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 2044
34 com.apple.HIToolbox 0x92df0cbc SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 304
35 com.apple.HIToolbox 0x92df809c SendEventToEventTarget + 56
36 com.apple.HIToolbox 0x92e3c013 ToolboxEventDispatcher + 81
37 com.apple.HIToolbox 0x92e3a9eb RunApplicationEventLoop + 165
38 com.cycling74.MaxMSP46 0×00027854 app_run + 52 (main.c:1519)
39 com.cycling74.MaxMSP46 0x00027afe main + 680 (main.c:416)
40 com.cycling74.MaxMSP46 0x00002ba2 _start + 216
41 com.cycling74.MaxMSP46 0x00002ac9 start + 41


October 10, 2007 | 6:25 pm

Just an update…

I was able to use this same algorithm to successfully create and delete a bunch of buttons, so I know that it *should* work in theory.

Is the problem related specifically to deleting patchers? Or is it just trying to do too much too quickly? Any ideas?

Thanks again,
Dan

Quote: doctor op wrote on Wed, 10 October 2007 00:29
—————————————————-
> Hello,
>
> I am getting a crash when trying to delete 1 or more bpatchers that I have dynamically created through Javascript.
>
> MacBookPro, 2.4 GHz Core 2 Duo, OS 10.4.10, Max 4.6.3
>
> The code is too convoluted to post, but basically I’m assigning the bpatcher’s object name to an index of an array when it is created. To delete all, I am trying to iterate through the Array.
>

—————————————————-


October 10, 2007 | 8:11 pm

Hi Dan, mostly it is hard for people to get involved when there is no patch to save, open and press a button on to reproduce your problem.

It could take quite some time to create the patch that is needed to confirm your problem, let alone say something useful about it. That is mostly a reason for people not to reply.

Posting a small patch that clearly demonstrates the problem will dramatically increase the chance for a useful answer.

Mattijs


October 10, 2007 | 8:50 pm

Yes, I’m well aware that a thorough example patch is helpful, but I was hoping to avoid it because the patch I’m working in is pretty complicated and I wasn’t able to repro the result in a more controlled patch. I was kind of hoping that with my basic description and crash log someone might have some insight. Ah well, pipe dream I suppose…

I’m not at my personal computer right now, but I’ll do some more investigating tonight and see if I can narrow it down and post a complete example patch.

Thanks
Dan

Quote: Mattijs wrote on Wed, 10 October 2007 14:11
—————————————————-
> Hi Dan, mostly it is hard for people to get involved when there is no patch to save, open and press a button on to reproduce your problem.
>
> It could take quite some time to create the patch that is needed to confirm your problem, let alone say something useful about it. That is mostly a reason for people not to reply.
>
> Posting a small patch that clearly demonstrates the problem will dramatically increase the chance for a useful answer.
>
> Mattijs
—————————————————-


October 11, 2007 | 2:56 am

OK… after some snooping on my own I think I’ve found a fix/workaround for my problem.

For what it’s worth, I believe that at least part of my problem was not recognizing the difference between the scripted name of an object (i.e. what you see when you right-click and select "Name…") and the js reference name of an object (which I believe, after some well-placed post() messages, is something like "js 120983"). Is it possible that using this.patcher.remove() and passing the scripted name as an argument would cause a crash?

In any event… problem solved. I’m a relative newbie with js but getting better all the time. Next time I post with a problem I’ll be sure to include a concise example.

Thanks
dan


Viewing 5 posts - 1 through 5 (of 5 total)