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 usage of assure #2732

Merged
merged 3 commits into from
Dec 22, 2023
Merged

Fix usage of assure #2732

merged 3 commits into from
Dec 22, 2023

Conversation

jankoboehm
Copy link
Contributor

@jankoboehm jankoboehm commented Aug 24, 2023

This removes the wrong usage of assure in the standard basis command for ideals. Possibly the last occurance. According to local tests, it should result in a segfault arising from the test "MPolyAnyMap/MPolyQuoRing segfault", which can be run by

  Oscar.test_module("Rings/MPolyAnyMap/MPolyQuo")

Note that the segfault only appears over

  Qi, i = quadratic_field(-1)

but not over QQ.

Once this is through, close #2109, since it is completely covered.

@fingolfin
Copy link
Member

So I guess now we need @hannes14 to help determine why it crashes?

@fingolfin
Copy link
Member

Just to say, the crash I get is

Test Summary:                        |Time
MPolyAnyMap/MPolyQuoRing no segfault | None  9.4s

[41341] signal (11.2): Segmentation fault: 11
in expression starting at /Users/mhorn/Projekte/OSCAR/Oscar.spielwiese/test/Rings/MPolyAnyMap/MPolyQuo.jl:10
_Z21maMap_CreatePolyIdealP10sip_sidealP8ip_sringS2_S2_RP8mapoly_sRP9maideal_s at /Users/mhorn/.julia/artifacts/b370e340135e825b6ea825fc19f912214fc6df9a/lib/libSingular-4.3.2.dylib (unknown line)
Allocations: 50365024 (Pool: 50307809; Big: 57215); GC: 34
ERROR: failed process: Process(`/Users/mhorn/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/bin/julia -Cnative -J/Users/mhorn/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/lib/julia/sys.dylib -g1 --project=/Users/mhorn/Projekte/OSCAR/Oscar.spielwiese/p/1.9/Project.toml -e 'using Test; using Oscar; Hecke.assertions(true); include("/Users/mhorn/Projekte/OSCAR/Oscar.spielwiese/test/Rings/MPolyAnyMap/MPolyQuo.jl");'`, ProcessSignaled(11)) [0]

Stacktrace:
 [1] pipeline_error
   @ ./process.jl:565 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base ./process.jl:480
 [3] run
   @ ./process.jl:477 [inlined]
 [4] test_module(file::String; new::Bool)
   @ Oscar ~/Projekte/OSCAR/Oscar.spielwiese/src/utils/tests.jl:21
 [5] test_module(file::String)
   @ Oscar ~/Projekte/OSCAR/Oscar.spielwiese/src/utils/tests.jl:12
 [6] top-level scope
   @ REPL[3]:1

The C++ symbol demangles to maMap_CreatePolyIdeal(sip_sideal*, ip_sring*, ip_sring*, ip_sring*, mapoly_s*&, maideal_s*&).

I guess it would be useful to have a more complete backtrace... So here is an interactive session:

julia> Qi, i = quadratic_field(-1)
(Imaginary quadratic field defined by x^2 + 1, sqrt(-1))

julia> Qix, (x, y) = Qi["x", "y"]
(Multivariate polynomial ring in 2 variables over imaginary quadratic field defined by x^2 + 1, AbstractAlgebra.Generic.MPoly{nf_elem}[x, y])

julia> I = ideal(Qix, elem_type(Qix)[])
ideal()

julia> Qix, = quo(Qix, I)
(Quotient of multivariate polynomial ring by ideal with 0 generators, Map from
Multivariate polynomial ring in 2 variables over imaginary quadratic field defined by x^2 + 1 to Qix defined by a julia-function with inverse)

julia> x = Qix(x)
x

julia> y = Qix(y)
y

julia> f = hom(Qix, Qix, [x^2, y^2])

