Skip to content

ODR violation with ThreadContextManager::instance() when using quill across multiple shared libraries #892

@wangjunbo4

Description

@wangjunbo4

Environment

  • OS: Linux (CentOS/RHEL)
  • Compiler: GCC with AddressSanitizer enabled

Problem

My project structure includes:

  • A main executable
  • Multiple shared libraries

All components include quill headers and use the logging functionality. When running with AddressSanitizer, I get the following error:

==4093084==ERROR: AddressSanitizer: odr-violation (0x7f52feedd800):
  [1] size=32 'instance' /path/to/quill/core/ThreadContextManager.h:216:33 in lib.so
  [2] size=32 'instance' /path/to/quill/core/ThreadContextManager.h:216:33 in main
QUILL_EXPORT static ThreadContextManager& instance() noexcept
{
  static ThreadContextManager instance;  // <-- ODR violation here
  return instance;
}

Questions

  • What is the recommended way to use quill in a multi-shared-library project?
  • Is there a planned fix for this ODR issue in header-only mode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions