protect read-write-extend operations with a lock#1010
Merged
wenyongh merged 2 commits intobytecodealliance:mainfrom Mar 23, 2022
Merged
protect read-write-extend operations with a lock#1010wenyongh merged 2 commits intobytecodealliance:mainfrom
wenyongh merged 2 commits intobytecodealliance:mainfrom
Conversation
wenyongh
reviewed
Feb 22, 2022
core/shared/utils/bh_vector.c
Outdated
| vector->num_elems = 0; | ||
|
|
||
| if (use_lock) { | ||
| vector->lock = wasm_runtime_malloc(sizeof(korp_mutex)); |
Collaborator
There was a problem hiding this comment.
Should check the return value
core/shared/utils/bh_vector.c
Outdated
|
|
||
| if (use_lock) { | ||
| vector->lock = wasm_runtime_malloc(sizeof(korp_mutex)); | ||
| os_mutex_init(vector->lock); |
Collaborator
There was a problem hiding this comment.
Should check the return value
core/shared/utils/bh_vector.c
Outdated
| #include "bh_vector.h" | ||
|
|
||
| #define LOCK(v) \ | ||
| { \ |
Collaborator
There was a problem hiding this comment.
Had better wrap the code with do { .. } while (0)
0ae194e to
bae0fb2
Compare
wenyongh
reviewed
Mar 22, 2022
core/shared/utils/bh_vector.c
Outdated
| return false; | ||
| } | ||
|
|
||
| if (BHT_ERROR == os_mutex_init(vector->lock)) { |
Collaborator
There was a problem hiding this comment.
Should use 0 != os_mutex_init or BHT_OK != os_mutex_init, as os_mutex_init is implemented by various platforms, the return value may be not BHT_ERROR when we failed to init it.
bae0fb2 to
d3e179c
Compare
wenyongh
reviewed
Mar 23, 2022
doc/wasm_c_api.md
Outdated
| - The thread model of _wasm_c_api_ is | ||
|
|
||
| - An `wasm_engine_t` instance may only be created once per process | ||
| - Every `wasm_store_t` and its objects only be accessed in a single thread |
doc/wasm_c_api.md
Outdated
|
|
||
| - `wasm_engine_new`, `wasm_engine_new_with_config`, `wasm_engine_new_with_args`, | ||
| `wasm_engine_delete`should be called in a thread-safe environment. Such | ||
| behaviors are not recommend , and please make sure an appropriate calling |
Collaborator
There was a problem hiding this comment.
are not recommend , to are not recommended,
doc/wasm_c_api.md
Outdated
| behaviors are not recommend , and please make sure an appropriate calling | ||
| sequence if it has to be. | ||
|
|
||
| - to call `wasm_engine_new` and `wasm_engine_delete` in different threads |
Collaborator
There was a problem hiding this comment.
to call means do it in the future, had better change it to call?
doc/wasm_c_api.md
Outdated
| sequence if it has to be. | ||
|
|
||
| - to call `wasm_engine_new` and `wasm_engine_delete` in different threads | ||
| - to call `wasm_engine_new` or `wasm_engine_delete` multiple time in |
d3e179c to
cfbe7ed
Compare
wenyongh
added a commit
to wenyongh/wasm-micro-runtime
that referenced
this pull request
Mar 23, 2022
Enable lock for Vector to protect wasm-c-api read/write/extend operations (bytecodealliance#1010)
vickiegpt
pushed a commit
to vickiegpt/wamr-aot-gc-checkpoint-restore
that referenced
this pull request
May 27, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.