Forums > MaxMSP

Stack overflow

August 1, 2008 | 8:36 am

I’m working on a large patch where I want to make colls out of a large cellblock using a coll which describes the rows and columns to put in the coll.

It uses a counter to go to the next columnnumber, and also a counter to go to the next row number.
So basically it should do this:

Get first row -> Get first column -> Get second column -> etc. -> Put in coll at index 1 -> Go to next row.
Get second row -> Get first column -> Get second column -> etc. -> Put in coll at index 2 -> Go to next row.

But, if I don’t put a delay somewhere in the ‘loop’, it get’s a stack overflow after going performing four rows.

Does this mean without the delay it’s an actual loop MAX can’t handle?

With a delay of 0.00001ms it works fine, but is pretty slow when I want values from say 1000 rows. Using deferlow instead makes it even slower…

Can anybody please give advice?

Kind regards,
Bas


August 1, 2008 | 9:51 am

its difficult to give u an answer without seeing the patch…

but from what you describe, i would start by looking at what happens at the 3/4th row – just before the stack overflow.

have u tried trace?


August 1, 2008 | 10:43 am

Hello Justin,

Thanks for your reply.
Between the 3rd and 4th nothing different happens than between the others before.

I can’t send the patch (working for a company, can’t reveal too much).

What do you mean with trace?
I did use the debugger to monitor what happens.
My guess is that MAX sees it as a loop.
So the question is: How can I use a counter to perform the same thing as often as needed, but that waits with the next count till the current is completed.

Bas


August 1, 2008 | 10:50 am


August 1, 2008 | 11:10 am

Bas wrote:
> I can’t send the patch (working for a company, can’t reveal too much).
>

Finding a stack overflow in a patch you can’t see is kinda tricky you know.
Isolating this part of the patch and replacing jit.cellblock datas
shouldn’t reveal much.


August 1, 2008 | 1:04 pm

I understand it’s hard to help without seeing it.
I tried to make it as abstract as possible, and found some interesting situations.

Please take a look at it. I hope someone can explain why the message box from example 1 causes a stack overflow.
And why the counters can cause a stack overflow after like 300 cycles.

I think this is what going wrong in the patch I’m making as well.

Emmanuel, could you post a small example of a counter with a bunch of triggers?

Kind regards,
Bas


August 1, 2008 | 1:12 pm

ps. Sent the wrong file…

Found out ‘zl reg’ instead of a message box works as well. (see example 6)

But with a counter it still doesn’t work…


August 1, 2008 | 2:16 pm

Oops…does not work after all…

Only without zl reg or ‘storing in a message box and banging later’ it does not give a stack overflow…

Does anyone have an idea how to ‘prepare’ a value and bang it later without having a stack overflow.

Please don’t use the older files, they contain a double line to the counter.


August 1, 2008 | 2:17 pm


August 1, 2008 | 3:11 pm

In many cases, the stack overflow is caused by asking Max to complete too many operations too quickly (such as recursive counters).

What is sometimes confusing is if you write a test patch that runs the counter a dozen or so times, and the patch works. But when you substitute real data, you get a stack overflow.

The stack overflow can be avoided using a deferlow object. See the attached patch (but please recognize that the version to the left offers no exit…)

– Pasted Max Patch, click to expand. –


kjg
August 2, 2008 | 1:31 pm

Quote: BasS wrote on Fri, 01 August 2008 10:36
—————————————————-

> So basically it should do this:
>
> Get first row -> Get first column -> Get second column -> etc. -> Put in coll at index 1 -> Go to next row.
> Get second row -> Get first column -> Get second column -> etc. -> Put in coll at index 2 -> Go to next row.

Like this? Or am I not understanding you?

