Stream: git-wasmtime

Topic: wasmtime / issue #3605 clock() function in ctime always r...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2021 at 13:54):

gdjs2 opened issue #3605:

Test Case

#include <cstdio>
#include <ctime>

int main() {
    clock_t time = clock();
    printf("%ld\n", time);
}

Steps to Reproduce

Expected Results

The clock tick after the module start to run.

Actual Results

0

Versions and Environment

Wasmtime version or commit: 0.28

Operating system: macOS 12.1 & Ubuntu 20.04

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2021 at 13:54):

gdjs2 labeled issue #3605:

Test Case

#include <cstdio>
#include <ctime>

int main() {
    clock_t time = clock();
    printf("%ld\n", time);
}

Steps to Reproduce

Expected Results

The clock tick after the module start to run.

Actual Results

0

Versions and Environment

Wasmtime version or commit: 0.28

Operating system: macOS 12.1 & Ubuntu 20.04

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2021 at 15:15):

alexcrichton commented on issue #3605:

Can you share the wasm binary and/or the wasi-sdk version that you're using? Using wasi-sdk-14.0 and your source code I have to compile with -lwasi-emulated-process-clocks which appears to fix the issue because the return value is non-zero, so this may have been a bug fixed in wasi-sdk

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2021 at 15:33):

gdjs2 commented on issue #3605:

I used wasi-sdk-12.0 and when I switched to wasi-skd-14.0 it will give me the warning when I try to use clock() in my source code.

But when I used wasi-sdk-12.0 it shown nothing and compiled successfully. This WASM module could give non-zero number on Wasmer and WAMR but given zero on wasmtime.

That's why I guess it is the problem of wasmtime. I upload the WASM module and you can have a check.

clock.wasm.zip

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2021 at 15:37):

alexcrichton commented on issue #3605:

@sunfishcode may wish to confirm, but I believe the clock function was simply buggy in wasi-sdk-12.0

view this post on Zulip Wasmtime GitHub notifications bot (Dec 16 2021 at 15:47):

gdjs2 commented on issue #3605:

I believe so because the wasi-sdk-14.0 shows that the CPU tick is not supported by WASI currently and the clock() function uses a wall clock to emulate this func.

Anyway it does not seem to be a big problem. Thanks a lot for your attention.


Last updated: Dec 23 2024 at 13:07 UTC