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 invalid unchecked cast to StFlow #1226

Merged
merged 1 commit into from
Mar 22, 2022
Merged

Conversation

speth
Copy link
Member

@speth speth commented Mar 21, 2022

The domain between two boundaries isn't necessarily an StFlow object,
as exemplified by the Blasius BVP sample code.

Fixes #1224

Changes proposed in this pull request

  • Replace unchecked C-style casts to StFlow* with dynamic_cast
  • Partial fix for logic calculating number of species in a boundary domain

If applicable, fill in the issue number this pull request is fixing

Closes #1224

If applicable, provide an example illustrating new features this pull request is introducing

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 domain between two boundaries isn't necessarily an StFlow object,
as exemplified by the Blasius BVP sample code.

Fixes Cantera#1224
@codecov
Copy link

codecov bot commented Mar 21, 2022

Codecov Report

Merging #1226 (31dea6e) into main (5f94a85) will increase coverage by 0.00%.
The diff coverage is 76.47%.

@@           Coverage Diff           @@
##             main    #1226   +/-   ##
=======================================
  Coverage   65.44%   65.44%           
=======================================
  Files         327      327           
  Lines       46321    46327    +6     
  Branches    19688    19694    +6     
=======================================
+ Hits        30314    30318    +4     
  Misses      13475    13475           
- Partials     2532     2534    +2     
Impacted Files Coverage Δ
src/oneD/Boundary1D.cpp 49.90% <76.47%> (+0.19%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

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

Wow! How did you find this?

@speth
Copy link
Member Author

speth commented Mar 21, 2022

I had to run the blasius example about 100 times (no joke) in the Visual Studio debugger to get it to hit the exception. I'm not entirely sure why the failure was so rare and restricted to Windows, but I guess what it comes down to is that these invalid values that were being calculated don't end up getting used for anything. I realized that the reason Valgrind wasn't able to help is because the values that are being read here are part of the BoundaryValueProblem object, they're just being mis-interpreted as values in a StFlow object, and Valgrind can't help with that.

@bryanwweber
Copy link
Member

Can you tell if this is due to a recent change, or had this been around for a while and we just didn't notice it? I imagine bisecting this isn't worth it 🤣

@ischoegl
Copy link
Member

Kudos!

@ischoegl ischoegl merged commit edd82c6 into Cantera:main Mar 22, 2022
@speth
Copy link
Member Author

speth commented Mar 22, 2022

The offending code has been there since the beginning of the commit history that we have (2003). I guess one reason we didn't see this before is that we weren't regularly testing the samples until more recently (#883).

@speth speth deleted the fix-1224-bvp branch July 23, 2024 15:34
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.

Sporadic failures on MSVC CI runs
3 participants