Skip to content

Conversation

@no1wudi
Copy link
Collaborator

@no1wudi no1wudi commented Aug 1, 2022

No description provided.

Comment on lines 1157 to 1160
if (!append_thread_info_node(info_node))
goto fail3;

if (!bh_hash_map_insert(sem_info_map, (void *)name, info_node)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

An issue for multi-thread: suppose thread A opens a semaphore with a name, and the info_node is added into both thread_info_map and sem_info_map, and B opens a semaphore with the same name, this time it will just return success in L1140 as is has been created. And then thread A exits, the semaphore may be destroyed during thread exiting, but thread B still uses it, which might cause core dump.

Copy link
Collaborator Author

@no1wudi no1wudi Aug 3, 2022

Choose a reason for hiding this comment

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

Now it will check the status of sem before using it

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

Comment on lines 1157 to 1160
if (!append_thread_info_node(info_node))
goto fail3;

if (!bh_hash_map_insert(sem_info_map, (void *)name, info_node)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

Comment on lines 200 to 201
* semaphore. The semaphore is identified by name. For details of
* the construction of name
Copy link
Collaborator

Choose a reason for hiding this comment

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

"For details of the construction of name" this statement seems incomplete

Copy link
Collaborator Author

@no1wudi no1wudi Aug 5, 2022

Choose a reason for hiding this comment

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

Yes, docs added.
Most description of these APIs is from https://man7.org/linux/man-pages/man3/sem_open.3.html


#include "bh_common.h"
#include "bh_log.h"
#include "platform_api_extension.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should include"bh_platform.h" instead, "platform_api_extension.h" is an internal file of core/shared and is included in "bh_platform.h", normally we don't include it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, this was added by clangd in my editor, I'll remove it.

@wenyongh wenyongh merged commit f3f8d68 into bytecodealliance:main Aug 8, 2022
loganek pushed a commit to loganek/wasm-micro-runtime that referenced this pull request Aug 31, 2022
…e#1345)

Implement POSIX semaphore support for linux platform
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
…e#1345)

Implement POSIX semaphore support for linux platform
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.

3 participants