Godot: Engine hangs when trying to preload a resource from script starting with OS reserved names

Created on 12 Jul 2018  路  14Comments  路  Source: godotengine/godot

Godot version:
3.0+, 4.0+

OS/device including version:
Windows 10 1803 build 17134.165

Issue description:
I have tried to preload a script condition.gd using relative path:

gif

const Condition = preload("con 
# engine hangs after `con` is typed

After that the engine hangs (no crash), with the following output (master, in official just hangs the engine)

WARNING: _open: Case mismatch opening requested file 'con.remap', stored as 'con' in the filesystem. This file will not open when exported to other case-sensitive platforms.
     At: drivers/windows/file_access_windows.cpp:102

The issue is most likely related to the fact that parser tries to manipulate OS reserved names as pointed by KellyThomas

Workaround:
gif2

馃槃

Minimal reproduction project:
con-preload-hang.zip

bug windows editor

Most helpful comment

Probably related to this constraint:

Do not use the following reserved names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.

https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file

All 14 comments

Probably related to this constraint:

Do not use the following reserved names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.

https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file

@KellyThomas seems like it, tested on names like com1, aux ... same hang.

So how should we fix this, blacklist all filenames starting with those strings in FileAccess? I fear it may hurt performance if each file access requires comparing to 20 strings or so.

But why completion fires the issue? Is really weird.
Maybe on load/preload and on windows, it can avoid trying to autocomplete the first 3 characters if starts with those combinations (autocomplete from the 4th character).

this kinda sucks, i wonder where should we avoid this

Also hangs for names like "con.txt" and "con "

We can explicitly tell the Win32 apis we want files by prefixing all types with \\?\. This will let a particular string straight through to the windows file apis without going through the other namespaces so \\?\c:\con is fine.

@hpvb That sounds like an interesting option.

Whatever fix we choose, we must ensure that it doesn't make cross-platform dev and export more cumbersome. The proposed fix in #25805 would imply that some names can't be used while on Windows, but you can use them while on Linux and export a broken Windows build, which isn't good.

@akien-mga if we use the explicit 'file namespace' prefix in Windows you can use names like 'con' just fine.

@hpvb Sure that's another alternative however using explicit namespace to create files with reserved names on windows (e.g. "\\?c:con.txt") makes them hard to manage (e.g. Windows Explorer cannot move or delete such files) so it has its own cons. I've got no idea if there's any fully cross platform solution to the problem.

In my opinion the issue is that of the typeahead prediction. There are other programs that let you create unfortunate names. Short of testing all filenames saved against a blacklist there's not a lot that can be done. And this is a separate issue in my opinion.

So how should we proceed with this issue?

It sounds like #25805 will not be merged, so should we close it? And if so, what solution should be favored?

IMO we can try @hpvb's proposal, or have a list of forbidden names for cross-platform support... but that feels pretty hacky.

The fix do not need to be cross platform because is a platform specific bug, the \\ solution seems simple enough for windows.

Well Godot's behaviour does need to be the same cross platform. Currently you can create a "con" file on Linux, then switch to Windows and get problems (either you or a fellow Dev via VCS). So if one platform has filename limitations, the other platforms which can create files need to take it into account.

But if we lift the limitation with @hpvb's proposal, it should be ok.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timoschwarzer picture timoschwarzer  路  3Comments

mefihl picture mefihl  路  3Comments

nunodonato picture nunodonato  路  3Comments

Spooner picture Spooner  路  3Comments

SleepProgger picture SleepProgger  路  3Comments