什么是Webkit中使用的0xbbadbeef?

时间:2014-08-18 14:19:22

标签: pointers memory webkit magic-numbers

使用Webkit时遇到错误,指针设置为0xbbadbeef。 什么是BadBeef用于Webkit?

1 个答案:

答案 0 :(得分:6)

它是WebKit中使用的hexspeak,它表示已知的,不可恢复的错误,例如内存不足。

正如您从链接https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/wtf/Assertions.h&l=180

中看到的那样
/* CRASH() - Raises a fatal error resulting in program termination and triggering either the debugger or the crash reporter.

   Use CRASH() in response to known, unrecoverable errors like out-of-memory.
   Macro is enabled in both debug and release mode.
   To test for unknown errors and verify assumptions, use ASSERT instead, to avoid impacting performance in release builds.

   Signals are ignored by the crash reporter on OS X so we must do better.
*/
#ifndef CRASH
#if COMPILER(MSVC)
#define CRASH() (__debugbreak(), IMMEDIATE_CRASH())
#else
#define CRASH() \
    (WTFReportBacktrace(), (*(int*)0xfbadbeef = 0), IMMEDIATE_CRASH())
#endif
#endif