Boost C++ Libraries: Ticket #12108: boost::filesystem::canonical() enters infinite loop when current path is a directory symlink on windows https://svn.boost.org/trac10/ticket/12108 <p> On Windows platforms, when the current path is a directory symlink, boost::filesystem::canonical() enters an infinite loop. </p> <p> Verified using attached program on Windows 8.1 and Windows Server 2012. </p> <p> The problem occurs because when the current path is a directory symlink then boost::filesystem::is_symlink(path("c:")) returns true. </p> <p> Assuming the following paths: </p> <p> myDir = c:\temp\symlink-example\dir mySym = c:\temp\symlink-example\sym -&gt; myDir myFile = c:\temp\symlink-example\dir\hello.txt </p> <p> When current path is set to mySym and canonical(myFile) is called: </p> <ul><li>The path components of myFile are iterated over (operations.cpp:827) </li><li>"c:" is the first component. It is considered a symlink and expanded (operations.cpp:844) </li><li>The path then becomes c:\temp\symlink-example\dir\temp\symlink-example\dir\hello.txt </li><li>scan is set true and the loop repeats. "c:" is again expanded. The loop repeats infinitely as the path grows longer and longer </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12108 Trac 1.4.3 Tony Abbott <tony.abbott@…> Fri, 01 Apr 2016 08:02:43 GMT attachment set https://svn.boost.org/trac10/ticket/12108 https://svn.boost.org/trac10/ticket/12108 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">filesystem_canonical_bug.cpp</span> </li> </ul> Ticket libaracy@… Tue, 12 Jul 2016 08:48:16 GMT <link>https://svn.boost.org/trac10/ticket/12108#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12108#comment:1</guid> <description> <p> Will boost fix it? I have encountered similar problem. </p> <p> "C:" refers to current directory on drive C according to <a class="ext-link" href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#fully_qualified_vs._relative_paths"><span class="icon">​</span>https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#fully_qualified_vs._relative_paths</a> </p> <pre class="wiki"> // this is my test code: system("mkdir D:\\canonical"); system("mkdir D:\\canonical\\target"); system("echo test &gt; D:\\canonical\\target\\test.txt"); system("mklink /d D:\\canonical\\link D:\\canonical\\target"); SetCurrentDirectoryW(L"D:\\canonical\\link"); auto x = boost::filesystem::canonical(L"D:\\canonical\\link\\test.txt"); </pre><p> <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/11138"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/11138</a> should be similar. </p> </description> <category>Ticket</category> </item> </channel> </rss>