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

Is uiThread required to avoid data races? #2299

Closed
niklasf opened this issue Sep 12, 2019 · 6 comments
Closed

Is uiThread required to avoid data races? #2299

niklasf opened this issue Sep 12, 2019 · 6 comments

Comments

@niklasf
Copy link
Contributor

niklasf commented Sep 12, 2019

Apologies if #1990 was closed intentionally. If so, I'd appreciate brief explanantion.


uiThread is used here (a):

pos.set(StartFEN, false, &states->back(), uiThread.get());

But not here (b):

pos.set(fen, Options["UCI_Chess960"], &states->back(), Threads.main());

This means that there's either a data race in (b), or an upportunity to simplify away uiThread in (a). (Or a third option, that I am missing). Can anyone figure out which it is?

@vondele
Copy link
Member

vondele commented Sep 14, 2019

the rationale for uiThread is in the commit message 750dfa0 . If I understand correctly to allow certain commands while search is going on. That's a bit of a grey area, since UCI suggests that this is not conforming. So, the one at line 196 would be a feature, while the one at line 70 is OK for conforming uci commands. This is tricky code, I would recommend to compile with the sanitize=thread option, and see what happens when issuing UCI commands during search.

@xoto10
Copy link
Contributor

xoto10 commented Sep 17, 2019

@niklasf
The comment vondele refers to says the problem is a data race if eval is requested while searching. It seems to me we could just deny this eval request, e.g. see my branch uithread2

@vondele
Copy link
Member

vondele commented Sep 18, 2019

yes, I did a quick check, and even with this uiThread in place, things are not race free issuing an eval during an ongoing search. It might have been a partial fix, but not the full fix. In that case, it is not clear if there is any benefit from the code.

snicolet pushed a commit that referenced this issue Oct 19, 2019
With the current questions and issues around threading, I had a look at
#2299.

It seems there was a problem with data races when requesting eval via UCI while
a search was already running. To fix this an extra thread uithread was created,
presumably to avoid an overlap with Threads.main() that was causing problems.
Making this eval request seems to be outside the scope of UCI, and @vondele also
reports that the data race is not even fixed reliably by this change. I suggest
we simplify the threading here by removing this uithread and adding a comment
signaling that user should not request eval when a search is already running.

Closes #2310

No functional change.
@vondele
Copy link
Member

vondele commented Oct 20, 2019

this issue can be closed now.

@ddugovic
Copy link

@niklasf
Copy link
Contributor Author

niklasf commented Oct 20, 2019

Thanks all.

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

4 participants