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

Possible data race during handshake #20

Open
savethebeesandseeds opened this issue May 28, 2022 · 0 comments
Open

Possible data race during handshake #20

savethebeesandseeds opened this issue May 28, 2022 · 0 comments

Comments

@savethebeesandseeds
Copy link

savethebeesandseeds commented May 28, 2022

A possible data raise might mean some mutex lock is missing.
on running Valgrind Helgrind, output shows:

==62338== Possible data race during write of size 1 at 0x1FC8CB94 by thread #2
==62338== Locks held: 1, at address 0x1FC8CB38
==62338== at 0x4B129E5: libwsclient_handshake_thread (wsclient.c:792)
==62338== by 0x484F30D: mythread_wrapper (hg_intercepts.c:406)
==62338== by 0x1C467B19: start_thread (pthread_create.c:443)
==62338== by 0x1C4EB8F3: clone (clone.S:100)
==62338==
==62338== This conflicts with a previous read of size 1 by thread #1
==62338== Locks held: none
==62338== at 0x4B1157A: libwsclient_run (wsclient.c:50)

Fairly simple to resolve:

change:
if(pthread_create(&client->handshake_thread, NULL, libwsclient_handshake_thread, (void *)client)) {

by:
ibwsclient_handshake_thread((void *)client);

omitting the threading for the handshake solves it.

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

No branches or pull requests

1 participant