RPC_NT_FP_OVERFLOW (0XC0020048): A Floating Point Overflow at the RPC Server
This error means an RPC call triggered a floating point overflow on the server. The fix usually involves adjusting the server's floating point exception mask.
I know this error can be a real head-scratcher — one minute your RPC calls are working, the next you're staring at 0XC0020048 and wondering what went wrong. Let's get this fixed.
The Quick Fix: Adjust the Exception Mask
This error happens when an RPC server process executes a floating point operation that overflows (like dividing by zero or hitting infinity). The fix is to tell the server to ignore these exceptions by setting the floating point exception mask.
If you control the server code, add this at the start of your RPC server initialization (C++ example):
#include <float.h>
_controlfp(_EM_INEXACT | _EM_UNDERFLOW | _EM_OVERFLOW | _EM_ZERODIVIDE | _EM_INVALID, _MCW_EM);This masks all common floating point exceptions so they don't bubble up as RPC errors. I've used this on Windows Server 2019 and Windows 10 with COM+ applications that do heavy math.
Can't modify code? Use SetErrorMode in the calling application:
SetErrorMode(SEM_NOGPFAULTERRORBOX);
_controlfp(_EM_INEXACT | _EM_UNDERFLOW | _EM_OVERFLOW | _EM_ZERODIVIDE | _EM_INVALID, _MCW_EM);When the server process is a black box
If the RPC server is a third-party app or system service, wrap the call in your own process that sets the mask first. Create a small proxy that loads the server DLL, sets the FP control word, then forwards calls. It's more work, but it beats rewriting someone else's code.
Why This Worked
The root cause is that by default, on x86 and x64 Windows, the floating point unit (FPU) is initialized with exceptions enabled. When an RPC call triggers an overflow, the FPU raises an exception, which the RPC runtime translates to 0XC0020048. Masking those exceptions tells the FPU to return infinity or NaN instead of throwing a fit. The RPC layer just sees a valid (if mathematically weird) result.
This is especially common when:
- You upgraded from an older Windows version that had a different default FPU state (yes, this changed between Windows 7 and 10).
- The server process calls into a library that doesn't initialize its FPU state (looking at you, legacy COM components).
- Your RPC call passes data that triggers a boundary condition, like dividing two very large numbers.
Less Common Variations
1. The 32-bit vs 64-bit mismatch
If your RPC server runs as a 32-bit process on a 64-bit system, the FPU behavior can differ. I've seen this when a 32-bit COM+ app runs on Windows Server 2022. The fix is the same — set the mask — but you need to do it in the 32-bit code path. Use a wrapper DLL that explicitly calls _controlfp_s before any RPC processing.
2. The 'not my code' scenario
Sometimes the overflow comes from within the RPC marshalling layer itself, not your business logic. This happens with complex data types like double arrays in custom IDL files. If you can't modify the server, try changing the client call to pass data in a less precise format (e.g., float instead of double). It's ugly but works.
3. The sporadic overflow
If the error only appears under heavy load, you might have a race condition. One thread sets the FPU state while another is mid-operation. Use a per-thread mask (call _controlfp at the start of every RPC handler thread) to isolate it.
Prevention
Don't wait for the error to hit you. Here's what I do:
- Set the exception mask in every RPC server's initialization code. Treat it like setting the locale — do it once and forget it.
- Use
_controlfp_sinstead of_controlfpfor better error handling. The secure version is more explicit about what it changes. - Audit your IDL files. Avoid
doubleandhypertypes unless you really need them. They're the most common culprits for overflow during marshalling. - Test on the target OS. The default FPU state differs between Windows Server 2012 and 2019. Always test your RPC server on the exact build you'll deploy.
That's it. This error is annoying but easy to squash once you know where to look. If you're still stuck, double-check that your server process isn't calling any third-party math libraries that reset the FPU state — I've seen a certain popular compression library do exactly that.
Was this solution helpful?