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

Improve object lifetime management when creating temporary Rules object: #4917

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

ximinez
Copy link
Collaborator

@ximinez ximinez commented Feb 13, 2024

High Level Overview of Change

Rules objects store a reference to the presets provided to the ctor. One instance in unit tests passed a temporary to the ctor, which resulted in unit tests crashing on Windows on one of my development branches after it was rebased onto 2.1.0-rc1. There doesn't seem to be anything in 2.1.0-rc1 that caused the problem. In fact, when I switch back to changes based on the previous version (2.0.1), it fails, too, despite the CI succeeding.

Context of Change

Commit 01c37fe introduced a change to the STTx unit test where a local defaultRules object was created with a temporary inline presets value provided to the ctor. Rules::Impl stores a const ref to the presets provided to the ctor. This particular call provided an inline temp variable, which goes out of scope as soon as the object is created. On Windows, attempting to use the presets (e.g. via the enabled() function) causes an access violation, which crashes the test run.

An audit of the code indicates that all other instances of Rules use the Application's config.features list, which will have a sufficient lifetime.

Type of Change

  • [X ] Bug fix (non-breaking change which fixes an issue)
  • [X ] Tests (you added tests for code that already exists, or your new feature included in this PR)

API Impact

None

* Commit 01c37fe introduced a change to the STTx unit test where a local
  "defaultRules" object was created with a temporary inline "presets"
  value provided to the ctor. Rules::Impl stores a const ref to the
  presets provided to the ctor.  This particular call provided an inline
  temp variable, which goes out of scope as soon as the object is
  created. On Windows, attempting to use the presets (e.g. via the
  enabled() function) causes an access violation, which crashes the test
  run.
* An audit of the code indicates that all other instances of Rules use
  the Application's config.features list, which will have a sufficient
  lifetime.
@ximinez ximinez added Bug Perf impact not expected Change is not expected to improve nor harm performance. labels Feb 13, 2024
@ximinez ximinez added this to the 2.1.0 (Fix) milestone Feb 13, 2024
@intelliot
Copy link
Collaborator

ok for 2.1.0: only updates unit test

@intelliot intelliot requested a review from seelabs February 14, 2024 18:42
@intelliot intelliot changed the title [TRIVIAL] Improve object lifetime management when creating temporary Rules object: Improve object lifetime management when creating temporary Rules object: Feb 14, 2024
@intelliot intelliot merged commit e74cb35 into XRPLF:develop Feb 16, 2024
17 checks passed
sophiax851 pushed a commit to sophiax851/rippled that referenced this pull request Jun 12, 2024
* Commit 01c37fe introduced a change to the STTx unit test where a local
  "defaultRules" object was created with a temporary inline "presets"
  value provided to the ctor. Rules::Impl stores a const ref to the
  presets provided to the ctor.  This particular call provided an inline
  temp variable, which goes out of scope as soon as the object is
  created. On Windows, attempting to use the presets (e.g. via the
  enabled() function) causes an access violation, which crashes the test
  run.
* An audit of the code indicates that all other instances of Rules use
  the Application's config.features list, which will have a sufficient
  lifetime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Perf impact not expected Change is not expected to improve nor harm performance.
Projects
Status: 🚢 Released in 2.2.0
Development

Successfully merging this pull request may close these issues.

6 participants