NVlabs / FPSci

Aim Training Experiments
Other
67 stars 23 forks source link

getenv("USERNAME") failures in some cases #398

Closed joohwankimNV closed 1 year ago

joohwankimNV commented 1 year ago

getenv("USERNAME") (at line 7 of SystemInfo.cpp) sometimes throws access violation exception. This happened to me when I newly reinstalled my Windows 10. Seems like a bug on the Windows side, specifically the installation process.

While waiting for a solution, here is how I get around it. The exception is resolved when I manually set the username by doing Windows Key + R -> type netplwiz -> double click on my user account -> enter a user name

bboudaoud-nv commented 1 year ago

I believe this issue is sourced from the result of getenv("USERNAME")( a const char *) coming back as a null pointer. This then fails the assignment to the info.username (a G3D::String) in line 7. We need to dig a bit deeper on this, but there should probably be a null check on the result of getenv("USERNAME") before we directly assign this value to the info.username field.

bboudaoud-nv commented 1 year ago

Can confirm that this matches the documented behavior of std::getenv(). The null return value is expected for a value not in the environment variable. We should certainly null check these values in FPSci and report some default value (like "unknown") when nulls are returned.