with kind regards,
klaas-jan govaart

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 51 52 33 196617 dump;
#P newex 51 414 43 196617 route 0;
#P newex 109 484 76 196617 prepend merge;
#P newex 109 460 44 196617 pack i s;
#P newex 84 436 60 196617 unpack i i s;
#N coll iflower;
#P newobj 109 508 62 196617 coll iflower;
#P user jit.cellblock 51 71 953 392 3 9 11 15 80 20 0 1 1 1 1 1 1 1 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 1;
#X set 0 1 A;
#X set 0 2 B;
#X set 0 3 C;
#X set 0 4 D;
#X set 0 5 E;
#X set 0 6 F;
#X set 0 7 G;
#X set 0 8 H;
#X set 0 9 I;
#X set 0 10 J;
#X set 0 11 K;
#X set 0 12 L;
#X set 0 13 M;
#X set 0 14 N;
#X set 1 0 Dogs;
#X set 1 1 Alopekis;
#X set 1 2 Beagle;
#X set 1 3 Chow;
#X set 1 4 Dalmatian;
#X set 1 5 Elkhound;
#X set 1 6 Foxhound;
#X set 1 7 Greyhound;
#X set 1 8 Harrier;
#X set 1 9 Irish;
#X set 1 10 Jindo;
#X set 1 11 Kuvasz;
#X set 1 12 Lhasa;
#X set 1 13 Mastiff;
#X set 1 14 Newfoundland;
#X set 2 0 Cats;
#X set 2 1 Asian;
#X set 2 2 Burmese;
#X set 2 3 Ceylon;
#X set 2 4 Devon Rex;
#X set 2 5 Egyptian Mau;
#X set 2 6 Foldex;
#X set 2 7 Gao;
#X set 2 8 Himalayan;
#X set 2 9 Irish Shorthair;
#X set 2 10 Javanese;
#X set 2 11 Korat;
#X set 2 12 LaPerm;
#X set 2 13 Malayan;
#X set 2 14 Nebelung;
#X set 3 0 Cars;
#X set 3 1 Acura;
#X set 3 2 Buick;
#X set 3 3 Cadillac;
#X set 3 4 Datsun;
#X set 3 5 Edsel;
#X set 3 6 Ford;
#X set 3 7 Geo;
#X set 3 8 Hummer;
#X set 3 9 Isuzu;
#X set 3 10 Jeep;
#X set 3 11 Kia;
#X set 3 12 Lincoln;
#X set 3 13 Mitsubishi;
#X set 3 14 Nash;
#X set 4 0 Seinfelds;
#X set 4 1 Ada;
#X set 4 2 Bania;
#X set 4 3 Cosmo;
#X set 4 4 Deena;
#X set 4 5 Elaine;
#X set 4 6 Frank;
#X set 4 7 George;
#X set 4 8 Haffler;
#X set 4 9 Izzy;
#X set 4 10 Jerry;
#X set 4 11 Klompas;
#X set 4 12 Leo;
#X set 4 13 Mulva;
#X set 4 14 Newman;
#X set 5 0 Drinks;
#X set 5 1 Absinthe;
#X set 5 2 Bourbon;
#X set 5 3 Cuba Libre;
#X set 5 4 Daiquiri;
#X set 5 5 English Rose;
#X set 5 6 Floradora;
#X set 5 7 Gibson;
#X set 5 8 Hurricane;
#X set 5 9 Irish Coffee;
#X set 5 10 John Collins;
#X set 5 11 Knickerbocker;
#X set 5 12 Limeade;
#X set 5 13 Martini;
#X set 5 14 Negroni;
#X set 6 0 Countries;
#X set 6 1 Albania;
#X set 6 2 Belgium;
#X set 6 3 Costa Rica;
#X set 6 4 Denmark;
#X set 6 5 England;
#X set 6 6 France;
#X set 6 7 Germany;
#X set 6 8 Honduras;
#X set 6 9 Italy;
#X set 6 10 Japan;
#X set 6 11 Korea;
#X set 6 12 Liberia;
#X set 6 13 Mexico;
#X set 6 14 Norway;
#X set 7 0 Synths;
#X set 7 1 Akai;
#X set 7 2 Buchla;
#X set 7 3 Crumar;
#X set 7 4 Digisound;
#X set 7 5 EMS;
#X set 7 6 Fairlight;
#X set 7 7 GDS;
#X set 7 8 Hammond;
#X set 7 9 iSynth;
#X set 7 10 Jen;
#X set 7 11 Kurzweil;
#X set 7 12 Linn;
#X set 7 13 Moog;
#X set 7 14 Novation;
#X set 8 0 Objects;
#X set 8 1 abs;
#X set 8 2 bag;
#X set 8 3 coll;
#X set 8 4 detonate;
#X set 8 5 env;
#X set 8 6 filepath;
#X set 8 7 gate;
#X set 8 8 hint;
#X set 8 9 iter;
#X set 8 10 jit.matrix;
#X set 8 11 kslider;
#X set 8 12 lcd;
#X set 8 13 menubar;
#X set 8 14 notein;
#X set 9 0 Jobs;
#X set 9 1 Architect;
#X set 9 2 Brick Layer;
#X set 9 3 Coal Shoveler;
#X set 9 4 Draftsman;
#X set 9 5 Educator;
#X set 9 6 Financier;
#X set 9 7 Grip;
#X set 9 8 Health Worker;
#X set 9 9 Investigator;
#X set 9 10 Janitor;
#X set 9 11 Keyer;
#X set 9 12 Lawyer;
#X set 9 13 Mechanic;
#X set 9 14 Netter;
#X set 10 0 TV;
#X set 10 1 Alf;
#X set 10 2 Buffy;
#X set 10 3 Chandler;
#X set 10 4 Dick;
#X set 10 5 Elmer;
#X set 10 6 Floyd;
#X set 10 7 Gilligan;
#X set 10 8 Harvey;
#X set 10 9 Incredible Hulk;
#X set 10 10 Jeannie;
#X set 10 11 Kate;
#X set 10 12 Larry;
#X set 10 13 Malcolm;
#X set 10 14 Norm;
#P connect 6 0 0 0;
#P connect 0 0 5 0;
#P connect 5 1 2 0;
#P connect 2 1 3 0;
#P connect 3 0 4 0;
#P connect 4 0 1 0;
#P connect 2 2 3 1;


