Godot: modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path.

Created on 10 Jun 2020  Â·  22Comments  Â·  Source: godotengine/godot

Godot version:
v3.2.2.beta4.mono.official

OS/device including version:

Windows 10 Pro 1909

Issue description:

When opening a project, in the editor output, I get flooded with about 20 of the following errors:
modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path
These then change to:
modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.NullReferenceException: Object reference not set to an instance of an object
which continue as long as the editor is open.

These are expanded in the console as:

Unhandled Exception:
System.ArgumentException: Illegal characters in path.
  at System.IO.Path.Combine (System.String path1, System.String path2) [0x0003e] in <34e7ab706f1141f9b981d74fbe2f5560>:0
  at GodotTools.Utils.OS+<>c__DisplayClass39_0.<PathWhichWindows>b__1 (System.String dir) [0x00000] in <bf243baa94fe41ccbd98c8bbc3a78900>:0
  at System.Linq.Enumerable+SelectListIterator`2[TSource,TResult].MoveNext () [0x00048] in <fdc50bfd761741c0a0c2f052bf074a1c>:0
  at System.Linq.Enumerable+<SelectManyIterator>d__167`3[TSource,TCollection,TResult].MoveNext () [0x000d1] in <fdc50bfd761741c0a0c2f052bf074a1c>:0
  at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found) [0x0004f] in <fdc50bfd761741c0a0c2f052bf074a1c>:0
  at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00000] in <fdc50bfd761741c0a0c2f052bf074a1c>:0
  at GodotTools.Utils.OS.PathWhichWindows (System.String name) [0x00111] in <bf243baa94fe41ccbd98c8bbc3a78900>:0
  at GodotTools.Utils.OS.PathWhich (System.String name) [0x0000e] in <bf243baa94fe41ccbd98c8bbc3a78900>:0
  at GodotTools.BuildManager.Initialize () [0x00023] in <bf243baa94fe41ccbd98c8bbc3a78900>:0
  at GodotTools.GodotSharpEditor.EnablePlugin () [0x00453] in <bf243baa94fe41ccbd98c8bbc3a78900>:0
ERROR: debug_send_unhandled_exception_error: System.ArgumentException: Illegal characters in path.
   At: modules/mono/mono_gd/gd_mono_utils.cpp:371

and

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at GodotTools.HotReloadAssemblyWatcher.RestartTimer () [0x00000] in <bf243baa94fe41ccbd98c8bbc3a78900>:0
  at GodotTools.HotReloadAssemblyWatcher._Notification (System.Int32 what) [0x00008] in <bf243baa94fe41ccbd98c8bbc3a78900>:0
  at (wrapper managed-to-native) System.Threading.Monitor.Exit(object)
  at Godot.GodotTaskScheduler.ExecuteQueuedTasks () [0x00050] in <e870abd78d2142af92585d192bb3eb0a>:0
  at Godot.GodotTaskScheduler.Activate () [0x00001] in <e870abd78d2142af92585d192bb3eb0a>:0
  at (wrapper native-to-managed) Godot.GodotTaskScheduler.Activate(Godot.GodotTaskScheduler,System.Exception&)
ERROR: debug_send_unhandled_exception_error: System.NullReferenceException: Object reference not set to an instance of an object
   At: modules/mono/mono_gd/gd_mono_utils.cpp:371

respectively.

Steps to reproduce:

Minimal reproduction project:
None required.

bug regression editor mono

Most helpful comment

Ok, managed to reproduce it by visiting here..

https://www.soscisurvey.de/tools/view-chars.php

...I copied the space between 'string…' and 'or' which contains a few odd characters and pasted onto the end of one my path directories in the windows 'edit text' section of its environment var's editors.

Tried to fire up Godot and I'm back to seeing the issue, remove the characters and all's well again.

All 22 comments

Does this occur if you create a project in a path that doesn't contain spaces?

@Calinou Yes. I get the same errors with a new project in C:\Users\Marcel\Downloads\Godot\Test

Closing, because I can no longer reproduce this error.

I am getting this issue every time I open Godot. Please can this be reopened?

@dancroote What steps are necessary to reproduce this? Is it the same steps mentioned by OP?

@neikeq Yes, exactly the same.
This occurs when I open any project (the pong cs demo for example) or create a new one.

modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path. modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path. modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path. modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path. Switch Scene Tab modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path. modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.ArgumentException: Illegal characters in path. modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.NullReferenceException: Object reference not set to an instance of an object modules/mono/mono_gd/gd_mono_utils.cpp:371 - System.NullReferenceException: Object reference not set to an instance of an object

