Skip to content
Prev 61835 / 63424 Next

R-4.3 version list.files function could not work correctly in chinese

On 8/15/23 09:04, Ivan Krylov wrote:
Thanks, yes, I can reproduce the problem. Some Windows functions impose 
260 wide characters limit, but other 260 bytes limit, so one can create 
a file with a name too long to be found by FindNextFileA.

In R 4.2, we used readdir() from mingw-w64, which itself used findnext, 
which however had the same problem, it used a buffer of size 260 bytes 
and from the code of mingw-w64 and the Windows documentation, it should 
have behaved the same, it should have stopped the search on such a long 
file name. However, in my use case, R 4.2.3 crashed inside findnext due 
to stack overrun, R 4.1.3 worked, but clearly it would require a 
different use case to overrun this buffer as it didn't use UTF-8. This 
suggests that findnext didn't have a check for this and hence caused 
memory corruption, which can lead to a crash or work by coincidence. 
Which could have been the case for the user reporting this as a 
regression compared to R 4.2. But it is not a regression, the problem 
existed for long.

So, yes, we'd probably have to use wide variants of FindNext/FindFirst. 
I'll fix.

Thanks for debugging this,
Tomas

Thread (20 messages)

叶月光 R-4.3 version list.files function could not work correctly in chinese Aug 10 Ivan Krylov R-4.3 version list.files function could not work correctly in chinese Aug 11 Yihui Xie R-4.3 version list.files function could not work correctly in chinese Aug 11 Ivan Krylov R-4.3 version list.files function could not work correctly in chinese Aug 12 叶月光 答复: R-4.3 version list.files function could not work correctly in chinese Aug 12 Ivan Krylov R-4.3 version list.files function could not work correctly in chinese Aug 13 yu gong R-4.3 version list.files function could not work correctly in chinese Aug 13 yu gong R-4.3 version list.files function could not work correctly in chinese Aug 13 Ivan Krylov R-4.3 version list.files function could not work correctly in chinese Aug 13 叶月光 答复: R-4.3 version list.files function could not work correctly in chinese Aug 13 Kevin Ushey 答复: R-4.3 version list.files function could not work correctly in chinese Aug 14 Tomas Kalibera R-4.3 version list.files function could not work correctly in chinese Aug 14 Ivan Krylov R-4.3 version list.files function could not work correctly in chinese Aug 15 Tomas Kalibera R-4.3 version list.files function could not work correctly in chinese Aug 15 Tomas Kalibera 答复: R-4.3 version list.files function could not work correctly in chinese Aug 15 Tomas Kalibera R-4.3 version list.files function could not work correctly in chinese Aug 16 yu gong R-4.3 version list.files function could not work correctly in chinese Aug 16 Ivan Krylov R-4.3 version list.files function could not work correctly in chinese Aug 16 Tomas Kalibera R-4.3 version list.files function could not work correctly in chinese Aug 16 Tomas Kalibera R-4.3 version list.files function could not work correctly in chinese Aug 16