# Stack level too deep when parsing xml

**URL:** <https://www.ruby-forum.com/t/stack-level-too-deep-when-parsing-xml/109376>\
**Category:** Rails\
**Created:** [July 13, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-when-parsing-xml/109376 "2007-07-13T21:00:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkitchel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@dkitchel](https://www.ruby-forum.com/u/dkitchel)\
**Post date:** [July 13, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-when-parsing-xml/109376/1 "2007-07-13T21:00:04Z")

</div>

I’m trying to figure out why I’m getting a stack level too deep error.  
I have controller which parses xml (about 1400 lines) and ingests it  
into mysql. First I was getting a system stack error every time, but  
then I found the ulimit -s command which allows me to raise it from 8mb  
to 64mb. That solved the problem I thought,

But now, I can parse the xml once, but when I do it for a second time, I  
get the stack level too deep error. If I quit the server (mongrel) and  
restart it using the script/server call, something resets and lets me do  
the xml parsing once again. But only once.

is something getting clogged up? Do I need to clear the stack level  
somehow?

It’s not an infinite loop, just a long xml file.

---

<div class="post-metadata">

**Author:** ![dkitchel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@dkitchel](https://www.ruby-forum.com/u/dkitchel)\
**Post date:** [July 13, 2007, 9:15pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-when-parsing-xml/109376/2 "2007-07-13T21:15:36Z")

</div>

On 7/13/07, Davis K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> restart it using the script/server call, something resets and lets me do  
> the xml parsing once again. But only once.
> 
> is something getting clogged up? Do I need to clear the stack level  
> somehow?
> 
> It’s not an infinite loop, just a long xml file.

Sounds like you have something, maybe a variable, that references  
itself causing an infinite recursion? Maybe it gets defined the first  
time around, so it’s not recursive until the second time? Just a  
guess.

Chris

---

<div class="post-metadata">

**Author:** ![dkitchel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@dkitchel](https://www.ruby-forum.com/u/dkitchel)\
**Post date:** [July 13, 2007, 9:40pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-when-parsing-xml/109376/3 "2007-07-13T21:40:20Z")

</div>

snacktime wrote:

> On 7/13/07, Davis K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > restart it using the script/server call, something resets and lets me do  
> > the xml parsing once again. But only once.
> > 
> > is something getting clogged up? Do I need to clear the stack level  
> > somehow?
> > 
> > It’s not an infinite loop, just a long xml file.
> 
> Sounds like you have something, maybe a variable, that references  
> itself causing an infinite recursion? Maybe it gets defined the first  
> time around, so it’s not recursive until the second time? Just a  
> guess.
> 
> Chris

Nope, that’s not it. If I take out the @database.save line which  
creates the sql insert statements, I can run it as many times as I like  
no problem. Somehow 1400 sql insert statements brings rails to it’s  
knees and it cant recover without a restart. This can’t be true? There  
must be a solution? Rails must be able to handle this? No?

---

<div class="post-metadata">

**Author:** ![dkitchel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ba0ec/32.png) [@dkitchel](https://www.ruby-forum.com/u/dkitchel)\
**Post date:** [July 13, 2007, 9:58pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-when-parsing-xml/109376/4 "2007-07-13T21:58:43Z")

</div>

Strangely enough I got that error in an app with - in a foldername and  
then changed to \_ and the error did go away.

2007/7/13, Davis K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> restart it using the script/server call, something resets and lets me do
> 
> >

## –

Andreas Kviby  
Telefon 070-352 66 76  
E-post removed\_email\_address@domain.invalid
