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

avoiding memory leaks on errors in weekly schedule for #1860 #1861

Merged
merged 17 commits into from
Apr 5, 2024

Conversation

Mathadon
Copy link
Member

@Mathadon Mathadon commented Mar 30, 2024

@mwetter this should fix the memory leak issue. I was able to run IBPSA.Utilities.IO.Files.Examples.WeeklySchedule using this code but I did no memory checks using valgrind.

I don't have a machine to test the windows line endings. Is that something you could have a look at?

@Mathadon Mathadon requested a review from mwetter March 30, 2024 11:10
Copy link
Contributor

@mwetter mwetter left a comment

Choose a reason for hiding this comment

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

Note that IBPSA.Utilities.IO.Files.Examples.WeeklySchedule crashes on my Dymola, with an empty log file.

@mwetter
Copy link
Contributor

mwetter commented Apr 1, 2024

I could test the windows line endings, but can you please update the code. I am not familiar enough with the logic of your C implementation, by maybe where you test for \n, you could check if there is a \r followed by an \n and if so, skip the \r. Or alternatively convert the buffer from \r\n to \n before all the processing starts?

We should then replicate one of the validation and use a text file with Windows line endings, which we should be able to add with dos2unix.

Copy link
Member Author

@Mathadon Mathadon left a comment

Choose a reason for hiding this comment

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

I have made some revisions but can't figure out from the code why it crashes in Dymola. On OM it works ok:
image

I'm not sure how to debug further since we do not have a dymola license. You also checked the simulation tab for any error messages?

@Mathadon
Copy link
Member Author

Mathadon commented Apr 1, 2024

@mwetter through 0ecdc2e I attempted to add \r\n support.

@mwetter
Copy link
Contributor

mwetter commented Apr 1, 2024

@Mathadon : I have not checked for the root cause of the error, but also OCT refuses the translate the file. It issues:

free(): double free detected in tcache 2

@Mathadon
Copy link
Member Author

Mathadon commented Apr 2, 2024

@mwetter thanks for checking further! I got the same error using Taco and apparently I forgot to remove the original fclose(). See ac9c6e2 for a fix. Does that resolve the windows issue too?

Avoids a warning in OCT
@mwetter
Copy link
Contributor

mwetter commented Apr 2, 2024

@Mathadon : Now the results are wrong:
image

@Mathadon
Copy link
Member Author

Mathadon commented Apr 3, 2024

@mwetter thanks for the windows example model. I found the bug and tested the new example. The results visually match the old results in your screenshot and the new example works. :) see a911c6a

@mwetter mwetter enabled auto-merge April 3, 2024 17:12
Copy link
Contributor

@mwetter mwetter left a comment

Choose a reason for hiding this comment

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

@Mathadon : Thanks, this looks good to merge when the CI tests pass.

@Mathadon
Copy link
Member Author

Mathadon commented Apr 3, 2024

🙌

@mwetter mwetter merged commit 96088a7 into master Apr 5, 2024
3 checks passed
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