http://rpg.hamsterrepublic.com/bugzilla/show_bug.cgi?id=929

Ralph Versteegen <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #2 from Ralph Versteegen <[email protected]> 2011-09-10 05:53:36 
PDT ---
Whoooa there. Those verbose stack traces aren't all the useful, I've almost
never actually bothered to look at them. I always look at the regular
non-verbose stack trace instead.

However in this case, the stack trace is entirely useless because all the local
variables contain only garbage, and the program counter doesn't actually point
at any line of code. Looks like the stack frame is bad for some reason, not
sure what's going on.

--- Comment #3 from Ralph Versteegen <[email protected]> 2011-09-11 11:35:00 
PDT ---
Ok, fixed.

Using gdb, I found that the seg fault looked exactly like a stack overflow, and
noticed that SUB battle allocates lots of memory on the stack (65KB). However,
an infinitely recursing function only overflows the stack after using 1MB (or
maybe the default value was 2MB). It was obvious that there was something about
virtual memory which I didn't understand, so I downloaded a program to inspect
the memory map (VMMap, which is awesome!), which solved the mystery. Turns out
that on Windows, program stacks are reserved but not committed, meaning part of
the virtual address space is reserved, but no (virtual) pages are mapped.
Instead, a 4KB guard page is placed at the top (well, bottom, since the stack
grows downwards) of the stack, and writing to that page causes another 4KB page
to be committed. I believe committed pages require space to be reserved in the
page file and other resources (but no memory until they're actually
read/written to). Not clear on that. Just a week ago, I was looking at the
source for alloca, and didn't understand why it wrote a byte per 4KB allocated;
now I do. Turns out that compilers normally do so (called stack probing, eg.
/Gs option for Visual C++) for functions that allocate more than 4KB of stack
space, but FB doesn't.

-- 
Configure bugmail: 
http://rpg.hamsterrepublic.com/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Ohrrpgce mailing list
[email protected]
http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org

Reply via email to