Process 40778 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000002bba215f4 libSingular-4.3.2.dylib`maMap_CreatePolyIdeal(sip_sideal*, ip_sring*, ip_sring*, ip_sring*, mapoly_s*&, maideal_s*&) + 148
libSingular-4.3.2.dylib`maMap_CreatePolyIdeal:
->  0x2bba215f4 <+148>: ldr    x8, [x26]
    0x2bba215f8 <+152>: ldr    x25, [x8, #0x8]
    0x2bba215fc <+156>: cbz    x25, 0x2bba21978          ; <+1048>
    0x2bba21600 <+160>: ldr    x9, [x8]
Target 0: (julia) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000002bba215f4 libSingular-4.3.2.dylib`maMap_CreatePolyIdeal(sip_sideal*, ip_sring*, ip_sring*, ip_sring*, mapoly_s*&, maideal_s*&) + 148
    frame #1: 0x00000002bba2239c libSingular-4.3.2.dylib`fast_map_common_subexp(sip_sideal*, ip_sring*, sip_sideal*, ip_sring*) + 124
    frame #2: 0x00000002bbc14444 libsingular_julia.dylib`std::__1::__function::__func<singular_define_ideals(jlcxx::Module&)::$_33, std::__1::allocator<singular_define_ideals(jlcxx::Module&)::$_33>, sip_sideal* (sip_sideal*, ip_sring*, sip_sideal*, ip_sring*, void*)>::operator()(sip_sideal*&&, ip_sring*&&, sip_sideal*&&, ip_sring*&&, void*&&) + 84
    frame #3: 0x00000002bbc14314 libsingular_julia.dylib`jlcxx::detail::CallFunctor<sip_sideal*, sip_sideal*, ip_sring*, sip_sideal*, ip_sring*, void*>::apply(void const*, jlcxx::WrappedCppPtr, jlcxx::WrappedCppPtr, jlcxx::WrappedCppPtr, jlcxx::WrappedCppPtr, void*) + 68
    frame #4: 0x00000002d7ee40c8
    frame #5: 0x00000002d26e424c
    frame #6: 0x00000002b9c140e0
    frame #7: 0x00000001016264ec libjulia-internal.1.9.dylib`do_call + 188
    frame #8: 0x0000000101624d10 libjulia-internal.1.9.dylib`eval_body + 1476
    frame #9: 0x000000010162535c libjulia-internal.1.9.dylib`jl_interpret_toplevel_thunk + 260
    frame #10: 0x000000010163c59c libjulia-internal.1.9.dylib`jl_toplevel_eval_flex + 4620
    frame #11: 0x000000010163c4c0 libjulia-internal.1.9.dylib`jl_toplevel_eval_flex + 4400
    frame #12: 0x000000010163d2e4 libjulia-internal.1.9.dylib`ijl_toplevel_eval_in + 156
    frame #13: 0x0000000118b8d070 sys.dylib`japi1_eval_user_input_60004 at boot.jl:370
    frame #14: 0x0000000118b8da30 sys.dylib`julia_repl_backend_loop_61406 at REPL.jl:249
    frame #15: 0x0000000118b8e46c sys.dylib`japi1_YY.start_repl_backendYY.46_60048 at REPL.jl:234
    frame #16: 0x0000000118b8e648 sys.dylib`japi1_start_repl_backend_25046 at REPL.jl:231
    frame #17: 0x000000010160d5c4 libjulia-internal.1.9.dylib`ijl_apply_generic + 1732
...

@fingolfin fingolfin added this to the 1.0 milestone Dec 20, 2023
@fingolfin
Copy link
Member

@hannes14 running with a Singular & libsingular-julia compiled with -g, and Singular with --enable-debug, I am getting:

julia> f = hom(Qix, Qix, [x^2, y^2])
***omError_NullSizeAlloc: alloc of size 0
 occurred at:
  #0 at ??:0                 in ??
Ring homomorphism
  from quotient of multivariate polynomial ring by ideal()
  to quotient of multivariate polynomial ring by ideal()
defined by
  x -> x^2
  y -> y^2

I set a breakpoint on omReportError and got this backtrace:

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
  * frame #0: 0x000000016ff3807c libomalloc-0.9.6.dylib`omReportError(error=omError_NullSizeAlloc, report_error=omError_NoError, r=0x00000002c9437c50, fmt="") at omError.c:85:7
    frame #1: 0x000000016ff30634 libomalloc-0.9.6.dylib`_omDebugAlloc(size_bin=0x0000000000000000, flags=34, check='\x01', track='\x04') at omDebug.c:133:7
    frame #2: 0x00000002c9437c50 libSingular-4.3.2.dylib`maMap_CreatePolyIdeal(map_id=0x00000002c7c4bd88, map_r=0x00000002c7c3e3d8, src_r=0x00000002c7c3e510, dest_r=0x00000002c7c3e8b8, mp=0x000000016d206668, mideal=0x000000016d206660) at fast_maps.cc:260:35
    frame #3: 0x00000002c94383e0 libSingular-4.3.2.dylib`fast_map_common_subexp(map_id=0x00000002c7c4bd88, map_r=0x00000002c7c3e3d8, image_id=0x00000002c7c4e138, image_r=0x00000002c7c3e3d8) at fast_maps.cc:377:3
    frame #4: 0x00000002c943b33c libSingular-4.3.2.dylib`maMapIdeal(map_id=0x00000002c7c4bd88, preimage_r=0x00000002c7c3e3d8, image_id=0x00000002c7c4e138, image_r=0x00000002c7c3e3d8, nMap=(libpolys-4.3.2.dylib`ndCopyMap(snumber*, n_Procs_s*, n_Procs_s*) at numbers.cc:292))(snumber*, n_Procs_s*, n_Procs_s*)) at gen_maps.cc:132:16
    frame #5: 0x00000002c207eaec libsingular_julia.dylib`std::__1::__function::__func<singular_define_ideals(jlcxx::Module&)::$_33, std::__1::allocator<singular_define_ideals(jlcxx::Module&)::$_33>, sip_sideal* (sip_sideal*, ip_sring*, sip_sideal*, ip_sring*, void*)>::operator()(sip_sideal*&&, ip_sring*&&, sip_sideal*&&, ip_sring*&&, void*&&) + 84
    frame #6: 0x00000002c207ea00 libsingular_julia.dylib`jlcxx::detail::CallFunctor<sip_sideal*, sip_sideal*, ip_sring*, sip_sideal*, ip_sring*, void*>::apply(void const*, jlcxx::WrappedCppPtr, jlcxx::WrappedCppPtr, jlcxx::WrappedCppPtr, jlcxx::WrappedCppPtr, void*) + 68
...

@fingolfin
Copy link
Member

(This is with Singular 4.3.2p12, commit Singular/Singular@3bda0f8)

@fingolfin
Copy link
Member

So yeah, we are taking an ideal with zero generators, and that code in the Singular kernel doesn't seem to deal well with it...

@fingolfin
Copy link
Member

@hannes14 implemented a fix in Singular, we'll retest once that has landed in a Singular.jl release

@fingolfin
Copy link
Member

Seems to be working now

@jankoboehm jankoboehm marked this pull request as ready for review December 22, 2023 14:14
@thofma thofma merged commit e818a16 into oscar-system:master Dec 22, 2023
15 of 19 checks passed
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.

4 participants