Closed Bug 1504022 Opened 6 years ago Closed 6 years ago

Enable SEH exceptions for x86 (or something else)

Categories

(Firefox Build System :: General: Unsupported Platforms, enhancement, P5)

enhancement

Tracking

(firefox-esr60 fixed, firefox65 fixed)

RESOLVED FIXED
mozilla65
Tracking Status
firefox-esr60 --- fixed
firefox65 --- fixed

People

(Reporter: tjr, Assigned: tjr)

References

Details

Attachments

(4 files)

The x86 mingw-clang build uses setjmp/longjmp exception handling instead of SEH. This causes the toolchain to assert when __try/__except is used. (It'd be nice if it printed an error message instead of crashing, but the problem would remain.) We can fix this by fixing the SEH exception handling for x86 mode and switching to it. If that's not feasible, we can also go back to the old way that we did with mingw-gcc where we plaster over the __try/__except with if(true) / else. Also we should test __try/__except in the x64 build and make sure it works the way we think it does. If it doesn't we'll need to use the old way anyway. (And probably nag upstream about appearing-but-not-really supporting it.)
(In reply to Tom Ritter [:tjr] from comment #0) > The x86 mingw-clang build uses setjmp/longjmp exception handling instead of > SEH. This causes the toolchain to assert when __try/__except is used. (It'd > be nice if it printed an error message instead of crashing, but the problem > would remain.) > > We can fix this by fixing the SEH exception handling for x86 mode and > switching to it. This is probably a rather big venture. The basic SEH mechanisms on all other archs than i386 is pretty much the same, but SEH on i386 is pretty different from the rest. GCC only supports SEH on x86_64, while LLVM does support it on i386 as well. However, to actually use SEH for exception handling, you need support for it in the runtime as well - either by using libgcc or libunwind. Neither of these support the i386 SEH mechanism for C++ exceptions as it stands right now. If lucky, one could try compiling with -fseh-exceptions for i386 and "only" fill in the blanks in libunwind. If unlucky, there's lots of nontrivial things to fix within LLVM for i386-SEH-for-mingw. But don't let me discourage you - any research into this area would be very welcome by the general mingw community :-) > If that's not feasible, we can also go back to the old way that we did with > mingw-gcc where we plaster over the __try/__except with if(true) / else. Sounds sensible > Also we should test __try/__except in the x64 build and make sure it works > the way we think it does. If it doesn't we'll need to use the old way > anyway. (And probably nag upstream about appearing-but-not-really > supporting it.) Yup - I'm interested in hearing about this, and I'd love to grab some minimal testcases of using this after you've looked at it.
Attached file __try test with x64 mingw-clang.txt (deleted) —
(In reply to Martin Storsjö from comment #1) > > Also we should test __try/__except in the x64 build and make sure it works > > the way we think it does. If it doesn't we'll need to use the old way > > anyway. (And probably nag upstream about appearing-but-not-really > > supporting it.) > > Yup - I'm interested in hearing about this, and I'd love to grab some > minimal testcases of using this after you've looked at it. So the very first thing I tried did not work. Details attached. So I'll just revert those patches an apply them to both x64 and x86...
What about x64? I thought that we still want SEH there.
(In reply to Jacek Caban from comment #6) > What about x64? I thought that we still want SEH there. AFAIK, you'd still use SEH for C++ exceptions. This is about the "real" plain SEH constructs with `__try`/`__except`, which aren't supported in mingw mode (nor in GCC) even if they are using SEH for C++ exceptions.
Attachment #9022296 - Flags: review?(bobowencode) → review+
Attachment #9022297 - Flags: review?(bobowencode) → review+
Attachment #9022299 - Flags: review?(bobowencode) → review+
Keywords: checkin-needed
Pushed by dvarga@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/c2efa1db3727 Restore mingw overrides for __try/__except (backout of 1498676) r=bobowen https://hg.mozilla.org/integration/mozilla-inbound/rev/52a1404ac742 Map GetExceptionCode to a nop to avoid an error r=bobowen https://hg.mozilla.org/integration/mozilla-inbound/rev/a22d6ae98c2d Backout 1498693 to restore mingw exceptions for __try/__except r=bobowen
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Blocks: 1517841

Comment on attachment 9022299 [details] [diff] [review]
Bug 1504022 - Map GetExceptionCode to a nop to avoid an error r?bobowen

NOTE: This patch (Map GetExceptionCode to a nop to avoid an error) only.

[ESR Uplift Approval Request]

If this is not a sec:{high,crit} bug, please state case for ESR consideration: The mingwclang build cannot enable the sandbox without this patch.

User impact if declined: Tor will have to carry the patch; and we won't be able to enable the sandbox on esr60.

Fix Landed on Version: 65.0a1 / 20181107100135

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): Affects only mingw build

String or UUID changes made by this patch:

Attachment #9022299 - Flags: approval-mozilla-esr60?

Comment on attachment 9022299 [details] [diff] [review]
Bug 1504022 - Map GetExceptionCode to a nop to avoid an error r?bobowen

mingw fix, approved for 60.5esr

Attachment #9022299 - Flags: approval-mozilla-esr60? → approval-mozilla-esr60+
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: