We have been getting this error nonstop lately:

pbx.c: Maximum PBX stack exceeded

We think it is because we have too many outbound routes, parking lots, IVR’s, etc on Freepbx being included and exceeding the asterisk 128 include limit. Now I know we could just switch to having another server but we have a pretty good dedicated server currently with SSHD’s, ample memory, and we have it working great (besides the stack error).

Do you think we could increase the AST_PBX_MAX_STACK limit to 256 without asterisk blowing up, assuming the server could handle the added processing and memory use. Can you think of any issues that might happen as a result of it?

You could probably increase it, but I think understanding the root cause of it would be wiser. That message is output if you exceed 128 includes deep or other searches. Are you actually doing that?

1 Like

I don’t think so but I am not sure how to check and make sure it is not in some type of loop either. Is there some way I can check or do a stack trace?

I think Freepbx generates a dial plan that is about 4-5 deep then it has TONS of includes on that level, it exceeds 128. I wonder if I could add an “echo” somewhere to see if its repeating something…

There’s nothing really to do exactly that. A “dialplan show” will show you what is used given an extension and context… but not how it got there.

1 Like

I read a little on stacks:

Also looked up the stack size on my linux ((kbytes) 8192).

It sounds like stacks in Asterisk is a data object that fills up with objects (extensions, contexts, something) until it reaches the 128 (kbyte?) limit then rejects any further objects. A max stack error means I have reached the 128 (kbyte?) maximum stack size. Am I on the right track?

The stack that LInux is talking about is part of the machine architecture. Exceeding that will probably give you a segmentation violation (although, with threads, you may just overwrite another stack).

I think the stack that Asterisk is talking about is another case of the general concept I think the limit is 128 entries. I haven’t looked at the details, but those entries might be pointers to data structures or arbitrary size.