0X00000277

Fix Floating Point Trap Error 0x00000277 in Legacy Code

Windows throws this when old code hits multiple floating point traps. Disable the trap in project settings or patch the exception handler. Real fix below.

Yeah, that error code is a pain. You're staring at a crash dialog that says EXCEPTION (0x00000277) - Multiple floating point traps and wondering why your code worked yesterday. Deep breath. This is a legacy Windows thing, and I've seen it pop up on everything from old Delphi apps to C++ DLLs built in VS2008. Here's the fix that actually works.

The quick fix in Visual Studio

If you're building with Visual C++ (any version), the fastest way to stop this crash is to tell the compiler to stop generating floating point trap checks. In your project properties, go to:

Configuration Properties → C/C++ → Code Generation → Floating Point Model
Set to "Fast" (or /fp:fast)

That alone usually kills the error because it stops the compiler from inserting calls to _clearfp and trap handlers around every float operation. I had a client in 2019—they were running a trading app built in VS2005—and changing just that setting fixed a weekly crash that had them pulling their hair out.

But what if you can't change the project settings? Maybe it's a third-party DLL you can't recompile. Then you need the runtime patch.

The runtime patch for stubborn binaries

If you have the source but can't change the build, or if you're debugging a DLL you didn't write, you can disable floating point exceptions at the start of your program or before the crashing module loads. Use _controlfp on Windows:

#include <float.h>
// Disable all floating point exceptions
_controlfp(0, _MCW_EM);

Put that line at the very beginning of your main() or DllMain(). What it does is mask all x87 and SSE floating point exceptions—so instead of the OS throwing a trap when a division by zero or overflow happens, the CPU just returns inf or NaN and your code keeps running. Crude, but for legacy code that's not meant to handle floating point errors gracefully, it's the difference between a crash and a warning.

I've also used a small helper DLL that hooks into the process at load time via AppInit_DLLs (registry key) to inject that call. Fiddly, but works if you really can't touch the main executable.

Why this happens

Windows traps multiple floating point exceptions as a single error (0x00000277) because it's a bitmask of all the possible x87 exceptions: invalid operation, divide by zero, overflow, underflow, precision, denormal. The old code probably has a loop doing math on data from a file or user input, and when that data contains something like 0.0/0.0, it triggers a trap. If the trap isn't handled—and in a lot of old C code it isn't—Windows kills the process.

Most modern compilers default to masking these traps. But older ones didn't always, especially if the code was ported from 16-bit DOS or written by someone who thought _controlfp was a waste of time.

Less common variations

Sometimes you see this error not at the start of a run but mid-operation, like when loading a saved file or after a system sleep. Two things to check:

  • Mixed FPU states: If your code uses both x87 and SSE instructions, a mismatch can cause traps on context switches. Force the FPU to a known state with _fpreset() before and after heavy math.
  • Third-party libraries: I've seen this crash trace back to an OLE Automation call or an ActiveX control that toggles the FPU control word and never restores it. If your app uses COM, add _controlfp calls around those calls.

Also, if you're running on x64, note that the compiler uses SSE for floats by default. The classic x87 traps are less common there, but you can still get _EM_OVERFLOW or _EM_ZERODIVIDE masked—just that the error code might be different. If you see 0xC000008E or similar, it's the same root cause.

Prevention is boring but effective

Once you've got it running, do these three things so you don't wake up to this again:

  1. Set the floating point model to /fp:fast for any project you still compile.
  2. For existing binaries, add a startup shim that calls _controlfp before anything else runs.
  3. Write a regression test that feeds your math routines edge cases—0/0, 1e308*10, sqrt(-1)—to make sure they return something sane, not a trap.

That last one sounds boring, but it's saved me more than once. Last month, a client called with a crash in their invoice generator—turns out a currency field had a negative value that got squared and overflowed. The test caught it before I even shipped the fix.

So there you go. Disable the traps, patch the handler, and test your edge cases. You'll be done in ten minutes, not days.

Related Errors in Programming & Dev Tools
0XC01E0200 STATUS_GRAPHICS_GPU_EXCEPTION_ON_DEVICE 0xC01E0200 Fix 0X000002FF Fixing ERROR_DBG_CONTINUE (0X000002FF) in Visual Studio Debugger 0X0000023E Fix Windows App Crash ERROR_UNHANDLED_EXCEPTION 0X0000023E ModuleNotFoundError Fix Python ModuleNotFoundError: No module named 'module'

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.