Troubleshooting
Build Issues
MSVC: C4114 warnings
If you see volatile qualifier warnings, ensure you're using the latest FastQueue headers which use proper volatile qualifiers for MSVC atomics.
GCC/Clang: unknown type name '_Thread_local'
Ensure you're compiling with C11 or later support (recommended):
bash
gcc -std=c11 ...CMake: Could not find package
If using FetchContent, ensure the git tag is correct:
cmake
FetchContent_Declare(
FastQueue
GIT_REPOSITORY https://github.com/muhammad-fiaz/FastQueue.git
GIT_TAG main
)Runtime Issues
Deadlock in wait_idle
If fq_scheduler_wait_idle hangs:
- Check that all tasks complete (no infinite loops)
- Ensure tasks don't call
wait_idlerecursively - Verify queue capacity is sufficient:
c
cfg.queue_capacity = 8192; // Increase capacityTasks not executing
- Check that the scheduler is not shut down
- Verify task submission succeeded:
c
fq_status_t st = fq_scheduler_submit_fn(scheduler, task, data);
if (st != FQ_OK) {
fprintf(stderr, "Submit failed: %s\n", fq_status_string(st));
}- Check thread count:
c
printf("Thread count: %u\n", cfg.thread_count);High memory usage
- Reduce queue capacity
- Use custom allocator with arena/pool strategy
- Ensure tasks don't accumulate:
c
fq_scheduler_wait_idle(scheduler); // Wait before submitting moreTasks appear lost
- Check queue capacity - tasks submitted to full queues are dropped
- Use
fq_scheduler_statsto verify:
c
fq_scheduler_stats_t stats;
fq_scheduler_stats(scheduler, &stats);
printf("Submitted: %d, Completed: %d\n", stats.tasks_submitted, stats.tasks_completed);Sanitizer Reports
AddressSanitizer: heap-use-after-free
Ensure tasks don't access freed memory:
c
int *data = malloc(sizeof(int));
*data = 42;
fq_scheduler_submit_fn(scheduler, task, data);
// Don't free data here - let the task do itThreadSanitizer: data race
Ensure shared data is properly synchronized:
c
// Use mutex for shared data
fq_mutex_t mutex;
fq_mutex_init(&mutex);
static void safe_task(void *arg) {
fq_mutex_lock(&mutex);
shared_counter++;
fq_mutex_unlock(&mutex);
}