August 4, 2008 | 8:25 am

Thanks for the example Arne. I can definetely use that. I tried to use deferlow, but not in this way.

Klaas-Jan, thanks as well. It’s partially what I meant. This is a nice way to get a cellblock in a coll, which I need as well.
But I sometimes also need to get a specific row range and columns in a coll.

Like:
Row 1: Columns 1, 2, 4, 6
Row 2: Columns 2, 4, 6, 7
etc.

But I think I can make it work now.

Thanks for the help!

Bas



kjg
August 4, 2008 | 11:07 am

Quote: BasS wrote on Mon, 04 August 2008 10:25
—————————————————-

> t’s partially what I meant. This is a nice way to get a cellblock in a coll, which I need as well.
> But I sometimes also need to get a specific row range and columns in a coll.
>
> Like:
> Row 1: Columns 1, 2, 4, 6
> Row 2: Columns 2, 4, 6, 7
> etc.

I see. You can lookup specific values after dumping in coll, or straight from jit.cellblock.

good luck with the project.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 324 468 29 196617 t l 1;
#P button 34 32 15 0;
#P newex 34 61 49 196617 t dump 0;
#P newex 234 530 29 196617 gate;
#P window linecount 2;
#P comment 538 447 100 196617 or just lookup in jit.cellblock;
#B color 6;
#P window linecount 1;
#P newex 537 536 51 196617 zl ecils 1;
#P newex 537 558 47 196617 zl iter 1;
#P comment 606 495 111 196617 row 2 index 1 2 4 & 6;
#P comment 595 479 111 196617 row 1 index 1 2 4 & 6;
#P newex 537 514 37 196617 zl rev;
#P message 549 495 52 196617 2 2 4 6 7;
#B color 6;
#P message 537 478 52 196617 1 1 2 4 6;
#B color 6;
#P newex 537 580 42 196617 pack i i;
#P newex 293 651 38 196617 zl join;
#P newex 324 624 51 196617 zl slice 1;
#P newex 234 563 51 196617 print cell;
#B color 6;
#P newex 293 672 51 196617 print coll;
#B color 5;
#N coll iflower;
#P newobj 324 599 62 196617 coll iflower;
#P newex 324 511 51 196617 zl ecils 1;
#P newex 324 533 47 196617 zl iter 1;
#P comment 393 444 111 196617 row 2 index 1 2 4 & 6;
#P comment 382 428 111 196617 row 1 index 1 2 4 & 6;
#P newex 324 489 37 196617 zl rev;
#P message 336 444 52 196617 2 2 4 6 7;
#B color 5;
#P message 324 427 52 196617 1 1 2 4 6;
#B color 5;
#P newex 324 555 42 196617 pack i i;
#P message 324 577 54 196617 nth $2 $1;
#P newex 34 428 43 196617 route 0;
#P newex 92 498 76 196617 prepend merge;
#P newex 92 474 44 196617 pack i s;
#P newex 67 450 60 196617 unpack i i s;
#N coll iflower;
#P newobj 92 522 62 196617 coll iflower;
#P user jit.cellblock 34 94 936 415 3 9 11 15 80 20 0 1 1 1 1 1 1 1 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 1;
#X set 0 1 A;
#X set 0 2 B;
#X set 0 3 C;
#X set 0 4 D;
#X set 0 5 E;
#X set 0 6 F;
#X set 0 7 G;
#X set 0 8 H;
#X set 0 9 I;
#X set 0 10 J;
#X set 0 11 K;
#X set 0 12 L;
#X set 0 13 M;
#X set 0 14 N;
#X set 1 0 Dogs;
#X set 1 1 Alopekis;
#X set 1 2 Beagle;
#X set 1 3 Chow;
#X set 1 4 Dalmatian;
#X set 1 5 Elkhound;
#X set 1 6 Foxhound;
#X set 1 7 Greyhound;
#X set 1 8 Harrier;
#X set 1 9 Irish;
#X set 1 10 Jindo;
#X set 1 11 Kuvasz;
#X set 1 12 Lhasa;
#X set 1 13 Mastiff;
#X set 1 14 Newfoundland;
#X set 2 0 Cats;
#X set 2 1 Asian;
#X set 2 2 Burmese;
#X set 2 3 Ceylon;
#X set 2 4 Devon Rex;
#X set 2 5 Egyptian Mau;
#X set 2 6 Foldex;
#X set 2 7 Gao;
#X set 2 8 Himalayan;
#X set 2 9 Irish Shorthair;
#X set 2 10 Javanese;
#X set 2 11 Korat;
#X set 2 12 LaPerm;
#X set 2 13 Malayan;
#X set 2 14 Nebelung;
#X set 3 0 Cars;
#X set 3 1 Acura;
#X set 3 2 Buick;
#X set 3 3 Cadillac;
#X set 3 4 Datsun;
#X set 3 5 Edsel;
#X set 3 6 Ford;
#X set 3 7 Geo;
#X set 3 8 Hummer;
#X set 3 9 Isuzu;
#X set 3 10 Jeep;
#X set 3 11 Kia;
#X set 3 12 Lincoln;
#X set 3 13 Mitsubishi;
#X set 3 14 Nash;
#X set 4 0 Seinfelds;
#X set 4 1 Ada;
#X set 4 2 Bania;
#X set 4 3 Cosmo;
#X set 4 4 Deena;
#X set 4 5 Elaine;
#X set 4 6 Frank;
#X set 4 7 George;
#X set 4 8 Haffler;
#X set 4 9 Izzy;
#X set 4 10 Jerry;
#X set 4 11 Klompas;
#X set 4 12 Leo;
#X set 4 13 Mulva;
#X set 4 14 Newman;
#X set 5 0 Drinks;
#X set 5 1 Absinthe;
#X set 5 2 Bourbon;
#X set 5 3 Cuba Libre;
#X set 5 4 Daiquiri;
#X set 5 5 English Rose;
#X set 5 6 Floradora;
#X set 5 7 Gibson;
#X set 5 8 Hurricane;
#X set 5 9 Irish Coffee;
#X set 5 10 John Collins;
#X set 5 11 Knickerbocker;
#X set 5 12 Limeade;
#X set 5 13 Martini;
#X set 5 14 Negroni;
#X set 6 0 Countries;
#X set 6 1 Albania;
#X set 6 2 Belgium;
#X set 6 3 Costa Rica;
#X set 6 4 Denmark;
#X set 6 5 England;
#X set 6 6 France;
#X set 6 7 Germany;
#X set 6 8 Honduras;
#X set 6 9 Italy;
#X set 6 10 Japan;
#X set 6 11 Korea;
#X set 6 12 Liberia;
#X set 6 13 Mexico;
#X set 6 14 Norway;
#X set 7 0 Synths;
#X set 7 1 Akai;
#X set 7 2 Buchla;
#X set 7 3 Crumar;
#X set 7 4 Digisound;
#X set 7 5 EMS;
#X set 7 6 Fairlight;
#X set 7 7 GDS;
#X set 7 8 Hammond;
#X set 7 9 iSynth;
#X set 7 10 Jen;
#X set 7 11 Kurzweil;
#X set 7 12 Linn;
#X set 7 13 Moog;
#X set 7 14 Novation;
#X set 8 0 Objects;
#X set 8 1 abs;
#X set 8 2 bag;
#X set 8 3 coll;
#X set 8 4 detonate;
#X set 8 5 env;
#X set 8 6 filepath;
#X set 8 7 gate;
#X set 8 8 hint;
#X set 8 9 iter;
#X set 8 10 jit.matrix;
#X set 8 11 kslider;
#X set 8 12 lcd;
#X set 8 13 menubar;
#X set 8 14 notein;
#X set 9 0 Jobs;
#X set 9 1 Architect;
#X set 9 2 Brick Layer;
#X set 9 3 Coal Shoveler;
#X set 9 4 Draftsman;
#X set 9 5 Educator;
#X set 9 6 Financier;
#X set 9 7 Grip;
#X set 9 8 Health Worker;
#X set 9 9 Investigator;
#X set 9 10 Janitor;
#X set 9 11 Keyer;
#X set 9 12 Lawyer;
#X set 9 13 Mechanic;
#X set 9 14 Netter;
#X set 10 0 TV;
#X set 10 1 Alf;
#X set 10 2 Buffy;
#X set 10 3 Chandler;
#X set 10 4 Dick;
#X set 10 5 Elmer;
#X set 10 6 Floyd;
#X set 10 7 Gilligan;
#X set 10 8 Harvey;
#X set 10 9 Incredible Hulk;
#X set 10 10 Jeannie;
#X set 10 11 Kate;
#X set 10 12 Larry;
#X set 10 13 Malcolm;
#X set 10 14 Norm;
#P window linecount 2;
#P comment 88 60 100 196617 dump into coll first , then lookup in coll;
#B color 5;
#P connect 32 0 31 0;
#P connect 31 0 1 0;
#P fasten 21 0 1 0 542 607 938 607 938 90 39 90;
#P connect 1 0 6 0;
#P connect 6 1 3 0;
#P connect 3 1 4 0;
#P connect 4 0 5 0;
#P connect 5 0 2 0;
#P connect 3 2 4 1;
#P connect 33 1 30 0;
#P connect 31 1 30 0;
#P connect 30 0 18 0;
#P connect 1 0 30 1;
#P connect 8 0 20 0;
#P connect 20 0 17 0;
#P connect 19 1 20 1;
#P connect 10 0 33 0;
#P connect 9 0 33 0;
#P connect 33 0 11 0;
#P connect 11 0 15 0;
#P connect 15 0 14 0;
#P connect 14 0 8 0;
#P connect 8 0 7 0;
#P connect 7 0 16 0;
#P connect 16 0 19 0;
#P connect 15 1 8 1;
#P connect 22 0 24 0;
#P connect 23 0 24 0;
#P connect 24 0 28 0;
#P connect 28 0 27 0;
#P connect 27 0 21 0;
#P connect 28 1 21 1;


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