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

Prevent segfault in casacore log sink destructor #1398

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

confluence
Copy link
Collaborator

@confluence confluence commented Jan 27, 2025

Description

This fixes #1382. Testing is required to check if this is still doing the correct thing with casacore logs.

The segfault happens in the shared pointer destructor called from the casacore::LogSink destructor. I believe that this is because the shared pointer's underlying pointer is zeroed by casacore::LogSink::globalSink when it is used to set the global sink. This PR bypasses this issue by not reusing the same raw pointer both to set the global sink and to create a LogSink object which the LogIO object is then attached to. Instead, it uses the default LogIO constructor, which should attach the object to the global sink, which should be set to the correct sink.

I tested this locally and it appears that the casacore messages are still being formatted correctly in the output, but I'm not 100% familiar with the way that this logging model is supposed to work.

If there is no regression, I think that this PR is low-risk enough to be included in the freeze, but I'm creating it as a draft first just in case.

Checklist

  • changelog updated / no changelog update needed
  • e2e test passing / corresponding fix added / new e2e test created
  • ICD test passing / corresponding fix added / new ICD test created
  • protobuf updated to the latest dev commit / no protobuf update needed
  • protobuf version bumped / protobuf version not bumped
  • added reviewers and assignee
  • GitHub Project estimate added

@confluence confluence self-assigned this Jan 27, 2025
Copy link
Collaborator

@pford pford left a comment

Choose a reason for hiding this comment

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

As stated in the description, these changes solve the reported bug and still send casacore log messages to the carta log for consistent formatting.

src/Main/Main.cc Outdated
casacore::LogSink::globalSink(carta_log_sink);
casacore::LogIO casacore_log(log_sink);
casacore::LogIO casacore_log;
Copy link
Collaborator

Choose a reason for hiding this comment

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

LogIO not needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point; this object is actually never used.

Copy link

Code Coverage

Package Line Rate Health
src.Cache 72%
src.DataStream 44%
src.FileList 67%
src.Frame 36%
src.HttpServer 42%
src.ImageData 28%
src.ImageFitter 83%
src.ImageGenerators 43%
src.ImageStats 75%
src.Logger 37%
src.Main 52%
src.Region 69%
src.Session 4%
src.Table 52%
src.ThreadingManager 67%
src.Timer 85%
src.Util 38%
Summary 46% (8643 / 18963)

@confluence confluence marked this pull request as ready for review February 3, 2025 07:53
@confluence confluence added the awaiting testing For pull requests that require testing label Feb 3, 2025
@kswang1029 kswang1029 added awaiting merge For pull requests ready for merge or pending frontend/protobuf changes and removed awaiting testing For pull requests that require testing labels Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge For pull requests ready for merge or pending frontend/protobuf changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend segfaults if the starting dir isn't contained in the top level folder
3 participants