Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async_msg: take ownership of filename/funcname #2935

Open
wants to merge 1 commit into
base: v1.x
Choose a base branch
from

Conversation

timblechmann
Copy link
Contributor

@timblechmann timblechmann commented Nov 9, 2023

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
CMakeLists.txt Outdated
@@ -113,6 +113,8 @@ else()
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
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
@timblechmann timblechmann force-pushed the feature/async_sourceloc_ownership branch from 38ff02b to bfb3a8e Compare November 9, 2023 03:39
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