Skip to content

Commit

Permalink
fix handling of errors in singular libraries (#696)
Browse files Browse the repository at this point in the history
reset the error flags of singular after reporting, not in Werror
  • Loading branch information
hannes14 authored Aug 9, 2023
1 parent 4be1204 commit 7b8e4bb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
24 changes: 8 additions & 16 deletions deps/src/ideals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,14 @@ auto id_MinStd_helper(ideal a, ring b, bool complete_reduction = false)
crbit = 0;
ideal id = NULL;
ideal m = NULL;
if (!idIs0(a))
{
tHomog h = testHomog;
const ring origin = currRing;
unsigned int save_opt = si_opt_1;
si_opt_1 |= crbit;
rChangeCurrRing(b);
id = kMin_std(a, b->qideal, h, NULL, m);
si_opt_1 = save_opt;
rChangeCurrRing(origin);
}
else
{
id = idInit(0, a->rank);
m = idInit(0, a->rank);
}
tHomog h = testHomog;
const ring origin = currRing;
unsigned int save_opt = si_opt_1;
si_opt_1 |= crbit;
rChangeCurrRing(b);
id = kMin_std(a, b->qideal, h, NULL, m);
si_opt_1 = save_opt;
rChangeCurrRing(origin);
return std::make_tuple(id, m);
}

Expand Down
3 changes: 2 additions & 1 deletion deps/src/singular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ static void WarningS_for_julia(const char * s)
*/
static void WerrorS_and_reset(const char * s)
{
errorreported = 0;
if (singular_error_log.size() > 9)
{
for (auto & si : singular_error_log)
Expand Down Expand Up @@ -124,6 +123,8 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular)
});

Singular.method("get_and_clear_error", []() {
errorreported = 0;
inerror = 0;
std::stringstream ss;
for (auto & si : singular_error_log)
ss << si << std::endl;
Expand Down
7 changes: 7 additions & 0 deletions src/caller.jl
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ function low_level_caller_rng(lib::String, name::String, ring, args...)
end
arguments = Any[i for (i, j) in arguments]
return_value = libSingular.call_singular_library_procedure(name, ring.ptr, arguments)
if libSingular.have_error()
error(libSingular.get_and_clear_error())
end

return convert_return(return_value, ring)
end

Expand All @@ -387,6 +391,9 @@ function low_level_caller(lib::String, name::String, args...)
return_values = nothing
rng_ptr = (rng == nothing) ? C_NULL : rng.ptr
return_value = libSingular.call_singular_library_procedure(name, rng_ptr, arguments)
if libSingular.have_error()
error(libSingular.get_and_clear_error())
end
return convert_return(return_value, rng)
end

Expand Down

0 comments on commit 7b8e4bb

Please sign in to comment.