Skip to content

Fix nil pointer dereference in sortUnpackJobs when sorting non-failed jobs#3793

Open
jianzhangbjz wants to merge 1 commit intooperator-framework:masterfrom
jianzhangbjz:OCPBUGS-77179
Open

Fix nil pointer dereference in sortUnpackJobs when sorting non-failed jobs#3793
jianzhangbjz wants to merge 1 commit intooperator-framework:masterfrom
jianzhangbjz:OCPBUGS-77179

Conversation

@jianzhangbjz
Copy link
Member

@jianzhangbjz jianzhangbjz commented Mar 11, 2026

Description of the change:
Added a nil check before accessing LastTransitionTime. When both conditions are nil (i.e., both jobs have not failed), fall back to sorting by CreationTimestamp instead.

  • pkg/controller/bundle/bundle_unpacker.go: Added nil check for condI and condJ in the sort comparison function

Motivation for the change:
The catalog-operator crashes with a nil pointer dereference panic when sorting unpack jobs:

  panic: runtime error: invalid memory address or nil pointer dereference
  [signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x1f94bf0]

  goroutine 514 [running]:
  github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle.sortUnpackJobs.func1(...)
      /pkg/controller/bundle/bundle_unpacker.go:889 +0x1f0

In sortUnpackJobs(), when comparing two jobs that both have not failed (failedI == false && failedJ == false), the getCondition() function returns nil for both condI and condJ. The code then attempts to access condI.LastTransitionTime without a nil check, causing the panic.
More details: https://issues.redhat.com/browse/OCPBUGS-77179

Architectural changes:

Testing remarks:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

Assisted-By: Claude-Code

@openshift-ci openshift-ci bot requested review from ankitathomas and oceanc80 March 11, 2026 07:48
@tmshort
Copy link
Contributor

tmshort commented Mar 11, 2026

/approve

@openshift-ci
Copy link

openshift-ci bot commented Mar 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tmshort

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants