packages-cpp icon indicating copy to clipboard operation
packages-cpp copied to clipboard

PlException should not use PlRecordExternalCopy (or PlRecord)

Open kamahen opened this issue 2 years ago • 1 comments

There should be no need to use the "record" API for the error term.

However, there appear to be some corner cases with PlQuery that can create an error term that becomes invalid. It's possible that these are incorrect uses of PlQuery - if so, they should be caught in the PlQuery constructor or PlQuery::next_solution(). Another possibility is creating multiple kinds of PlQuery for the 4 (or 6) combinations of PL_Q_EXT_STATUS and PL_CATCH_EXCEPTION / PL_PASS_EXCEPTION / PL_Q_NORMAL - and we need test cases for all these combinations.

In the meantime, using PlRecordExternalCopy for the exception term is "safe" in the sense that it doesn't crash, but it also can consume large amounts of memory by copying the contents of the error term.

kamahen avatar Apr 13 '23 20:04 kamahen

Also, the call to PlxErase() is only in PlException::plThrow() - it should also be in ~PlException after checking for non-null.

kamahen avatar Apr 17 '23 15:04 kamahen