[LLVMdev] alloca on Win32

Anton Korobeynikov asl at math.spbu.ru
Sun Jun 24 14:00:13 PDT 2007


Hello, Scott.

> Is that generally dangerous, or should it be OK?
Well, in general, it's dangerous, because you should probe the stack on
windows, if you'll allocate more than 4k. This is needed to let guard
pages be allocated in proper order. 

So, you can see random crashes here and there now :) For example: try to
allocate big array (>4k of size) and touch its last element (this should
be in the second page) without touching somewhere in the beginning (to
be in the first page). It'll crash fast.

> I tried to fix the alloca resolution, as it does appear the same thing
> will happen once there's > 4k on the stack as you mentioned (mingw
> hacking or no).
As I've mentioned, it's not mingw-special stuff, it's windows-special :(

> I wasn't able to understand where lli was doing the hooking you
> describe though. Once I have some larger functions, I'll dig in more
> deeply (or if someone points me at it...). 
It's in lib/System/Win32/DynamicLibrary.inc 
I'd suggest you to check, whether vcpp stack probing routine and _alloca
has the same signature. If yes - we can easily fix the code emission.
Otherwise we'll need extra information about chkstk.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.





More information about the llvm-dev mailing list