wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Bug: atomic wait waits microsecond instead of nanoseconds

Open kfessel opened this issue 3 years ago • 3 comments

https://github.com/bytecodealliance/wasm-micro-runtime/blob/006574307557b4e041eeb785274021027e338ade/core/iwasm/common/wasm_shared_memory.c#L295

is used to implement memory.atomic.wait the ops timeout should be nanoseconds but it is interpreted in microseconds

https://github.com/bytecodealliance/wasm-micro-runtime/blob/006574307557b4e041eeb785274021027e338ade/core/iwasm/interpreter/wasm_interp_classic.c#L3197

https://github.com/bytecodealliance/wasm-micro-runtime/blob/006574307557b4e041eeb785274021027e338ade/core/iwasm/common/wasm_shared_memory.c#L377

https://github.com/bytecodealliance/wasm-micro-runtime/blob/006574307557b4e041eeb785274021027e338ade/core/shared/platform/common/posix/posix_thread.c#L236

kfessel avatar Mar 09 '22 15:03 kfessel

Hi, thanks for reporting this issue.

I have submitted a PR #1041 to fix this.

BTW, do you have any case that can be compiled to atomic.wait opcode?

xujuntwt95329 avatar Mar 10 '22 06:03 xujuntwt95329

BTW, do you have any case that can be compiled to atomic.wait opcode?

No, i was just checking, Why i have that semaphore in the riot port, tracked it back and found it not matching the wasm specs.

kfessel avatar Mar 10 '22 11:03 kfessel

@kfessel Thanks a lot!

The PR #1041 has been merged

xujuntwt95329 avatar Mar 11 '22 01:03 xujuntwt95329