WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@TianlongLiang
Copy link
Collaborator

No description provided.

@yamt
Copy link
Collaborator

yamt commented Dec 8, 2025

can you elaborate use cases a bit?

@TianlongLiang
Copy link
Collaborator Author

can you elaborate use cases a bit?

For example, if a WASM module calls shared_heap_malloc a few times and an exception occurs before it gets a chance to free it, then the WAMR runtime-managed shared heap will have some dangling pointer(some memory block can't be allocated) until the runtime destroys and reinitializes. This api provides a lighter way to reset(allow the whole WAMR runtime-managed shared heap to become allocatable) the shared heaps without re-initializing the runtime.

@yamt
Copy link
Collaborator

yamt commented Dec 8, 2025

can you elaborate use cases a bit?

For example, if a WASM module calls shared_heap_malloc a few times and an exception occurs before it gets a chance to free it, then the WAMR runtime-managed shared heap will have some dangling pointer(some memory block can't be allocated) until the runtime destroys and reinitializes. This api provides a lighter way to reset(allow the whole WAMR runtime-managed shared heap to become allocatable) the shared heaps without re-initializing the runtime.

so,

  • it's an equivalent of destroy + re-create
  • not intended to be used for a chain being used by running instances

right?

unsigned int wasm_file_size = 0;
unsigned int stack_size = 16 * 1024, heap_size = app_heap_size;
char error_buf[128] = { 0 };
char error_buf[128] = {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a change for "fix some warnings"?
what warning?

EXPECT_EQ(offset, offset_after_reset);
EXPECT_EQ(native_ptr, native_ptr_after_reset);

/* Only on some platform, the os_mmap will memset the memory to 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean that in some cases shared memory may have uninitialized user-visible contents?
is it documented somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants