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 x0 and possible memory leak #166

Merged

Conversation

nbelakovski
Copy link
Contributor

In #148 the ability of the user to specify x0 from the C interface was removed. This PR fixes that. I noted this at the time in a comment in 488abda but I suppose you missed it.

In the issue you objected to setting result->x to x0, but there is no other reasonable way to provide x0 to the Fortran code. In the issue you mentioned that result->x was set to a reasonable value even though no solver was selected, but the correct solution to that would be to have prima_check_problem return a non-zero exit code when it doesn't select a solver, as I mentioned in the issue.

Separately, I discuss this in my comment on the commit linked above as well, the modifications from that issue led to a possible memory leak. If prima_init_result returned 0 but prima_check_problem did not, we would return to the user with a non-zero exit code and also with allocated memory that the user would be expected to free. Of course it's not appropriate to both return a non-zero exit code and expect the user to clean up after us. The easiest way to solve this problem is to just check the problem before initializing the result.

@zaikunzhang
Copy link
Member

Thank you @nbelakovski . I see the problem. I was confused by the original comment.

I will merge it for the moment, but still have related changes to make.

Thanks.

@zaikunzhang zaikunzhang merged commit b625d64 into libprima:main Feb 22, 2024
41 checks passed
@nbelakovski nbelakovski deleted the fix_x0_and_possible_memory_leak branch February 22, 2024 16:55
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