Skip to content

async_msg: take ownership of filename/funcname#2935

Open
timblechmann wants to merge 1 commit into
gabime:v1.xfrom
timblechmann:feature/async_sourceloc_ownership
Open

async_msg: take ownership of filename/funcname#2935
timblechmann wants to merge 1 commit into
gabime:v1.xfrom
timblechmann:feature/async_sourceloc_ownership

Conversation

@timblechmann

@timblechmann timblechmann commented Nov 9, 2023

Copy link
Copy Markdown
Contributor

the async logger cannot ensure that filename/funcname pointers are still valid at the time when the async worker is executed:

  • filename/funcname may be provided by a VM
  • filename/funcname may point to a readonly text field, in a shared object that had been dlclosed

we add an api that can be enabled via SPDLOG_ASYNC_OWNING_SOURCELOC_STRINGS to take ownership of the strings

fixes #2867

@timblechmann timblechmann force-pushed the feature/async_sourceloc_ownership branch from 387a06f to 38ff02b Compare November 9, 2023 01:42
Comment thread CMakeLists.txt Outdated
set(SPDLOG_WCHAR_FILENAMES OFF CACHE BOOL "non supported option" FORCE)
endif()

set(SPDLOG_ASYNC_OWNING_SOURCELOC_STRINGS BOOL "Async loggers take owership of source_loc strings" OFF)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use option() instead of set().

Also, it seems halfway to define a new option in this position.
Why not define it where other options are defined together (e.g., after option(SPDLOG_DISABLE_DEFAULT_LOGGER ...))?

the async logger cannot ensure that filename/funcname pointers are still
valid at the time when the async worker is executed:
* filename/funcname may be provided by a VM
* filename/funcname may point to a readonly text field, in a shared
object that had been `dlclose`d

we add an api that can be enabled via
`SPDLOG_ASYNC_OWNING_SOURCELOC_STRINGS` to take ownership of the strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[source_loc] support for owning strings

2 participants