Jérôme Couture-Gagnon
2012-Apr-12 21:02 UTC
[LLVMdev] Support for "foreign" Visual Studio 64 bits C++ exceptions?
Hi, We are currently porting our application to Windows 64 bits (amd64), and we are getting regressions from 32 bits relatively to LLVM 3.0's ability to get traversed by "foreign" Visual Studio C++ exceptions. That is, there is a crash when C++ exceptions which are thrown from Visual Studio code, are unwinding through LLVM code before being eventually catch by other Visual Studio code (more details below). I am not an expert on the subject of exceptions, however I was not able to find clear answers about this specific issue. Should it be supported, and if not, is there is any planned effort from the LLVM team to work on this? Note that we are not using the LLVM3.0 exception API (launchingPad with personality routine). In fact, this leads to another related question: is there even a "personality routine" available when compiling with Visual Studio? From what I read it looks like this would require support for Windows' SEH, which is not implemented yet. Any news or plans on that front? SEH was mentionned in the design discussion of LLVM3.0's exception API, without mentioning any plans to support it: http://groups.google.com/group/llvm-dev/browse_thread/thread/b7fc0999e9f11b8f/2cc43ddaba3bcff6?lnk=gst&q=SEH+exception#2cc43ddaba3bcff6 More details about the crash: I was able to repro the issue simply by modifying the Fibonacci example to call an external C++ function which throws an exception, much like in ExceptionsDemo.cpp: works on 32 bits but not on 64 bits Visual Studio. The crash happens within Windows' _cxxThrowException routine. I read that the 64 bits exception handling in Windows is doing some unwinding in a different fashion than on 32 bits (as explained here: http://lackingrhoticity.blogspot.ca/2011/11/stack-unwinding-risks-on-64-bit-windows.html). In particular, this blog seems to state that exceptions won't unwind properly through functions that don't provide some unwind info, which is the case for LLVM I guess. Thank you, Jerome Couture-Gagnon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120412/e06b6ba9/attachment.html>
Sebastian Redl
2012-Apr-13 09:52 UTC
[LLVMdev] Support for "foreign" Visual Studio 64 bits C++ exceptions?
On 12.04.2012 23:02, Jérôme Couture-Gagnon wrote:> Hi, > > We are currently porting our application to Windows 64 bits (amd64), > and we are getting regressions from 32 bits relatively to LLVM 3.0's > ability to get traversed by "foreign" Visual Studio C++ exceptions. > That is, there is a crash when C++ exceptions which are thrown from > Visual Studio code, are unwinding through LLVM code before being > eventually catch by other Visual Studio code (more details below). > > I am not an expert on the subject of exceptions, however I was not > able to find clear answers about this specific issue. Should it be > supported,No. Not sure if the current Windows builds use SJLJ or Dwarf2 exception handling, but either way it is simply incompatible with SEH stack unwinding. Apparently LLVM doesn't generate even the minimal support for SEH unwinding through its code to work.> and if not, is there is any planned effort from the LLVM team to work > on this?Not AFAIK, but I'm pretty sure any and all work on 64-bit SEH support would be appreciated. Currently, there is some work in Clang ongoing to emulate the Microsoft ABI, and eventually, SEH support will be required for completeness. Sebastian -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120413/cfa0b1c0/attachment.html>
Michael Spencer
2012-Apr-13 15:19 UTC
[LLVMdev] Support for "foreign" Visual Studio 64 bits C++ exceptions?
On Thu, Apr 12, 2012 at 2:02 PM, Jérôme Couture-Gagnon <Jerome.Couture-Gagnon at fabricengine.com> wrote:> Hi, > > We are currently porting our application to Windows 64 bits (amd64), and we > are getting regressions from 32 bits relatively to LLVM 3.0's ability to get > traversed by "foreign" Visual Studio C++ exceptions. That is, there is a > crash when C++ exceptions which are thrown from Visual Studio code, are > unwinding through LLVM code before being eventually catch by other Visual > Studio code (more details below). > > I am not an expert on the subject of exceptions, however I was not able to > find clear answers about this specific issue. Should it be supported, and if > not, is there is any planned effort from the LLVM team to work on this? > > Note that we are not using the LLVM3.0 exception API (launchingPad with > personality routine). In fact, this leads to another related question: is > there even a "personality routine" available when compiling with Visual > Studio? From what I read it looks like this would require support for > Windows' SEH, which is not implemented yet. Any news or plans on that front? > SEH was mentionned in the design discussion of LLVM3.0's exception API, > without mentioning any plans to support it: > http://groups.google.com/group/llvm-dev/browse_thread/thread/b7fc0999e9f11b8f/2cc43ddaba3bcff6?lnk=gst&q=SEH+exception#2cc43ddaba3bcff6 > > More details about the crash: > > I was able to repro the issue simply by modifying the Fibonacci example to > call an external C++ function which throws an exception, much like in > ExceptionsDemo.cpp: works on 32 bits but not on 64 bits Visual Studio. The > crash happens within Windows' _cxxThrowException routine. I read that the 64 > bits exception handling in Windows is doing some unwinding in a different > fashion than on 32 bits (as explained > here: http://lackingrhoticity.blogspot.ca/2011/11/stack-unwinding-risks-on-64-bit-windows.html). > In particular, this blog seems to state that exceptions won't unwind > properly through functions that don't provide some unwind info, which is the > case for LLVM I guess. > > Thank you, > > Jerome Couture-GagnonWindows 64 does not have SEH. LLVM has code to generate proper unwind information for Windows 64, but it may have bugs, or not generate the proper info for this case. Clang also does no generate proper MSVC C++ exceptions. This is as much as I know. - Michael Spencer
Jérôme Couture-Gagnon
2012-Apr-13 15:31 UTC
[LLVMdev] Support for "foreign" Visual Studio 64 bits C++ exceptions?
Sorry for mixing up terms, reading through forums about Windows 64 bits exceptions gives quite a fuzzy picture (some talk about SEH for Windows 64 but probably just refer to the Windows specific mechanism). If the scenario I described below should work properly, then I will submit a bug with the small example that I built. I am not sure however if that crash is specific to Visual Studio's amd64 (which is not officially supported by LLVM). Thank you, Jerome Couture-Gagnon ________________________________________ From: Michael Spencer [bigcheesegs at gmail.com] Sent: Friday, April 13, 2012 11:19 AM To: Jérôme Couture-Gagnon Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] Support for "foreign" Visual Studio 64 bits C++ exceptions? On Thu, Apr 12, 2012 at 2:02 PM, Jérôme Couture-Gagnon <Jerome.Couture-Gagnon at fabricengine.com> wrote:> Hi, > > We are currently porting our application to Windows 64 bits (amd64), and we > are getting regressions from 32 bits relatively to LLVM 3.0's ability to get > traversed by "foreign" Visual Studio C++ exceptions. That is, there is a > crash when C++ exceptions which are thrown from Visual Studio code, are > unwinding through LLVM code before being eventually catch by other Visual > Studio code (more details below). > > I am not an expert on the subject of exceptions, however I was not able to > find clear answers about this specific issue. Should it be supported, and if > not, is there is any planned effort from the LLVM team to work on this? > > Note that we are not using the LLVM3.0 exception API (launchingPad with > personality routine). In fact, this leads to another related question: is > there even a "personality routine" available when compiling with Visual > Studio? From what I read it looks like this would require support for > Windows' SEH, which is not implemented yet. Any news or plans on that front? > SEH was mentionned in the design discussion of LLVM3.0's exception API, > without mentioning any plans to support it: > http://groups.google.com/group/llvm-dev/browse_thread/thread/b7fc0999e9f11b8f/2cc43ddaba3bcff6?lnk=gst&q=SEH+exception#2cc43ddaba3bcff6 > > More details about the crash: > > I was able to repro the issue simply by modifying the Fibonacci example to > call an external C++ function which throws an exception, much like in > ExceptionsDemo.cpp: works on 32 bits but not on 64 bits Visual Studio. The > crash happens within Windows' _cxxThrowException routine. I read that the 64 > bits exception handling in Windows is doing some unwinding in a different > fashion than on 32 bits (as explained > here: http://lackingrhoticity.blogspot.ca/2011/11/stack-unwinding-risks-on-64-bit-windows.html). > In particular, this blog seems to state that exceptions won't unwind > properly through functions that don't provide some unwind info, which is the > case for LLVM I guess. > > Thank you, > > Jerome Couture-GagnonWindows 64 does not have SEH. LLVM has code to generate proper unwind information for Windows 64, but it may have bugs, or not generate the proper info for this case. Clang also does no generate proper MSVC C++ exceptions. This is as much as I know. - Michael Spencer