Skip to content

Commit 190571f

Browse files
authored
release/1.3.x: Cumulative fixes for release/1.3.x (#3342)
Apply patches which were fixed in branch main to branch `release/1.3.x`: - aot debug: Fix a few NULL dereferences on errors (#3273) - aot debug: Fix a NULL dereference (#3274) - aot debug: Process lldb_function_to_function_dbi only for C (#3278) - Revert "lldb_function_to_function_dbi: A hack to avoid crashing on C++ methods (#3190)" (#3281) - Fix warnings/issues reported in Windows and by CodeQL/Coverity (#3275) - thread mgr: Free aux stack only when it was allocated (#3282) - interp: Restore context from prev_frame after tail calling a native f unction (#3283) - Sync simd opcode definitions spec (#3290) - Add more checks in wasm loader (#3300) - Fix posix_fadvise error handling (#3323) - Fix readdir for posix (#3339) - wasm loader: Fix checks for opcode ref.func and opcode else (#3340) - Enhance wasm loader checks for opcode br_table (#3352) - CI: Use macos-13 instead of macos-latest (#3366)
1 parent 2735192 commit 190571f

34 files changed

+327
-274
lines changed

.github/workflows/compilation_on_macos.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (C) 2019 Intel Corporation. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
name: compilation on macos-latest
4+
name: compilation on macos
55

66
on:
77
# will be triggered on PR events
@@ -58,7 +58,7 @@ jobs:
5858
build_llvm_libraries:
5959
uses: ./.github/workflows/build_llvm_libraries.yml
6060
with:
61-
os: "macos-latest"
61+
os: "macos-13"
6262
arch: "X86"
6363

6464
build_wamrc:
@@ -67,7 +67,7 @@ jobs:
6767
strategy:
6868
matrix:
6969
include:
70-
- os: macos-latest
70+
- os: macos-13
7171
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
7272
steps:
7373
- name: checkout
@@ -128,7 +128,7 @@ jobs:
128128
"-DWAMR_BUILD_TAIL_CALL=1",
129129
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
130130
]
131-
os: [macos-latest]
131+
os: [macos-13]
132132
platform: [darwin]
133133
exclude:
134134
# uncompatiable feature and platform
@@ -170,7 +170,7 @@ jobs:
170170
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
171171
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
172172
include:
173-
- os: macos-latest
173+
- os: macos-13
174174
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
175175
steps:
176176
- name: checkout
@@ -215,7 +215,7 @@ jobs:
215215
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
216216
#$AOT_BUILD_OPTIONS,
217217
]
218-
os: [macos-latest]
218+
os: [macos-13]
219219
wasi_sdk_release:
220220
[
221221
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
@@ -247,7 +247,7 @@ jobs:
247247
runs-on: ${{ matrix.os }}
248248
strategy:
249249
matrix:
250-
os: [macos-latest]
250+
os: [macos-13]
251251
wasi_sdk_release:
252252
[
253253
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",

.github/workflows/release_process.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
needs: [create_tag, create_release]
7070
uses: ./.github/workflows/build_llvm_libraries.yml
7171
with:
72-
os: "macos-latest"
72+
os: "macos-13"
7373
arch: "AArch64 ARM Mips RISCV X86"
7474

7575
#
@@ -100,7 +100,7 @@ jobs:
100100
with:
101101
llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }}
102102
release: true
103-
runner: macos-latest
103+
runner: macos-13
104104
upload_url: ${{ needs.create_release.outputs.upload_url }}
105105
ver_num: ${{ needs.create_tag.outputs.new_ver }}
106106

@@ -132,7 +132,7 @@ jobs:
132132
with:
133133
cwd: product-mini/platforms/darwin
134134
llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }}
135-
runner: macos-latest
135+
runner: macos-13
136136
upload_url: ${{ needs.create_release.outputs.upload_url }}
137137
ver_num: ${{ needs.create_tag.outputs.new_ver}}
138138

@@ -163,7 +163,7 @@ jobs:
163163
uses: ./.github/workflows/build_wamr_sdk.yml
164164
with:
165165
config_file: wamr_config_macos_release.cmake
166-
runner: macos-latest
166+
runner: macos-13
167167
upload_url: ${{ needs.create_release.outputs.upload_url }}
168168
ver_num: ${{ needs.create_tag.outputs.new_ver}}
169169
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz
@@ -209,7 +209,7 @@ jobs:
209209
needs: [create_tag, create_release]
210210
uses: ./.github/workflows/build_wamr_lldb.yml
211211
with:
212-
runner: macos-latest
212+
runner: macos-13
213213
arch: universal
214214
upload_url: ${{ needs.create_release.outputs.upload_url }}
215215
ver_num: ${{ needs.create_tag.outputs.new_ver}}

core/config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@
390390
#else
391391
#define DEFAULT_WASM_STACK_SIZE (12 * 1024)
392392
#endif
393-
/* Min auxilliary stack size of each wasm thread */
393+
/* Min auxiliary stack size of each wasm thread */
394394
#define WASM_THREAD_AUX_STACK_SIZE_MIN (256)
395395

