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 possible data race #426

Closed
ryancaicse opened this issue Apr 25, 2022 · 1 comment
Closed

A possible data race #426

ryancaicse opened this issue Apr 25, 2022 · 1 comment

Comments

@ryancaicse
Copy link

ryancaicse commented Apr 25, 2022

Should g.serverHalt = 1 be protected b lock g.serverMutex?

sqlcipher/src/test_server.c

Lines 508 to 513 in 0663d85

void sqlite3_server_stop(void){
g.serverHalt = 1;
pthread_cond_broadcast(&g.serverWakeup);
pthread_mutex_lock(&g.serverMutex);
pthread_mutex_unlock(&g.serverMutex);
}

Like this.

 void sqlite3_server_stop(void){ 
   pthread_mutex_lock(&g.serverMutex); 
   g.serverHalt = 1; 
   pthread_cond_broadcast(&g.serverWakeup); 
   pthread_mutex_unlock(&g.serverMutex); 
 } 
@sjlombardo
Copy link
Member

Hello @ryancaicse sorry for the delayed response on this. After a quick review of the server implementation, I don't think that the update to serverHalt needs to be guarded by the serverMutex since it is declared volatile and only used to control the thread run loop.

That said I'm not deeply familiar with that extension because it isn't really a core "feature" of SQLite or a supported extension for SQLCipher.

Since the test_server.c is part of the upstream SQLite sources, if you are thinking about using it you could consider posting a general question (i.e. not related to SQLCipher) up to the SQLite Forum.

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

2 participants