Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mute an UBSan check error for SCOPED_LOCK macro #283

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions thread/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ inline int posix_memalign(void** memptr, size_t alignment, size_t size) {
by target vcpu in resume_thread(), when its runq becomes empty;
*/

#define SCOPED_MEMBER_LOCK(x) SCOPED_LOCK(&(x)->lock, ((bool)x) * 2)

Choose a reason for hiding this comment

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

when x is null, it doesn't actually do the locking.


// Define assembly section header for clang and gcc
#if defined(__APPLE__)
#define DEF_ASM_FUNC(name) ".text\n" \
Expand Down Expand Up @@ -1199,7 +1197,8 @@ R"(
__attribute__((always_inline)) inline
Switch prepare_usleep(uint64_t useconds, thread_list* waitq, RunQ rq = {})
{
SCOPED_MEMBER_LOCK(waitq);
spinlock* waitq_lock = waitq ? &waitq->lock : nullptr;
SCOPED_LOCK(waitq_lock, ((bool) waitq) * 2);
SCOPED_LOCK(rq.current->lock);
assert(!AtomicRunQ(rq).single());
auto sw = AtomicRunQ(rq).remove_current(states::SLEEPING);
Expand Down