396396
/* Default/min native stack size of each app thread */
@@ -515,7 +515,7 @@
515515
#endif
516516

517517
/* Support registering quick AOT/JIT function entries of some func types
518-
to speedup the calling process of invoking the AOT/JIT functions of
518+
to speed up the calling process of invoking the AOT/JIT functions of
519519
these types from the host embedder */
520520
#ifndef WASM_ENABLE_QUICK_AOT_ENTRY
521521
#define WASM_ENABLE_QUICK_AOT_ENTRY 1

core/iwasm/common/wasm_exec_env.h

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ typedef struct WASMExecEnv {
114114

115115
/* whether current thread is detached */
116116
bool thread_is_detached;
117+
118+
/* whether the aux stack is allocated */
119+
bool is_aux_stack_allocated;
117120
#endif
118121

119122
#if WASM_ENABLE_DEBUG_INTERP != 0

core/iwasm/common/wasm_runtime_common.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ decode_insn(uint8 *insn)
269269
runtime_address);
270270

271271
/* Print current instruction */
272-
/*
272+
#if 0
273273
os_printf("%012" PRIX64 " ", runtime_address);
274274
puts(buffer);
275-
*/
275+
#endif
276276

277277
return instruction.length;
278278
}
@@ -946,7 +946,7 @@ wasm_runtime_register_module_internal(const char *module_name,
946946
/* module hasn't been registered */
947947
node = runtime_malloc(sizeof(WASMRegisteredModule), NULL, NULL, 0);
948948
if (!node) {
949-
LOG_DEBUG("malloc WASMRegisteredModule failed. SZ=%d",
949+
LOG_DEBUG("malloc WASMRegisteredModule failed. SZ=%zu",
950950
sizeof(WASMRegisteredModule));
951951
return false;
952952
}
@@ -5033,6 +5033,7 @@ wasm_externref_set_cleanup(WASMModuleInstanceCommon *module_inst,
50335033
if (lookup_user_data.found) {
50345034
void *key = (void *)(uintptr_t)lookup_user_data.externref_idx;
50355035
ExternRefMapNode *node = bh_hash_map_find(externref_map, key);
5036+
bh_assert(node);
50365037
node->cleanup = extern_obj_cleanup;
50375038
ok = true;
50385039
}
@@ -6061,12 +6062,12 @@ wasm_runtime_load_depended_module(const WASMModuleCommon *parent_module,
60616062
if (!ret) {
60626063
LOG_DEBUG("read the file of %s failed", sub_module_name);
60636064
set_error_buf_v(parent_module, error_buf, error_buf_size,
6064-
"unknown import", sub_module_name);
6065+
"unknown import %s", sub_module_name);
60656066
goto delete_loading_module;
60666067
}
60676068
if (get_package_type(buffer, buffer_size) != parent_module->module_type) {
60686069
LOG_DEBUG("moudle %s type error", sub_module_name);
6069-
goto delete_loading_module;
6070+
goto destroy_file_buffer;
60706071
}
60716072
if (get_package_type(buffer, buffer_size) == Wasm_Module_Bytecode) {
60726073
#if WASM_ENABLE_INTERP != 0
@@ -6171,7 +6172,7 @@ wasm_runtime_sub_module_instantiate(WASMModuleCommon *module,
61716172
sub_module_inst_list_node = loader_malloc(sizeof(WASMSubModInstNode),
61726173
error_buf, error_buf_size);
61736174
if (!sub_module_inst_list_node) {
6174-
LOG_DEBUG("Malloc WASMSubModInstNode failed, SZ:%d",
6175+
LOG_DEBUG("Malloc WASMSubModInstNode failed, SZ: %zu",
61756176
sizeof(WASMSubModInstNode));
61766177
if (sub_module_inst)
61776178
wasm_runtime_deinstantiate_internal(sub_module_inst, false);

core/iwasm/common/wasm_runtime_common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ typedef struct WASMModuleCommon {
336336

337337
/* The following uint8[1] member is a dummy just to indicate
338338
some module_type dependent members follow.
339-
Typically it should be accessed by casting to the corresponding
339+
Typically, it should be accessed by casting to the corresponding
340340
actual module_type dependent structure, not via this member. */
341341
uint8 module_data[1];
342342
} WASMModuleCommon;
@@ -352,7 +352,7 @@ typedef struct WASMModuleInstanceCommon {
352352

353353
/* The following uint8[1] member is a dummy just to indicate
354354
some module_type dependent members follow.
355-
Typically it should be accessed by casting to the corresponding
355+
Typically, it should be accessed by casting to the corresponding
356356
actual module_type dependent structure, not via this member. */
357357
uint8 module_inst_data[1];
358358
} WASMModuleInstanceCommon;

core/iwasm/compilation/aot_compiler.c

+3-52
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
196196
location = dwarf_gen_location(
197197
comp_ctx, func_ctx,
198198
(frame_ip - 1) - comp_ctx->comp_data->wasm_module->buf_code);
199-
LLVMSetCurrentDebugLocation2(comp_ctx->builder, location);
199+
if (location != NULL) {
200+
LLVMSetCurrentDebugLocation2(comp_ctx->builder, location);
201+
}
200202
#endif
201203

202204
switch (opcode) {
@@ -2134,16 +2136,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
21342136
break;
21352137
}
21362138

2137-
case SIMD_i32x4_narrow_i64x2_s:
2138-
case SIMD_i32x4_narrow_i64x2_u:
2139-
{
2140-
if (!aot_compile_simd_i32x4_narrow_i64x2(
2141-
comp_ctx, func_ctx,
2142-
SIMD_i32x4_narrow_i64x2_s == opcode))
2143-
return false;
2144-
break;
2145-
}
2146-
21472139
case SIMD_i32x4_extend_low_i16x8_s:
21482140
case SIMD_i32x4_extend_high_i16x8_s:
21492141
{
@@ -2183,16 +2175,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
21832175
break;
21842176
}
21852177

2186-
case SIMD_i32x4_add_sat_s:
2187-
case SIMD_i32x4_add_sat_u:
2188-
{
2189-
if (!aot_compile_simd_i32x4_saturate(
2190-
comp_ctx, func_ctx, V128_ADD,
2191-
opcode == SIMD_i32x4_add_sat_s))
2192-
return false;
2193-
break;
2194-
}
2195-
21962178
case SIMD_i32x4_sub:
21972179
{
21982180
if (!aot_compile_simd_i32x4_arith(comp_ctx, func_ctx,
@@ -2201,16 +2183,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
22012183
break;
22022184
}
22032185

2204-
case SIMD_i32x4_sub_sat_s:
2205-
case SIMD_i32x4_sub_sat_u:
2206-
{
2207-
if (!aot_compile_simd_i32x4_saturate(
2208-
comp_ctx, func_ctx, V128_SUB,
2209-
opcode == SIMD_i32x4_add_sat_s))
2210-
return false;
2211-
break;
2212-
}
2213-
22142186
case SIMD_i32x4_mul:
22152187
{
22162188
if (!aot_compile_simd_i32x4_arith(comp_ctx, func_ctx,
@@ -2247,13 +2219,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
22472219
break;
22482220
}
22492221

2250-
case SIMD_i32x4_avgr_u:
2251-
{
2252-
if (!aot_compile_simd_i32x4_avgr_u(comp_ctx, func_ctx))
2253-
return false;
2254-
break;
2255-
}
2256-
22572222
case SIMD_i32x4_extmul_low_i16x8_s:
22582223
case SIMD_i32x4_extmul_high_i16x8_s:
22592224
{
@@ -2410,13 +2375,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
24102375
break;
24112376
}
24122377

2413-
case SIMD_f32x4_round:
2414-
{
2415-
if (!aot_compile_simd_f32x4_round(comp_ctx, func_ctx))
2416-
return false;
2417-
break;
2418-
}
2419-
24202378
case SIMD_f32x4_sqrt:
24212379
{
24222380
if (!aot_compile_simd_f32x4_sqrt(comp_ctx, func_ctx))
@@ -2470,13 +2428,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
24702428
break;
24712429
}
24722430

2473-
case SIMD_f64x2_round:
2474-
{
2475-
if (!aot_compile_simd_f64x2_round(comp_ctx, func_ctx))
2476-
return false;
2477-
break;
2478-
}
2479-
24802431
case SIMD_f64x2_sqrt:
24812432
{
24822433
if (!aot_compile_simd_f64x2_sqrt(comp_ctx, func_ctx))

core/iwasm/compilation/aot_emit_control.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ handle_next_reachable_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
272272
goto fail;
273273
}
274274
#if WASM_ENABLE_DEBUG_AOT != 0
275-
LLVMInstructionSetDebugLoc(ret, return_location);
275+
if (return_location != NULL) {
276+
LLVMInstructionSetDebugLoc(ret, return_location);
277+
}
276278
#endif
277279
}
278280
else {
@@ -281,7 +283,9 @@ handle_next_reachable_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
281283
goto fail;
282284
}
283285
#if WASM_ENABLE_DEBUG_AOT != 0
284-
LLVMInstructionSetDebugLoc(ret, return_location);
286+
if (return_location != NULL) {
287+
LLVMInstructionSetDebugLoc(ret, return_location);
288+
}
285289
#endif
286290
}
287291
}
@@ -1048,6 +1052,7 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
10481052
PUSH(values[j], target_block->result_types[j]);
10491053
}
10501054
wasm_runtime_free(values);
1055+
values = NULL;
10511056
}
10521057
target_block->is_reachable = true;
10531058
if (i == br_count)
@@ -1073,6 +1078,7 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
10731078
PUSH(values[j], target_block->param_types[j]);
10741079
}
10751080
wasm_runtime_free(values);
1081+
values = NULL;
10761082
}
10771083
if (i == br_count)
10781084
default_llvm_block = target_block->llvm_entry_block;

0 commit comments

Comments
 (0)