Pārlūkot izejas kodu

libobs: Raise out of memory exception manually when out of memory

The previous attempt to clarify an out of memory exception/crash
resulted in the compiler optimizing os_breakpoint() and os_oom() into
the same result, which meant that crash stacks in the wild were still
not specific enough to be helpful. Forcefully differentiating the
functions in Release configuration by having os_breakpoint() only call
__debugbreak() and having os_oom() call RaiseException() should give us
clearer crash stacks.

Amends 94a736f1795c21afd0baa10c0692543b70c17dc5.
Ryan Foster 1 mēnesi atpakaļ
vecāks
revīzija
1e281538a4
1 mainītis faili ar 4 papildinājumiem un 0 dzēšanām
  1. 4 0
      libobs/util/platform-windows.c

+ 4 - 0
libobs/util/platform-windows.c

@@ -1194,7 +1194,11 @@ void os_breakpoint(void)
 
 void os_oom(void)
 {
+#ifdef DEBUG
 	__debugbreak();
+#else
+	RaiseException(ERROR_OUTOFMEMORY, EXCEPTION_NONCONTINUABLE, 0, NULL);
+#endif
 }
 
 DWORD num_logical_cores(ULONG_PTR mask)