IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.63k stars 4.83k forks source link

Realsense viewer and librealsense failing with "failed to convert special folder: errno=42" #13513

Open warmist opened 1 week ago

warmist commented 1 week ago
Required Info
Camera Model Does not matter
Firmware Version Does not matter
Operating System & Version Windows 10
Platform PC
SDK Version 2.56.2.7411
Language C++/viewer
Segment all

Source of error is this line: https://github.com/IntelRealSense/librealsense/blob/e1688cc318457f7dd57abcdbedd3398062db3009/third-party/rsutils/src/special-folder.cpp#L81

wcstombs_s returns value 42 which is EILSEQ i.e. it fails to convert wide string to multibyte string.

There are numerous issues closed with this but nobody dug down to the source. It seems that this only happens if your username has unicode characters.

MartyG-RealSense commented 1 week ago

Hi @warmist Have you visited the advice about the errno=42 error at https://github.com/IntelRealSense/librealsense/issues/13037 please?

https://github.com/IntelRealSense/librealsense/issues/13457#issuecomment-2432900837 has instructions for finding on a Windows computer and deleting the realsense-config.json configuration file mentioned in that link.

warmist commented 1 week ago

Hi @MartyG-RealSense. Thanks for answering.

Yes, i've seen both of them. Also i've looked into all the duplicates.

13037 does not apply because "problem due to an uninitialized json variable" cannot happen as it's before file loading. It's an error when resolving (and transforming) the path to appdata folder. There is no "realsense-config.json" file anywhere in appdata (also related: apps shouldn't write to appdata and should create a folder).

https://github.com/IntelRealSense/librealsense/issues/13457#issuecomment-2432900837 yes, i've looked into hidden files as well. Also you can access the folder faster if you type "%appdata%" into explorer path (i.e. the part where it has "C:\etc...")

I'll try to setup a minimal repro as i feel this issue might be hard to reproduce without setting up a windows machine with username with unicode chars in it.

warmist commented 4 days ago

Here is minimal reproduction: https://gist.github.com/warmist/e0b1927387864566db2804c50d0cf512

In my environment wcstombs_s fails with error=42. Content of path: image (see unicode letter in path)

warmist commented 4 days ago

Further research shows that wcstombs_s uses current locale and current locale is "en-us" and fails to convert unicode character. It should use _wcstombs_s_l with new locale (i.e. _create_locale(LC_ALL,"");)

MartyG-RealSense commented 3 days ago

I had a discussion with my Intel RealSense colleagues about the 'failed to convert special folder: errno=42' error earlier in 2024, so I will follow up on it and pass your kindly provided information to them for their consideration.