wasm-micro-runtime/core/shared/utils/bh_assert.c
Marcin Kolny ff4be24726
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.
2023-03-28 12:18:39 +08:00

26 lines
555 B
C

/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_assert.h"
void
bh_assert_internal(int64 v, const char *file_name, int line_number,
const char *expr_string)
{
if (v)
return;
if (!file_name)
file_name = "NULL FILENAME";
if (!expr_string)
expr_string = "NULL EXPR_STRING";
os_printf("\nASSERTION FAILED: %s, at file %s, line %d\n", expr_string,
file_name, line_number);
abort();
}