Skip to content

Seg. fault when reusing the factorization

Nicolas Marsic requested to merge reuseFactorization into master

Hi everyone,

First of all, let me wish you a happy new year :)!

Reusing the factorization with Solver::solve(true) leads to a segmentation fault.

I guess the cause is

_A->removePetscData();
_b->removePetscData();

at the end of solve() (lines 153-154), which kills the operator, making thus the reuse impossible.

My impression was that it worked a while ago, so I dig a bit: these lines were introduced in commit 49a1a43e, which fixes some memory leaks. So I'm not sure how to fix this bug without breaking other stuffs...

This MR suggests to simply remove the two removePetscData(), as it seems that this task is already handled by MatrixFactory<>::~MatrixFactory(). It works (no leak and no seg. fault) in the simple case

// [...]
formulation.solve(false);
formulation.solve(true);
// [...]

but I'm perhaps missing something? Any thoughts?

Cheers, Nicolas.

Merge request reports