Opened 7 years ago

Last modified 7 years ago

#12079 new Bugs

Infinite loop in boost:: filesystem::directory_iterator

Reported by: alexb.x42@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost Release Branch Severity: Problem
Keywords: Cc:

Description

Debian Jessie (GLIBC 2.19)

I have an NTFS partition created in Windows. On that partition there is a file with very long filename that contains Cyrillic characters: D:\test\очень_длинное_имя_для_файла_очень_длинное_имя_для_файла_очень_длинное_имя_для_файла_очень_длинное_имя_для_файла_очень_длинное_имя_для_файла_очень_длинное_имя_для_файла_очень_длинное_имя_для_файла_очень_длинное_имя_для_файла_очень_длинное_имя_для_ф.txt

I attached this partition to my linux box and mounted it to /media/sk1ff/EEBEDC27BEDBE65D/. So, when I execute the following simple piece of code:

  fs::directory_iterator it("/media/sk1ff/EEBEDC27BEDBE65D/test"), dir_end;    
  for (; it != dir_end; ++it)
  {
    std::cout << it->path() << std::endl;
  }

it falls into an infinite loop.

Attachments (1)

fs_dir_iter_fix.diff (597 bytes ) - added by alexb.x42@… 7 years ago.

Download all attachments as: .zip

Change History (2)

by alexb.x42@…, 7 years ago

Attachment: fs_dir_iter_fix.diff added

comment:1 by alexb.x42@…, 7 years ago

I checked with the debugger, and it seems that the problem is that the function readdir_r() for that file returns an error code 36 (ENAMETOOLONG). But errno is still zero. With this .diff in attachment, it started to work correctly (i.e. generates an error). Well, at least for this specific case :)

Note: See TracTickets for help on using tickets.