Stream: git-wasmtime

Topic: wasmtime / Issue #2855 "C API for WASI": Segmentation fau...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2021 at 12:23):

MartinKolbAtWork opened Issue #2855:

When calling wasi_config_delete() on a configuration that was created with wasi_config_new(), I get a Segmentation fault.

Test Case

I used the official WASI example of wasmtime as a template:
main.c

I added wasi_config_delete(wasi_config); in the line before return 0 of the main function. I did this because the documentation of wasi_config_new() reads:

The caller is expected to deallocate the returned configuration

Steps to Reproduce

Running the program with this one additional line containing wasi_config_delete causes the process to crash with a segmentation fault.

I discovered that wasi_config_delete can be called without problems up to the point when wasi_instance_new is called. It seems that wasi_instance_new takes ownership of parts of the data that is stored in wasi_config_t.

Expected Results

wasi_config_delete should delete the wasi_config_t structure without any negative side effects.

Actual Results

Segfault!

Versions and Environment

Wasmtime version or commit: Fresh pull of wasmtime on April 19th (200d7f1df668db31baf14f1453ab8cee54724292)

Operating system: Ubuntu 20.04

Architecture: x86_64 GNU/Linux

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2021 at 12:23):

MartinKolbAtWork labeled Issue #2855:

When calling wasi_config_delete() on a configuration that was created with wasi_config_new(), I get a Segmentation fault.

Test Case

I used the official WASI example of wasmtime as a template:
main.c

I added wasi_config_delete(wasi_config); in the line before return 0 of the main function. I did this because the documentation of wasi_config_new() reads:

The caller is expected to deallocate the returned configuration

Steps to Reproduce

Running the program with this one additional line containing wasi_config_delete causes the process to crash with a segmentation fault.

I discovered that wasi_config_delete can be called without problems up to the point when wasi_instance_new is called. It seems that wasi_instance_new takes ownership of parts of the data that is stored in wasi_config_t.

Expected Results

wasi_config_delete should delete the wasi_config_t structure without any negative side effects.

Actual Results

Segfault!

Versions and Environment

Wasmtime version or commit: Fresh pull of wasmtime on April 19th (200d7f1df668db31baf14f1453ab8cee54724292)

Operating system: Ubuntu 20.04

Architecture: x86_64 GNU/Linux

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2021 at 14:08):

alexcrichton commented on Issue #2855:

Are you using wasm_engine_new_with_config? If so that function is documented as taking ownership of the wasm_config_t so you don't need to free it.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2021 at 14:19):

MartinKolbAtWork commented on Issue #2855:

Are you using wasm_engine_new_with_config? If so that function is documented as taking ownership of the wasm_config_t so you don't need to free it.

@alexcrichton Thanks for pointing this out. Actually I'm using wasi_instance_new , and this function has the same semantics of taking ownership of the config object. I should have read the f***ing manual in more detail ;-)

I'll close this issue because this information resolves my problem. Thanks for looking into this.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2021 at 14:19):

MartinKolbAtWork closed Issue #2855:

When calling wasi_config_delete() on a configuration that was created with wasi_config_new(), I get a Segmentation fault.

Test Case

I used the official WASI example of wasmtime as a template:
main.c

I added wasi_config_delete(wasi_config); in the line before return 0 of the main function. I did this because the documentation of wasi_config_new() reads:

The caller is expected to deallocate the returned configuration

Steps to Reproduce

Running the program with this one additional line containing wasi_config_delete causes the process to crash with a segmentation fault.

I discovered that wasi_config_delete can be called without problems up to the point when wasi_instance_new is called. It seems that wasi_instance_new takes ownership of parts of the data that is stored in wasi_config_t.

Expected Results

wasi_config_delete should delete the wasi_config_t structure without any negative side effects.

Actual Results

Segfault!

Versions and Environment

Wasmtime version or commit: Fresh pull of wasmtime on April 19th (200d7f1df668db31baf14f1453ab8cee54724292)

Operating system: Ubuntu 20.04

Architecture: x86_64 GNU/Linux


Last updated: Oct 23 2024 at 20:03 UTC