oscar-system / Singular.jl

Julia package for the Singular library
Other
32 stars 33 forks source link

crash on fractions over Nemo #349

Closed tthsqe12 closed 3 years ago

tthsqe12 commented 3 years ago

If singular is unable to calculate this, then we should catch this before it crashes.

julia> using Singular

julia> R, (x, y) = PolynomialRing(Singular.Nemo.ZZ, ["x", "y"])
(Singular Polynomial Ring (Coeffs(17)),(x,y),(dp(2),C), spoly{Singular.n_unknown{Nemo.fmpz}}[x, y])

julia> x//y

signal (11): Segmentation fault
wbhart commented 3 years ago

Seems to be calling out to factory for gcd, which is segfaulting in _Z13p_InitContentP8spolyrecP8ip_sring at /home/wbhart/.julia/artifacts/1e70cd942f1bb941f2cea53c586a5024e04eb261/lib/libpolys.so

On Mon, 11 Jan 2021 at 13:59, tthsqe12 notifications@github.com wrote:

julia> using Singular

julia> R, (x, y) = PolynomialRing(Singular.Nemo.ZZ, ["x", "y"]) (Singular Polynomial Ring (Coeffs(17)),(x,y),(dp(2),C), spoly{Singular.n_unknown{Nemo.fmpz}}[x, y])

julia> x//y

signal (11): Segmentation fault

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oscar-system/Singular.jl/issues/349, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB3HJXVE2K3B42L5VGI5HLSZLY2FANCNFSM4V5Q2HIQ .

wbhart commented 3 years ago

Here is what happens if you call gcd directly:

julia> R, (x, y) = PolynomialRing(Singular.Nemo.ZZ, ["x", "y"])
(Singular Polynomial Ring (Coeffs(17)),(x,y),(dp(2),C),
spoly{Singular.n_unknown{Nemo.fmpz}}[x, y])

julia> gcd(x, y)

signal (11): Segmentation fault
in expression starting at REPL[3]:1
_Z13p_InitContentP8spolyrecP8ip_sring at
/home/wbhart/.julia/artifacts/1e70cd942f1bb941f2cea53c586a5024e04eb261/lib/libpolys.so
(unknown line)
_Z9p_ContentP8spolyrecP8ip_sring at
/home/wbhart/.julia/artifacts/1e70cd942f1bb941f2cea53c586a5024e04eb261/lib/libpolys.so
(unknown line)
_Z12singclap_gcdP8spolyrecS0_P8ip_sring at
/home/wbhart/.julia/artifacts/1e70cd942f1bb941f2cea53c586a5024e04eb261/lib/libSingular.so
(unknown line)
operator() at
/opt/x86_64-linux-gnu/x86_64-linux-gnu/include/c++/7.1.0/bits/std_function.h:706
[inlined]
operator() at
/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/jlcxx/module.hpp:47
[inlined]
apply at
/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/jlcxx/module.hpp:72
singclap_gcd at
/home/wbhart/.julia/packages/CxxWrap/68Y7I/src/CxxWrap.jl:596 [inlined]
gcd at /home/wbhart/.julia/packages/Singular/i9i1h/src/poly/poly.jl:565
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2141
[inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1631
[inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:328
eval_value at
/buildworker/worker/package_linux64/build/src/interpreter.c:417
eval_stmt_value at
/buildworker/worker/package_linux64/build/src/interpreter.c:368 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:778
jl_interpret_toplevel_thunk_callback at
/buildworker/worker/package_linux64/build/src/interpreter.c:888
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f7c6e0a468f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at
/buildworker/worker/package_linux64/build/src/interpreter.c:897
jl_toplevel_eval_flex at
/buildworker/worker/package_linux64/build/src/toplevel.c:814
jl_toplevel_eval_flex at
/buildworker/worker/package_linux64/build/src/toplevel.c:764
jl_toplevel_eval_in at
/buildworker/worker/package_linux64/build/src/toplevel.c:843
eval at ./boot.jl:330
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2135
[inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
eval_user_input at
/buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:86
macro expansion at
/buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:118
[inlined]
#26 at ./task.jl:333
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2135
[inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2305
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1631
[inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:659
unknown function (ip: 0xffffffffffffffff)
Allocations: 21540897 (Pool: 21536204; Big: 4693); GC: 19
Segmentation fault (core dumped)
fingolfin commented 3 years ago

@hannes14 can you please have a look at this crash?

hannes14 commented 3 years ago

p_InitContent should not be used on Nemo coeffs types, changed with https://github.com/Singular/Singular/commit/4218c13e2434358d0a056b78d0a40377a11bcdb1

fingolfin commented 3 years ago

This doesn't crash anymore; we now get this:

julia> R, (x, y) = PolynomialRing(Singular.Nemo.ZZ, ["x", "y"])
(Singular Polynomial Ring (Coeffs(17)),(x,y),(dp(2),C), spoly{Singular.n_unknown{Nemo.fmpz}}[x, y])

julia> x//y
Error showing value of type AbstractAlgebra.Generic.Frac{spoly{Singular.n_unknown{Nemo.fmpz}}}:
ERROR: MethodError: no method matching coeff(::spoly{Singular.n_unknown{Nemo.fmpz}}, ::Int64)
Closest candidates are:
  coeff(::Nemo.fmpz_poly, ::Int64) at /Users/mhorn/.julia/packages/Nemo/ltrvd/src/flint/fmpz_poly.jl:35
  coeff(::Nemo.fmpz_abs_series, ::Int64) at /Users/mhorn/.julia/packages/Nemo/ltrvd/src/flint/fmpz_abs_series.jl:65
  coeff(::Nemo.fq_nmod_poly, ::Int64) at /Users/mhorn/.julia/packages/Nemo/ltrvd/src/flint/fq_nmod_poly.jl:45
  ...
Stacktrace:
 [1] canonical_unit(::spoly{Singular.n_unknown{Nemo.fmpz}}) at /Users/mhorn/Projekte/OSCAR/Singular.jl/src/poly/poly.jl:217
 [2] numerator at /Users/mhorn/.julia/packages/AbstractAlgebra/RnlKH/src/generic/Fraction.jl:100 [inl
...

Which I assume is OK and the issue can be closed?

thofma commented 3 years ago

No, I don't think this error is OK. https://github.com/oscar-system/Singular.jl/blob/09e29618e82813b726e66848c266676aafd819b8/src/poly/poly.jl#L217 This should probably be the leading coefficient. @tthsqe12

tthsqe12 commented 3 years ago

The error is ok because there is a separate issue for it #350