Skip to content

director: fix crash in status scheduler when client is not set#965

Merged
arogge merged 6 commits intomasterfrom
dev/pstorz/master/fix-status_schedule-crash-5005
Nov 26, 2021
Merged

director: fix crash in status scheduler when client is not set#965
arogge merged 6 commits intomasterfrom
dev/pstorz/master/fix-status_schedule-crash-5005

Conversation

@pstorz
Copy link
Member

@pstorz pstorz commented Oct 26, 2021

Thank you for contributing to the Bareos Project!

The status scheduler command did not check the job->client pointer before dereferencing. This is fixed with this PR.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Separate commit for this PR in the CHANGELOG.md, PR number referenced is same
  • Commit descriptions are understandable and well formatted
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
  • git status should not report modifications in the source tree after building and testing

Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

While this patch fixes the crash, it will make status scheduler behave in a way that I would not expect. So it is probably not a good idea to do it this way.

Maybe we could improve the job object to have a function is_client_enabled() that could handle it. That function could look like this:

bool is_client_enabled() {
  return client != nullptr && client->enabled;
}

This would return false if client is set and not enabled, but true in every other case including client not being set.

arogge
arogge previously requested changes Oct 28, 2021
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

Just tried with your changes.
Configured a copy-job with a disabled client and ran status scheduler job=copy.
Threw the direcotor in an infinite loop eating CPU, so something is obviously still broken.

@pstorz pstorz self-assigned this Nov 4, 2021
@alaaeddineelamri alaaeddineelamri force-pushed the dev/pstorz/master/fix-status_schedule-crash-5005 branch from 4d7c3c4 to 9c7f956 Compare November 5, 2021 16:02
@arogge arogge added is a backport to 19.2 This is a backport from master to bareos-19.2 is a backport to 20 This is a backport from master to bareos-20 requires backport to 20 requires backport to 19.2 and removed is a backport to 19.2 This is a backport from master to bareos-19.2 is a backport to 20 This is a backport from master to bareos-20 labels Nov 9, 2021
@alaaeddineelamri alaaeddineelamri force-pushed the dev/pstorz/master/fix-status_schedule-crash-5005 branch from 9c7f956 to 238987e Compare November 9, 2021 11:39
@alaaeddineelamri alaaeddineelamri force-pushed the dev/pstorz/master/fix-status_schedule-crash-5005 branch from 238987e to 0caa435 Compare November 16, 2021 16:29
@pstorz pstorz assigned arogge and unassigned pstorz Nov 18, 2021
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

in ua_status.cc we have lines 658 to 716 with 7 empty or comment lines.
That's a net amount of 51 lines of code.

These contain:

  • 16 branches (14 ifs, 2 elses)
  • 3 loops (1 while, 2 foreach_res)
  • 9 jumps (3 gotos, 5 continues, 1 break)

So there is a loop, branch or some other kind of jump every 2 lines.

What I'm trying to say is: I would love to review the code, but I need to understand it.
Don't you think this should be refactored completely so we can understand what is going on without drawing a complex diagram?

@alaaeddineelamri alaaeddineelamri force-pushed the dev/pstorz/master/fix-status_schedule-crash-5005 branch from 0caa435 to cc31ee0 Compare November 23, 2021 16:29
@alaaeddineelamri alaaeddineelamri force-pushed the dev/pstorz/master/fix-status_schedule-crash-5005 branch from cc31ee0 to 0aaea07 Compare November 26, 2021 11:31
@pstorz pstorz dismissed arogge’s stale review November 26, 2021 11:35

The commits with the changes do not exist anymore

@pstorz pstorz assigned pstorz and unassigned arogge Nov 26, 2021
@pstorz pstorz changed the title ua_status: check job->client pointer before dereferencing director: avoid crash in status scheduler when client is not set Nov 26, 2021
@pstorz pstorz changed the title director: avoid crash in status scheduler when client is not set director: fix crash in status scheduler when client is not set Nov 26, 2021
@arogge arogge merged commit 895ac87 into master Nov 26, 2021
@arogge arogge deleted the dev/pstorz/master/fix-status_schedule-crash-5005 branch November 26, 2021 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments