Public bug reported:
When using the the increment(error_code) method of class
recursive_directory_iterator
it fails to report the end iterator which leads to a SEGFAULT when trying to
access the path of the (actually defunct) iterator.
Test code:
#include <boost/filesystem/operations.hpp>
using namespace boost::filesystem;
using namespace boost::system;
int main(int argc, char* argv[]) {
if (argc != 2) return 1;
error_code ec;
for (recursive_directory_iterator start(argv[1], ec), end; start !=
end; start.increment(ec))
{
start->path();
}
}
Compile with "g++ -g test.cpp -lboost_filesystem -lboost_system"
Run e.g. "gdb -ex run --args ./a.out /proc/$$"
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bcac11 in
boost::filesystem3::directory_entry::m_get_status(boost::system::error_code*)
const () from /usr/lib/libboost_filesystem.so.1.48.0
This bug was fixed upstream as part of SVN revision 76667
(http://lists.boost.org/boost-commit/2012/01/39358.php)
Here's a diff of the relevant part of that commit which fixes this
problem:
--- operations.hpp.orig 2012-01-06 08:37:50.000000000 +0100
+++ operations.hpp 2013-06-06 11:08:58.223889240 +0200
@@ -782,6 +782,8 @@
BOOST_ASSERT_MSG(m_imp.get(),
"increment() on end recursive_directory_iterator");
m_imp->increment(&ec);
+ if (m_imp->m_stack.empty())
+ m_imp.reset(); // done, so make end iterator
return *this;
}
** Affects: boost1.48 (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1188103
Title:
SEGFAULT using boost::filesystem::recursive_directory_iterator
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/boost1.48/+bug/1188103/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs