fishtest icon indicating copy to clipboard operation
fishtest copied to clipboard

non-ascii paths.

Open vondele opened this issue 3 years ago • 20 comments

an exchange in discord about a crashing worker getraideBFF https://tests.stockfishchess.org/tests/view/61d800f1f5fd40f357469b0a revealed that that worker was running into https://github.com/official-stockfish/Stockfish/issues/3424

This can't be easily fixed in SF, but maybe the worker code detect the fact it is running in a path that contains non-ascii characters (cyrillic) and detect it?

vondele avatar Jan 07 '22 15:01 vondele

I've documented this limitation here https://github.com/glinscott/fishtest/wiki/Running-the-worker:-overview#install-the-worker

vondele avatar Jan 07 '22 15:01 vondele

I am curious. Why can SF not handle non-ascii strings?

vdbergh avatar Jan 07 '22 15:01 vdbergh

I guess it is a windows problem. Windows cannot handle UTF-8 path names (the most common encoding on the planet). So one has to convert first to UTF-16.

First result on Google https://stackoverflow.com/questions/7153935/how-to-convert-utf-8-stdstring-to-utf-16-stdwstring

vdbergh avatar Jan 07 '22 15:01 vdbergh

yes, and the SF code needs to use the right types for filenames in all places etc... it is definitely not completely trivial to get right.

vondele avatar Jan 07 '22 15:01 vondele

The worker could send the short path name to SF: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getshortpathnamew if non-asci characters are detected in a path name (is it only the NNUE path?).

vdbergh avatar Jan 07 '22 15:01 vdbergh

I think it is not worth trying to do it from the worker. Things in SF it self might break (like it searches for the net in a couple of directories).

vondele avatar Jan 07 '22 15:01 vondele

Ok. Not allowing non asci characters in filenames probably excludes a sizable part of the world's population though. Nowadays people expect unicode to "just work".

EDIT. Fixed typo.

vdbergh avatar Jan 07 '22 15:01 vdbergh

yes, I agree, so well tested patches for SF would be welcome there :-) For whatever reason the Lc0 people said it is really non-trivial, so I take their word for it.

vondele avatar Jan 07 '22 15:01 vondele

I really think this is fixable on the worker's side. This is the cuplrit

option.EvalFile=/home/fishtest/fishtest/worker/testing/nn-13406b1dcbe0.nnue

The current directory is /home/fishtest/fishtest/worker/testing. So there doesn't seem to be any need to supply a path at all.

vdbergh avatar Jan 07 '22 16:01 vdbergh

OK, if that fixes it, I'm of course fine with it.

vondele avatar Jan 07 '22 16:01 vondele

Where is the code in SF that searches for the net?

vdbergh avatar Jan 07 '22 16:01 vdbergh

vector<string> dirs = { "<internal>" , "" , CommandLine::binaryDirectory , stringify(DEFAULT_NNUE_DIRECTORY) };

If I interpret this correctly it will first search in the current directory. Which is what we want.

vdbergh avatar Jan 07 '22 16:01 vdbergh

it will first use the embedded net, after that it will search the directory of the binary.... that would probably go wrong.

vondele avatar Jan 07 '22 16:01 vondele

No, the empty string "" is in the second place. That should be the current directory.

vdbergh avatar Jan 07 '22 16:01 vdbergh

sorry, right...

vondele avatar Jan 07 '22 16:01 vondele

If it doesn't work we can also embed the net (first copy the downloaded/cached net to the build directory).

vdbergh avatar Jan 07 '22 17:01 vdbergh

we specifically didn't do that since that would make the cache of the binaries large in size.

vondele avatar Jan 07 '22 19:01 vondele

It is fixed on the worker’s side now. However it might still be a good idea to trace the cause of the crash in SF and print an error message instead. Some system call used by SF must return with an error.

vdbergh avatar Jan 08 '22 05:01 vdbergh

I guess SF doesn't actually crash but just doesn't find the net and then exits. That would be perfectly fine of course.

vdbergh avatar Jan 08 '22 07:01 vdbergh

I think that's what happens, but can't test.

vondele avatar Jan 08 '22 07:01 vondele