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

[C++] logging factory should be stored as static shared_ptr #7132

Merged
merged 1 commit into from
Jun 2, 2020

Conversation

merlimat
Copy link
Contributor

@merlimat merlimat commented Jun 1, 2020

Motivation

C++ references and thus cleans up all statics on exit. This can happen
when there are still threads active. If a thread tries to access
logging when the process is shutting down, this will possibly use a
dead object and corrupt the heap, triggering a segfault.

The solution is to make the logger factory immortal. Once it is set,
it is assigned to an atomic static pointer, and this object is
thereafter never cleaned up. This does change the signature for
passing in logger factories, as shared_ptr is no longer valid.

C++ references and thus cleans up all statics on exit. This can happen
when there are still threads active. If a thread tries to access
logging when the process is shutting down, this will possibly use a
dead object and corrupt the heap, triggering a segfault.

The solution is to make the logger factory immortal. Once it is set,
it is assigned to an atomic static pointer, and this object is
thereafter never cleaned up. This does change the signature for
passing in logger factories, as shared_ptr is no longer valid.
@merlimat merlimat added the type/bug The PR fixed a bug or issue reported a bug label Jun 1, 2020
@merlimat merlimat added this to the 2.6.0 milestone Jun 1, 2020
@merlimat merlimat merged commit c74414c into apache:master Jun 2, 2020
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
)

C++ references and thus cleans up all statics on exit. This can happen
when there are still threads active. If a thread tries to access
logging when the process is shutting down, this will possibly use a
dead object and corrupt the heap, triggering a segfault.

The solution is to make the logger factory immortal. Once it is set,
it is assigned to an atomic static pointer, and this object is
thereafter never cleaned up. This does change the signature for
passing in logger factories, as shared_ptr is no longer valid.

Co-authored-by: Ivan Kelly <ikelly@splunk.com>
jiazhai pushed a commit that referenced this pull request Sep 10, 2020
#7932)

### Motivation

I want to use custom logging factory in cpp client

### Modifications

#7132 broke custom logger config option. It then was identified in #7503 (and #7502) but not fixed. This PR actually fixes it by checking the right variable name.

### Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

### Documentation

This PR does not introduce any new functionality, but it fixes existing functionality that presumably is already documented.

* Fix for not respecting custom LoggerFactory client config

* Add Custom Logger Factory Test

* revert threads used by make in docker-build

Co-authored-by: Stepan Mazurov <smazurov@quantummetric.com>
lbenc135 pushed a commit to lbenc135/pulsar that referenced this pull request Oct 3, 2020
apache#7932)

### Motivation

I want to use custom logging factory in cpp client

### Modifications

apache#7132 broke custom logger config option. It then was identified in apache#7503 (and apache#7502) but not fixed. This PR actually fixes it by checking the right variable name.

### Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

### Documentation

This PR does not introduce any new functionality, but it fixes existing functionality that presumably is already documented.

* Fix for not respecting custom LoggerFactory client config

* Add Custom Logger Factory Test

* revert threads used by make in docker-build

Co-authored-by: Stepan Mazurov <smazurov@quantummetric.com>
astifter pushed a commit to astifter/pulsar that referenced this pull request Apr 7, 2021
With issue apache#7132 the LoggerFactoryPtr was removed in favour of relevant memory-safe(r) pointers.

This change forgot to also change the Log4Cxx implementation, fix this by returning (as with
the other LoggerFactory's) a std::unique_ptr<LoggerFactory>.
astifter pushed a commit to astifter/pulsar that referenced this pull request Apr 29, 2021
With issue apache#7132 the LoggerFactoryPtr was removed in favour of relevant memory-safe(r) pointers.

This change forgot to also change the Log4Cxx implementation, fix this by returning (as with
the other LoggerFactory's) a std::unique_ptr<LoggerFactory>.
codelipenghui pushed a commit that referenced this pull request May 21, 2021
Fixes #10161.

### Motivation

With issue #7132 the LoggerFactoryPtr was removed in favour of relevant memory-safe(r) pointers.

This change forgot to also change the Log4Cxx implementation, fix this by returning (as with
the other LoggerFactory's) a std::unique_ptr<LoggerFactory>.
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
Fixes apache#10161.

### Motivation

With issue apache#7132 the LoggerFactoryPtr was removed in favour of relevant memory-safe(r) pointers.

This change forgot to also change the Log4Cxx implementation, fix this by returning (as with
the other LoggerFactory's) a std::unique_ptr<LoggerFactory>.
codelipenghui pushed a commit that referenced this pull request Jun 26, 2021
Fixes #10161.

### Motivation

With issue #7132 the LoggerFactoryPtr was removed in favour of relevant memory-safe(r) pointers.

This change forgot to also change the Log4Cxx implementation, fix this by returning (as with
the other LoggerFactory's) a std::unique_ptr<LoggerFactory>.

(cherry picked from commit d700f8d)
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
Fixes apache#10161.

### Motivation

With issue apache#7132 the LoggerFactoryPtr was removed in favour of relevant memory-safe(r) pointers.

This change forgot to also change the Log4Cxx implementation, fix this by returning (as with
the other LoggerFactory's) a std::unique_ptr<LoggerFactory>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants