function return causing crash

Feb 2, 2009 at 3:18am

function return causing crash

Max 5.0.5, OS X 10.5.6

I’ve created a function to read textfiles (essentially the example js
with a few tweaks for my purpose). Since I need to parse a few
different textfile formats I’d like to save some maintenance hassle and
use the same readfile() for all of them.

To that end, i have this (pseudocode for now):

function readfile(filepath) {
…stuff happens…
…an array of lines is built…
return array_of_lines;
}
local = 1;

Unfortunately, if the return is passing more than ~2068 characters
(whether in string or array form) Max will definitely crash. Commenting
out the return avoids the crash.

Report looks like this:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000075206f78
Crashed Thread: 0
Thread 0 Crashed:
0 com.cycling74.MaxMSP 0x00146db6 postrow_refname + 14
1 com.cycling74.MaxMSP 0x0014800c object_poststring + 76
2 com.cycling74.MaxAPI 0x01d420ac object_poststring + 50
3 com.cycling74.js 0x03b5d45a js_dopost + 866

Question 1: Why does this happen? Is this problem documented anywhere?
My searches turned up only
http://www.cycling74.com/forums/index.php?t=msg&goto=147230&rid=0&S=c1f2e71f8a06518dcaeab505db04303b
and

http://www.cycling74.com/forums/index.php?t=msg&th=18847&start=0&rid=0&S=5495c64239f7796de411065cf2f38c1b

Question 2: Chunking is an ugly “solution,” not to mention a slightly
complicated one in this case. Would creating a bunch of objects to
populate a sort of ad-hoc collection work? I’m going to have to
maintain this thing so I’d like some sort of unfragmented concept. On
the other hand, if someone knows off the top of their head that creating
a bunch of objects will strike the same invisible wall, I’d like to save
myself the trouble.

Thanks!

Jon

#42051
Feb 5, 2009 at 12:50am

dlurk wrote:
> function readfile(filepath) {
> …stuff happens…
> …an array of lines is built…
> return array_of_lines;
> }
> local = 1;
>
> Unfortunately, if the return is passing more than ~2068 characters
> (whether in string or array form) Max will definitely crash. Commenting
> out the return avoids the crash.

Well, it’s all in a big monolithic function now and so it works. I’d
still like to know whether passing large (?) objects between functions
*within js* is guaranteed to fail or whether there’s something more
subtle afoot.

Thanks for any info/feedback!

Jon

#150239

You must be logged in to reply to this topic.