[LLVMdev] Invalid or unaligned stack

Reid Kleckner rnk at google.com
Mon Mar 30 16:15:23 PDT 2015

See r227426 from Clang. setjmp on Win64 is really weird. There is a hidden
second parameter that you may need to fill in with @llvm.frameaddress.

On Mon, Mar 30, 2015 at 3:59 PM, Dibyendu Majumdar <mobile at majumdar.org.uk>

> Hi,
> I am encountering a problem that I do not know how to debug. I would
> greatly appreciate any guidance on this issue.
> On Windows when I run Lua test cases from JITed code I am getting
> following error:
> Unhandled exception at 0x00007FFCEEEAC500 (ntdll.dll) in lua.exe:
> 0xC0000028: An invalid or unaligned stack was encountered during an
> unwind operation.
> This is happening when the Lua code is attempting to call longjmp().
> The Lua test case that triggers this is a recursive call as shown below.
> function err_on_n (n)
>   if n==0 then error(); exit(1);
>   else err_on_n (n-1); exit(1);
>   end
> end
> do
>   function dummy (n)
>     if n > 0 then
>       assert(not pcall(err_on_n, n))
>       dummy(n-1)
>     end
>   end
> end
> dummy(10)
> I have a struct that is created on the stack in the JIT compiler, and
> this error is triggered when I add a field to the struct - if I remove
> the field the error stops. The struct is not very large in size - it
> is only 392 bytes with the new field.
> If I allocate this struct on the heap the error goes away.
> Note that just adding the field triggers the error even if I have no
> other code changes.
> The error occurs in Release build but not in Debug build.
> I am using Visual C++ 2013 - 64-bit, and LLVM 3.6.0 on Windows.
> I see no other unexpected behaviour - all the other tests pass.
> All tests pass on Ubuntu, using LLVM 3.5.1 and gcc 4.8.2.
> Of course I am currently assuming that somewhere my program is
> corrupting memory - but as I have no other signs of a memory
> corruption - the issue may be something else.
> Any tips on what the problem might be would be gratefully received.
> Thanks and Regards
> Dibyendu
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150330/a4bba2b7/attachment.html>

More information about the llvm-dev mailing list