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

Replace some asserts in PeerFinder::Logic with LogicError #4562

Merged
merged 5 commits into from
Oct 18, 2023

Conversation

scottschurr
Copy link
Collaborator

@scottschurr scottschurr commented Jun 8, 2023

High Level Overview of Change

It was discovered that it might be possible for the rippled server code to indirect through certain end() iterators. This problem is caught by assert()s in a debug build, but a release build would simply crash.

If we see problems in this area in the future, we'd like to get a definitive indication of the nature of the error regardless of whether it's a debug or release build. To accomplish this, these asserts are converted into LogicErrors that will produce a reasonable error message when they fire.

Type of Change

  • Refactor (non-breaking change that only restructures code)

Copy link
Collaborator

@mtrippled mtrippled left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@intelliot
Copy link
Collaborator

Can you explain how this is a breaking change?

I think I would consider it a Refactor, if we believe the following to be accurate:

Before

In a release build, in certain situations, the server would crash and not definitively indicate the nature of the error.

After

In a release build, in those same certain situations, the server would crash and definitively indicate the nature of the error, including a reasonable error message.

Reasoning against "Breaking change"

There is no situation in which

  • with this PR merged, the server would crash, but
  • without this PR, the server would continue operating.

@intelliot
Copy link
Collaborator

After writing the Before / After above, I think one could even argue for "New feature", since it adds the "functionality" of a potentially better error message for certain crashes.

@scottschurr
Copy link
Collaborator Author

@intelliot, that's a fair description. I very much agree that what would have been a puzzling crash before will now become a crash with an informative error message. I'm happy to call this a refactor.

@intelliot intelliot added Tech Debt Non-urgent improvements Needs Discussion labels Sep 3, 2023
@intelliot intelliot added this to the 1.14 milestone Sep 3, 2023
@HowardHinnant
Copy link
Contributor

With a removed .conan/data folder and using this command:

conan install .. --output-folder . --build  --settings build_type=Release

I'm getting a bunch of errors building boost 1.77. I believe this probably just needs to be brought up to boost 1.82, but I'm not positive. My build system has been somewhat in flux over the past week.

@scottschurr
Copy link
Collaborator Author

Hi @HowardHinnant. My best guess for the problems you're experiencing is that the branch is really stale. So I just applied a merge commit. With luck that will help the situation.

Copy link
Contributor

@HowardHinnant HowardHinnant left a comment

Choose a reason for hiding this comment

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

That worked! Thanks Scott.

@intelliot intelliot removed this from the 2024 release milestone Oct 4, 2023
@intelliot
Copy link
Collaborator

@scottschurr : at your convenience, can you confirm whether this PR is ready to merge?

(If you have permission - I'm not sure if you do - you can put the Passed label on)

@scottschurr scottschurr added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Oct 4, 2023
Copy link
Collaborator

@intelliot intelliot left a comment

Choose a reason for hiding this comment

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

Suggested commit message:

refactor(peerfinder): use LogicError in PeerFinder::Logic (#4562)

It might be possible for the server code to indirect through certain
`end()` iterators. While a debug build would catch this problem with
`assert()`s, a release build would crash. If there are problems in this
area in the future, it is best to get a definitive indication of the
nature of the error regardless of whether it's a debug or release build.
To accomplish this, these `assert`s are converted into `LogicError`s
that will produce a reasonable error message when they fire.

@intelliot intelliot added this to the 2.0 milestone Oct 17, 2023
@scottschurr
Copy link
Collaborator Author

Suggested commit message looks good to me. Do you want me to squash and change the commit message? Or will you do that when you merge to develop?

@intelliot
Copy link
Collaborator

I will do it

@intelliot intelliot merged commit b69156a into XRPLF:develop Oct 18, 2023
16 checks passed
@scottschurr scottschurr deleted the add-logic-errors branch October 31, 2023 15:46
sophiax851 pushed a commit to sophiax851/rippled that referenced this pull request Jun 12, 2024
It might be possible for the server code to indirect through certain
`end()` iterators. While a debug build would catch this problem with
`assert()`s, a release build would crash. If there are problems in this
area in the future, it is best to get a definitive indication of the
nature of the error regardless of whether it's a debug or release build.
To accomplish this, these `assert`s are converted into `LogicError`s
that will produce a reasonable error message when they fire.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. Tech Debt Non-urgent improvements
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants