I'm running into an odd deadlock situation, and I was wondering if it's a
known issue, or if there's likely something wrong with my code, or if I've
misconfigured something? First off, a stack trace:
ntdll.dll!77f5b7f4()
kernel32.dll!77e61bf5()
scanner.exe!boost::detail::sp_counted_base::release() Line 132 + 0xf C++
scanner.exe!boost::detail::shared_count::~shared_count() Line 380 C++
scanner.exe!boost::shared_ptr::~shared_ptrboost::filesystem::directory_iterator::dir_itr_imp() + 0x2e
C++
scanner.exe!boost::shared_ptr::reset() Line 217 C++
scanner.exe!boost::filesystem::directory_iterator::m_inc() Line 256 C++
scanner.exe!boost::filesystem::directory_iterator::operator++() Line 88 +
0x2b C++
scanner.exe!std::for_each(boost::filesystem::directory_iterator
_First={...}, boost::filesystem::directory_iterator _Last={...}, scan_file
_Func={...}) Line 20 + 0xa C++
I'm using boost 1.30.0 running a staticly linked debug build of the filesystem
lib, on vc7. The for_each is actually the most recursed level of a recursive
directory search - I'm pretty sure that code is fine; I'm very familiar with
STL iteration and I'm not doing anything strange, just:
std::for_each(
fs::directory_iterator(dir),
fs::directory_iterator(),
scan_files(fileset));
where scan_files will recurse on directories and process on files. I don't
touch the iterators directly other than to pass them to for_each.
Now, the strange part is this program works completely fine when I simply run
it from the command line. However, I am building it into a windows service,
and when it runs as a service under the SYSTEM account (I haven't tried
running it as a service under a different account, yet), I get deadlock. I
suspected the problem might be related to funny permissions on the directory
in question, but SYSTEM has full rights to the directory, so that shouldn't be
the problem.
Oddly, when I use the release filesystem lib it deadlocks in a different
location in the search, but in the same sp_counted_base::release() function -
this time in an attempt to unwind after a filesystem exception.
I tried to search the mailing list for similar problems, but the search seems
to be broken at the moment. I'm hoping this is an easy fix, known issue,
because I'm at a loss as to how I could be causing it, especially since I'm
not getting anywhere near the internals of the directory iterators. I am a
fairly new user to boost, but up until now I've had no problems.
Sorry if this is a jumble...I've been banging my head against this for the
past few hours and my coffee is wearing off.
Ken