build failure due to missing mutex include
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 5k
- Forks
- 622
- Avg merge
- 8h 37m
- Merged PRs (30d)
- 5
Description
When building SPTAG git master with GCC 11 on Debian bookworm, there is a build failure when compiling SPTAG because std::unique_lock doesn't exist due to a missing #include <mutex> in the AnnService/inc/Core/Common/BKTree.h file. There are a number of other situations in the code where #include <mutex> is also missing.
c++ -DBOOST_ALL_NO_LIB -DBOOST_SYSTEM_DYN_LINK -I"AnnService" -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wunreachable-code -Wno-reorder -Wno-sign-compare -Wno-unknown-pragmas -Wcast-align -lm -lrt -fopenmp -fopenmp -std=gnu++14 -MD -MT AnnService/CMakeFiles/sptag-indexbuilder.dir/src/IndexBuilder/main.cpp.o -MF CMakeFiles/sptag-indexbuilder.dir/src/IndexBuilder/main.cpp.o.d -o CMakeFiles/sptag-indexbuilder.dir/src/IndexBuilder/main.cpp.o -c "AnnService/src/IndexBuilder/main.cpp"
In file included from AnnService/inc/SSDServing/SelectHead_BKT/AnalyzeTree.h:9,
from AnnService/src/SSDServing/SelectHead_BKT/AnalyzeTree.cpp:4:
AnnService/inc/Core/Common/BKTree.h: In member function 'void SPTAG::COMMON::BKTree::Rebuild(const SPTAG::COMMON::Dataset<T>&, SPTAG::DistCalcMethod, SPTAG::IAbortOperation*)':
AnnService/inc/Core/Common/BKTree.h:409:22: error: 'unique_lock' is not a member of 'std'
409 | std::unique_lock<std::shared_timed_mutex> lock(*m_lock);
| ^~~~~~~~~~~
In file included from AnnService/inc/SSDServing/SelectHead_BKT/AnalyzeTree.h:9,
from AnnService/src/SSDServing/SelectHead_BKT/AnalyzeTree.cpp:4:
AnnService/inc/Core/Common/BKTree.h:19:1: note: 'std::unique_lock' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
18 | #include "DistanceUtils.h"
+++ |+#include <mutex>
19 |
In file included from AnnService/inc/SSDServing/SelectHead_BKT/AnalyzeTree.h:9,
from AnnService/src/SSDServing/SelectHead_BKT/AnalyzeTree.cpp:4:
AnnService/inc/Core/Common/BKTree.h:409:57: error: expected primary-expression before '>' token
409 | std::unique_lock<std::shared_timed_mutex> lock(*m_lock);
| ^
AnnService/inc/Core/Common/BKTree.h:409:59: error: there are no arguments to 'lock' that depend on a template parameter, so a declaration of 'lock' must be available [-fpermissive]
409 | std::unique_lock<std::shared_timed_mutex> lock(*m_lock);
| ^~~~
AnnService/inc/Core/Common/BKTree.h:409:59: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
.../SPTAG (master=) for f in `git grep -l unique_lock ` ; do if ! grep -q '<mutex>' $f ; then echo $f ; fi ; done
AnnService/inc/Core/Common/BKTree.h
AnnService/inc/Core/Common/KDTree.h
AnnService/inc/Helper/ConcurrentSet.h
AnnService/src/Client/ClientWrapper.cpp
AnnService/src/Core/BKT/BKTIndex.cpp
AnnService/src/Core/KDT/KDTIndex.cpp
AnnService/src/Core/MetadataSet.cpp
AnnService/src/Helper/Concurrent.cpp
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AnnService/inc/Core/Common/BKTree.h and compare the other files reported by the git grep check: KDTree.h, ConcurrentSet.h, ClientWrapper.cpp, BKTIndex.cpp, KDTIndex.cpp, MetadataSet.cpp, and Concurrent.cpp. Reproduce the failure with the shown GCC 11 C++14 build command, review each unique_lock use, and confirm the project builds successfully afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100