| doc_id | THR-GUID-024 |
|---|---|
| doc_title | Troubleshooting Guide |
| doc_version | 1.0.0 |
| doc_date | 2026-04-04 |
| doc_status | Released |
| project | thread_system |
| category | GUID |
SSOT: This document is the single source of truth for Troubleshooting Guide.
Language: English | 한국어
This guide covers common issues and their solutions when working with Thread System.
Symptom: Build fails with errors related to C++20 features like std::format, std::jthread, or concepts.
Solution:
- Check your compiler version:
g++ --version # Should be 11+
clang++ --version # Should be 14+- Ensure C++20 is enabled:
cmake -S . -B build -DCMAKE_CXX_STANDARD=20- If using older compilers, disable unsupported features:
cmake -S . -B build \
-DDISABLE_STD_FORMAT=ON \
-DDISABLE_STD_JTHREAD=ONSymptom: dependency.sh or dependency.bat fails to install vcpkg or packages.
Solution:
- Clean and reinstall:
rm -rf vcpkg
./scripts/dependency.sh- Manual installation:
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
export VCPKG_ROOT=$PWD/vcpkg- Check network connectivity and proxy settings.
Symptom: CMake fails with "No CMAKE_CXX_COMPILER could be found."
Solution:
- Set compiler explicitly:
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
cmake -S . -B build- Or use CMake variables:
cmake -S . -B build \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++Symptom: Unresolved external symbols or LNK errors on Windows.
Solution:
- Ensure consistent runtime library:
cmake -S . -B build -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL-
Use matching Debug/Release configurations.
-
Check that all dependencies are built with the same settings.
Symptom: Google Test related build errors.
Solution:
- Install Google Test via vcpkg:
./vcpkg/vcpkg install gtest- Or disable tests:
cmake -S . -B build -DBUILD_TESTING=OFFSymptom: Jobs are not being processed.
Solution:
- Ensure workers are added before starting:
auto pool = std::make_shared<thread_pool>("MyPool");
// Add workers first
std::vector<std::unique_ptr<thread_worker>> workers;
workers.push_back(std::make_unique<thread_worker>());
pool->enqueue_batch(std::move(workers));
// Then start
pool->start();- Check that
start()is called.
Symptom: Application hangs during job execution.
Solution:
- Avoid submitting jobs that wait for other jobs from the same pool:
// BAD: Potential deadlock
pool->submit_task([&pool]() {
auto future = pool->submit_task([]() { /* inner job */ });
future.get(); // Deadlock if all workers are busy
});-
Use separate pools for nested job submissions.
-
Run with ThreadSanitizer to detect issues:
cmake -S . -B build -DENABLE_TSAN=ONSymptom: Memory usage grows over time.
Solution:
- Ensure proper shutdown:
pool->shutdown_pool(false); // Wait for completion- Run with AddressSanitizer:
cmake -S . -B build -DENABLE_ASAN=ON
./build/bin/your_app- Check that all jobs are completing and not stuck.
Symptom: Jobs fail silently or return unexpected errors.
Solution:
- Check job return values:
pool->execute(std::make_unique<callback_job>([]() -> kcenon::common::VoidResult {
// Your work
return kcenon::common::ok();
}));- Use proper error handling:
auto result = pool->execute(std::move(job));
if (result.has_error()) {
std::cerr << "Job failed: " << result.get_error().message() << "\n";
}Symptom: Jobs are processed slower than expected.
Solution:
- Match worker count to workload:
// For CPU-bound work
size_t workers = std::thread::hardware_concurrency();
// For I/O-bound work
size_t workers = std::thread::hardware_concurrency() * 2;- Use lock-free queue for high contention:
thread_module::adaptive_job_queue q{
thread_module::adaptive_job_queue::queue_strategy::LOCKFREE
};- Profile your application to identify bottlenecks.
Symptom: CPU usage is high even with no jobs.
Solution:
- Use blocking wait instead of busy polling:
// Configure worker with proper idle behavior
// Workers should use condition variables for waiting- Check that shutdown is called when pool is no longer needed.
Symptom: Poor scaling with multiple threads.
Solution:
- Use adaptive or lock-free queues:
thread_module::adaptive_job_queue q{
thread_module::adaptive_job_queue::queue_strategy::ADAPTIVE
};-
Reduce shared state in jobs.
-
Batch related operations to reduce queue operations.
Symptom: Tests are skipped on macOS CI environments.
Explanation: Tests are disabled by default on macOS due to CI environment limitations. Run tests locally:
cd build && ctest --verboseSymptom: Console output shows garbled text.
Solution:
- Use UTF-8 encoding:
#ifdef _WIN32
SetConsoleOutputCP(CP_UTF8);
#endif- libiconv is excluded on Windows by default.
Symptom: Cannot execute scripts or binaries.
Solution:
- Make scripts executable:
chmod +x scripts/*.sh
chmod +x build/bin/*When reporting issues, include:
- System information:
uname -a # OS info
g++ --version # Compiler version
cmake --version # CMake version- Build configuration:
cmake -S . -B build -L # List CMake variables- Error messages: Full error output from the build or runtime.
- GitHub Issues - Report bugs and request features
- FAQ - Frequently asked questions
- Build Guide - Detailed build instructions
- Email: kcenon@naver.com
Last Updated: 2025-12-10