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

fix(storage): avoid segmentation fault when generating actions #1419

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions service/lib/agama/storage/actions_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,20 @@ class ActionsGenerator
# param target_graph [Y2Storage::Devicegraph]
def initialize(system_graph, target_graph)
@system_graph = system_graph
@target_graph = target_graph

# Keep a reference to the actiongraph. Otherwise, accessing to the compound actions could
# raise a segmentation fault if the actiongraph object was killed by the ruby GC.
#
# Source of the problem:
# * An actiongraph is generated from the target devicegraph.
# * The list of compound actions is recovered from the actiongraph.
# * If there is no refrence to the actiongraph, then the actiongraph object is a candidate
# to be cleaned by the ruby GC.
# * Accessing to the generated compound actions raises a segmentation fault if the
# actiongraph was cleaned.
#
# See https://github.com/openSUSE/agama/issues/1396.
@actiongraph = target_graph.actiongraph
end

# All actions properly sorted.
Expand All @@ -44,8 +57,8 @@ def generate
# @return [Y2Storage::Devicegraph]
attr_reader :system_graph

# @return [Y2Storage::Devicegraph]
attr_reader :target_graph
# @return [Y2Storage::Actiongraph]
attr_reader :actiongraph

# Sorted main actions (everything except subvolume actions).
#
Expand All @@ -67,7 +80,7 @@ def subvolume_actions
#
# @return [Array<Action>]
def actions
@actions ||= target_graph.actiongraph.compound_actions.map do |action|
@actions ||= actiongraph.compound_actions.map do |action|
Action.new(action, system_graph)
end
end
Expand Down
6 changes: 6 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jul 1 10:36:18 UTC 2024 - José Iván López González <jlopez@suse.com>

- Add yet another fix to avoid error when generating the storage
actions (gh#openSUSE/agama#1419).

-------------------------------------------------------------------
Fri Jun 28 11:57:39 UTC 2024 - José Iván López González <jlopez@suse.com>

Expand Down
Loading