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

logger: Create only one Context per process for mobile #38149

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

abeyad
Copy link
Contributor

@abeyad abeyad commented Jan 23, 2025

The Logger::Context operates as a stack. When a new one is created, it becomes the active Context. When it gets destroyed, the destructor pops the previous Context as the currently active one.

This can lead to lifetime bugs in Envoy Mobile, if multiple engines are created and the destruction of those engines lead to indeterminate destruction of the Logger::Context objects.

In this commit, the behavior is changed so that the Logger::Context initialization is done by the external caller, not inside StrippedMainBase as previously done. This allows the caller, in this case, Envoy Mobile, to ensure only one Logger::Context is ever created, circumventing any potential issues on Context destruction with popping the previously saved context.

The Logger::Context operates as a stack. When a new one is created, it
becomes the active Context. When it gets destroyed, the destructor pops
the previous Context as the currently active one.

This can lead to lifetime bugs in Envoy Mobile, if multiple engines are
created and the destruction of those engines lead to indeterminate
destruction of the Logger::Context objects.

In this commit, the behavior is changed so that the Logger::Context
initialization is done by the external caller, not inside
StrippedMainBase as previously done. This allows the caller, in this
case, Envoy Mobile, to ensure only one Logger::Context is ever created,
circumventing any potential issues on Context destruction with popping
the previously saved context.

Signed-off-by: Ali Beyad <[email protected]>
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #38149 was opened by abeyad.

see: more, trace.

Signed-off-by: Ali Beyad <[email protected]>
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.

1 participant