mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
Fix bh_assert for 64-bit platforms (#2071)
In some cases, the memory address of some variables may have 4 least significant bytes set to zero. Because we cast the pointer to int, we look only at 4 least significant bytes; the assertion may fail because 4 least significant bytes are 0. Change bh_assert implementation to cast the assert expr to int64_t and it works well with 64-bit architectures.
This commit is contained in:
parent
61369d48fd
commit
ff4be24726
|
@ -6,7 +6,7 @@
|
|||
#include "bh_assert.h"
|
||||
|
||||
void
|
||||
bh_assert_internal(int v, const char *file_name, int line_number,
|
||||
bh_assert_internal(int64 v, const char *file_name, int line_number,
|
||||
const char *expr_string)
|
||||
{
|
||||
if (v)
|
||||
|
|
|
@ -14,10 +14,10 @@ extern "C" {
|
|||
|
||||
#if BH_DEBUG != 0
|
||||
void
|
||||
bh_assert_internal(int v, const char *file_name, int line_number,
|
||||
bh_assert_internal(int64 v, const char *file_name, int line_number,
|
||||
const char *expr_string);
|
||||
#define bh_assert(expr) \
|
||||
bh_assert_internal((int)(uintptr_t)(expr), __FILE__, __LINE__, #expr)
|
||||
bh_assert_internal((int64)(uintptr_t)(expr), __FILE__, __LINE__, #expr)
|
||||
#else
|
||||
#define bh_assert(expr) (void)0
|
||||
#endif /* end of BH_DEBUG */
|
||||
|
|
Loading…
Reference in New Issue
Block a user