Files
Yannis Juglaret f2ec13393e Bug 1932088 - Fail cleanly via SEH if a single-step exception escapes the VEH chain. r=win-reviewers,gstoll
On Windows, we use single-step execution to collect the addresses of
some ntdll-internal locks that are required for deadlock-free profiling.
We achieve this by setting up a vectored exception handler that handles
single-step exceptions.

Based on crash data, third-party antivirus software can get in the way
of our handler, preventing it from running and thus letting the
single-step exception escape the VEH chain. When that happens, the user
will crash.

This patch thus adds a SEH handler to catch the single-step exception
and fail cleanly in case the exception escapes the VEH chain. This
requires moving the definition of MOZ_SEH_TRY and MOZ_SEH_EXCEPT to
mfbt/ so these macros are found when working with builds that don't use
xpcom/, such as SpiderMonkey builds.

Differential Revision: https://phabricator.services.mozilla.com/D300716
2026-05-20 08:22:00 +00:00

20 lines
494 B
C

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_SEH_h
#define mozilla_SEH_h
/*
* SEH exception macros.
*/
#ifdef HAVE_SEH_EXCEPTIONS
# define MOZ_SEH_TRY __try
# define MOZ_SEH_EXCEPT(expr) __except (expr)
#else
# define MOZ_SEH_TRY if (true)
# define MOZ_SEH_EXCEPT(expr) else
#endif
#endif /* mozilla_SEH_h */