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

A locking issue in cherokee_server_free #1278

Open
ryancaicse opened this issue Mar 25, 2022 · 4 comments
Open

A locking issue in cherokee_server_free #1278

ryancaicse opened this issue Mar 25, 2022 · 4 comments

Comments

@ryancaicse
Copy link

Hi, there is only an unlocking in the loop, should it be a bug?

webserver/cherokee/server.c

Lines 266 to 269 in 5b1dbdb

list_for_each (i, &srv->thread_list) {
THREAD(i)->exit = true;
CHEROKEE_MUTEX_UNLOCK (&srv->listeners_mutex);
}

@skinkie
Copy link
Member

skinkie commented Mar 25, 2022

It may be, at this point I don't understand the code here. Did this produce a hang or crash at your side?

@ryancaicse
Copy link
Author

Hi, I guess, the lock is supposed to protect the THREAD(i)->exit = true; from races. May be there is a missing CHEROKEE_MUTEX_LOCK.

@skinkie
Copy link
Member

skinkie commented Mar 25, 2022

I just looked through the code (thread.c) to see what is is used for there. But I wonder if this is actually the way to unlock what has been locked there.

@ryancaicse
Copy link
Author

@skinkie It seems, in this loop, an identical lock is released multiple times rather than releasing different indexed locks. Thus, it is very likely a bug.

I also tried to investigate the reason. However, I could not find the possible held lock at that program point. I think it is more likely that the lock is supposed to protect the THREAD(i)->exit = true; from races and there is a missing CHEROKEE_MUTEX_LOCK.

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

No branches or pull requests

2 participants