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 #8690 - Avoid a double free on Linux for FMU parser #8829

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Jun 18, 2021

Pull request overview

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

…so tweak it to avoid polluting the source...

Note: Why does it create ShadingController/binaries/darwin64/ on UBUNTU? darwin64?!


(note: CMAKE_CURRENT_BINARY_DIR = build/third_party/FMUParser)
@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus AuxiliaryTool Related to an auxiliary tool, not EnergyPlus itself (readvars, preprocessor, ep-launch, etc.) labels Jun 18, 2021
@jmarrec jmarrec self-assigned this Jun 18, 2021
Comment on lines +44 to +51

if(BUILD_TESTING)
# Avoid creating some artifacts (ShadingController/modelDescription.xml and ShadingController/binaries inside "${PROJECT_SOURCE_DIR}/datasets/FMUs/"
configure_file("${PROJECT_SOURCE_DIR}/datasets/FMUs/ShadingController.fmu" "${CMAKE_CURRENT_BINARY_DIR}/ShadingController.fmu" COPYONLY)
add_test(NAME "FMUParser"
COMMAND parser "--printidf" "${CMAKE_CURRENT_BINARY_DIR}/ShadingController.fmu"
)
endif()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a ctest to exercise the executable created.

Comment on lines +95 to +100
#ifdef _MSC_VER
// https://man7.org/linux/man-pages/man3/basename.3.html
// Both dirname() and basename() return pointers to null-terminated strings. (Do not pass these pointers to free(3).)
free(filNam);
free(ext);
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actual fix.

@Myoldmopar
Copy link
Member

Tested this on develop and experienced the double free. Tested with this branch and parser successfully creates the tmp.idf file. This is great. And a good test to just exercise parser as a ctest. Thanks @jmarrec !

@Myoldmopar Myoldmopar merged commit 28043f5 into develop Jun 21, 2021
@Myoldmopar Myoldmopar deleted the 8690_FMUParser_Ubuntu branch June 21, 2021 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AuxiliaryTool Related to an auxiliary tool, not EnergyPlus itself (readvars, preprocessor, ep-launch, etc.) Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FMU parser is broken in 9.5.0 on Ubuntu
7 participants