@dancroote Does your Windows username or the path to the project have any unusual characters (non-ASCII characters, ! symbol)?

No, it looks like this

C:\Users\Dan\Documents\GodotProjects\test

Can you still reproduce this issue with this build ("pre RC6" build, i.e. same as RC5 but with a few extra Mono fixes):
https://downloads.tuxfamily.org/godotengine/testing/3.2.3-pre-rc6-mono/

I'll try it and let you know

You can now try with the official 3.2.3 RC6 build: https://godotengine.org/article/release-candidate-godot-3-2-3-rc-6

The only cause I can think of for the Illegal characters in path exception is that there's an invalid character in one of the paths of the PATH env var or in the path returned by Directory.GetCurrentDirectory().

If you can still reproduce this with 3.2.3 RC6 could you try debugging the C# editor code? You would need to place a breakpoint in PathWhichWindows:

https://github.com/godotengine/godot/blob/49b3750b3671e6c0c3edd0ca4d41df85593ff26f/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs#L102-L125

Specially I would like to know what are the contents of searchDirs when the exception is thrown.

BTW, to debug the editor code I run Godot with the env var:

GODOT_MONO_DEBUGGER_AGENT=--debugger-agent=transport=dt_socket,address=127.0.0.1:22685,embedding=1,server=y,suspend=n

This tells it to listen for debuggers on port 22685 which you can configure your IDE/editor to attach to.

@akien-mga I have tried 3.2.3 RC6 build and the errors still occur.

@neikeq I'm happy to try that. How do I run Godot with an env variable?

How do I run Godot with an env variable?

  • Press Windows + R and enter cmd in the Run dialog to open a command prompt.
  • Paste the following line into the command prompt and press Enter (you may need to press it twice):
set GODOT_MONO_DEBUGGER_AGENT=--debugger-agent=transport=dt_socket,address=127.0.0.1:22685,embedding=1,server=y,suspend=n
  • Use the cd <path> command to reach the directory where your Godot executable is located. You can drag-and-drop a folder to the command prompt to get its path.
  • Use <name of Godot executable>.exe C:\Path\to\project.godot to open the project directly in the editor. (The project must be opened directly, as the project manager won't pass environment variables to the editor.)

Thanks @Calinou , that worked.
I'm now struggling to find the file containing the script with PathWhichWindows, so I can add a breakpoint as suggested.
Could someone please help with this?

It seems to be this file:

$ rg PathWhichWindows
modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
99:            return IsWindows ? PathWhichWindows(name) : PathWhichUnix(name);
102:        private static string PathWhichWindows([NotNull] string name)

I am also experiencing this error. It is preventing me from opening the project in the Godot editor. I'm on Windows 10, Godot 3.2.3 stable mono. I'm very technically illiterate so sorry if I'm not very helpful with this. I have another project that doesn't use C# and that one can be opened in the editor

I had this issue but solved it with a hint from @neikeq in the comment above regarding the environment PATH variable. I first went through and checked all the directories / folders actually existed in my PATH var and was still getting the error.

I echoed out PATH into a terminal session and all looked ok there... So I went into the Windows system properties environment variables GUI and in there you we get a list of the elements making up the path in a list, all looked ok still..

So I hit the 'edit text' button you get there and scanning through and sure enough there was a load of whitespace or maybe non-printable chars, anyway, removed those characters out and everything started working again.

:)

If the problem was with illegal characters in PATH, we can make PathWhich check for that.
Still weird to have such bad entries in PATH. I hope that's indeed the case and not some encoding problem on our code.

I'm 43, almost 44 and worked in IT all my life, first time I've ever seen something like it. Odd thing was I didn't see those characters when I echoed them out into the terminal so had me scratching my head.

Just for fun I tried adding a few spaces to the end off one of the paths in the same editor I removed the odd characters that looked like white space and Godot fires up fine still so does indeed look like some illegal characters had made its way into the path, bizarre.

Ok, managed to reproduce it by visiting here..

https://www.soscisurvey.de/tools/view-chars.php

...I copied the space between 'string…' and 'or' which contains a few odd characters and pasted onto the end of one my path directories in the windows 'edit text' section of its environment var's editors.

Tried to fire up Godot and I'm back to seeing the issue, remove the characters and all's well again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ndee85 picture ndee85  Â·  3Comments

bojidar-bg picture bojidar-bg  Â·  3Comments

gonzo191 picture gonzo191  Â·  3Comments

SleepProgger picture SleepProgger  Â·  3Comments

ducdetronquito picture ducdetronquito  Â·  3Comments