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 segfault in deprecated newPhase factory function #1600

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

speth
Copy link
Member

@speth speth commented Aug 22, 2023

The shared_ptr goes out of scope at the end of the function, deleting the held ThermoPhase right as it's returned.

Erroneous behavior introduced in f3e840d (#1448).

Changes proposed in this pull request

  • Replace the shared_ptr-based implementation with one that uses a unique_ptr (which can be released without destroying the underlying object)
  • Add test coverage for this method

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

The shared_ptr goes out of scope at the end of the function,
deleting the held ThermoPhase right as it's returned.

Erroneous behavior introduced in f3e840d (Cantera#1448).
@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Merging #1600 (9b55c1a) into main (8e2ab16) will increase coverage by 0.00%.
The diff coverage is 58.82%.

@@           Coverage Diff           @@
##             main    #1600   +/-   ##
=======================================
  Coverage   70.59%   70.59%           
=======================================
  Files         379      379           
  Lines       59168    59185   +17     
  Branches    21257    21270   +13     
=======================================
+ Hits        41768    41781   +13     
- Misses      14324    14325    +1     
- Partials     3076     3079    +3     
Files Changed Coverage Δ
src/thermo/ThermoFactory.cpp 74.30% <58.82%> (+0.15%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

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

Thanks for catching this.

@ischoegl ischoegl merged commit 217f35b into Cantera:main Aug 22, 2023
41 of 42 checks passed
@speth speth deleted the fix-factory-segfault branch July 23, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants