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

Giac consistent segfault in giac::zmakelinesplit on macos M2 #38864

Open
2 tasks done
vbraun opened this issue Oct 27, 2024 · 6 comments
Open
2 tasks done

Giac consistent segfault in giac::zmakelinesplit on macos M2 #38864

vbraun opened this issue Oct 27, 2024 · 6 comments
Labels

Comments

@vbraun
Copy link
Member

vbraun commented Oct 27, 2024

Steps To Reproduce

Build Sage on macos M2

Expected Behavior

Testsuite should succeed

Actual Behavior

There are a few giac-related segfaults, for example this one in void giac::zmakelinesplit<giac::tdeg_t14>(giac::zpolymod<giac::tdeg_t14> const&, giac::tdeg_t14 const*, std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14> > const&, void*, std::__1::vector<int, std::__1::allocator<int> > const&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short> >*, int):

sage: A9 = PolynomialRing(QQ, 9, 'x') ## line 4384 ##
sage: I9 = sage.rings.ideal.Katsura(A9) ## line 4385 ##
sage: print("possible output from giac", flush=True); I9.groebner_basis("giac", proba_epsilon=1e-7)  # long time (3s) ## line 4386 ##
possible output from giac
------------------------------------------------------------------------
0   signals.cpython-312-darwin.so       0x0000000105ad80b0 sigdie + 92
1   signals.cpython-312-darwin.so       0x0000000105ad7fe8 cysigs_signal_handler + 472
2   libsystem_platform.dylib            0x000000018616a584 _sigtramp + 56
3   libgiac.0.dylib                     0x000000011d0be310 _ZN4giac14zmakelinesplitINS_8tdeg_t14EEEvRKNS_8zpolymodIT_EEPKS3_RKNSt3__16vectorIS3_NS9_9allocatorIS3_EEEEPvRKNSA_IiNSB_IiEEEERNSA_ItNSB_ItEEEEPSM_i + 628
4   libgiac.0.dylib                     0x000000011d0bddb8 _ZN4giac10do_zbuildMINS_8tdeg_t14EEEvRKNS_12vectzpolymodIT_EERKNSt3__16vectorIjNS7_9allocatorIjEEEEibRKNS8_INS8_IS3_NS9_IS3_EEEENS9_ISF_EEEERKSF_RKNS8_IiNS9_IiEEEEPvRNS8_INS_12coeffindex_tENS9_ISR_EEEEjRNS8_INS8_ItNS9_ItEEEENS9_ISW_EEEERNS8_ISN_NS9_ISN_EEEERNS8_INS_14sparse_elementENS9_IS13_EEEEiii + 404
5   libgiac.0.dylib                     0x000000011d0b5958 _ZN4giac7zbuildMINS_8tdeg_t14EEEvRKNS_12vectzpolymodIT_EERKNSt3__16vectorIjNS7_9allocatorIjEEEEibiRKNS8_INS8_IS3_NS9_IS3_EEEENS9_ISF_EEEERKSF_RKNS8_IiNS9_IiEEEERPvRNS8_INS_12coeffindex_tENS9_ISS_EEEEjRNS8_INS8_ItNS9_ItEEEENS9_ISX_EEEERNS8_ISN_NS9_ISN_EEEERNS8_INS_14sparse_elementENS9_IS14_EEEEi + 264
6   libgiac.0.dylib                     0x000000011d0add18 _ZN4giac6zf4modINS_8tdeg_t14EEEiRNS_12vectzpolymodIT_EERKNSt3__16vectorIjNS6_9allocatorIjEEEEiRKNS7_INS_5paireENS8_ISD_EEEERPSB_S5_bRjPSF_RNS7_INS_7zinfo_tIS3_EENS8_ISN_EEEESK_bibii + 4348
7   libgiac.0.dylib                     0x000000011d0a3ed0 _ZN4giac10in_zgbasisINS_8tdeg_t14EEEbRNS_11vectpolymodIT_EEjRNSt3__16vectorIjNS6_9allocatorIjEEEEibPNS7_INS_5paireENS8_ISC_EEEERNS7_INS_7zinfo_tIS3_EENS8_ISH_EEEEbbbib + 6400
8   libgiac.0.dylib                     0x000000011d09267c _ZN4giac10zgbasisrurINS_8tdeg_t14EEEbRNS_9vectpoly8IT_EERNS_11vectpolymodIS3_EERNSt3__16vectorIjNS9_9allocatorIjEEEEibPNSA_INS_5paireENSB_ISF_EEEERNSA_INS_7zinfo_tIS3_EENSB_ISK_EEEEbbbbibRiS8_RNS_7polymodIS3_EESR_SR_PSQ_SS_ + 376
9   libgiac.0.dylib                     0x000000011d08b268 _ZN4giac13in_mod_gbasisINS_8tdeg_t14EEEiRNS_9vectpoly8IT_EEbbRiPKNS_7contextENS_14gbasis_param_tEi + 4476
10  libgiac.0.dylib                     0x000000011d078c7c _ZN4giac7gbasis8ERKNS_8vectpolyERNS_7order_tERS0_PNS_11environmentEbbRiPKNS_7contextENS_14gbasis_param_tE + 552
11  libgiac.0.dylib                     0x000000011cb98464 _ZN4giacL11giac_gbasisERNS_8vectpolyERKNS_3genEPNS_11environmentEiRiPKNS_7contextENS_14gbasis_param_tE + 960
12  libgiac.0.dylib                     0x000000011cb97e78 _ZN4giac6gbasisERKNS_8vectpolyERKNS_3genEbiPNS_11environmentERiPKNS_7contextENS_14gbasis_param_tE + 672
13  libgiac.0.dylib                     0x000000011cb99bb8 _ZN4giac7_gbasisERKNS_3genEPKNS_7contextE + 3812
14  libgiac.0.dylib                     0x000000011d2eca74 _ZNK4giac3genclERKS0_S2_PKNS_7contextE + 6468
15  giac.cpython-312-darwin.so          0x000000011abff2b8 _ZL50__pyx_pf_4sage_4libs_4giac_4giac_5Pygen_21__call__P39__pyx_obj_4sage_4libs_4giac_4giac_PygenP7_object + 1644
16  giac.cpython-312-darwin.so          0x000000011abf39fc _ZL50__pyx_pw_4sage_4libs_4giac_4giac_5Pygen_22__call__P7_objectS0_S0_ + 104
17  libpython3.12.dylib                 0x000000010506f680 wrapperdescr_call + 384
18  giac.cpython-312-darwin.so          0x000000011ac1aadc _ZL57__pyx_pw_4sage_4libs_4giac_4giac_12GiacFunction_1__call__P7_objectPKS0_lS0_ + 1004
19  libpython3.12.dylib                 0x00000001050641f8 _PyObject_FastCallDictTstate + 276
20  libpython3.12.dylib                 0x00000001050651cc _PyObject_Call_Prepend + 160
21  libpython3.12.dylib                 0x00000001050c8f84 slot_tp_call + 208
22  giac.cpython-312-darwin.so          0x000000011ab39f48 _ZL62__pyx_pw_4sage_4libs_4giac_4giac_16GiacMethods_base_1009gbasisP7_objectS0_S0_ + 368
23  libpython3.12.dylib                 0x000000010506fb40 method_vectorcall_VARARGS_KEYWORDS + 232
24  libpython3.12.dylib                 0x0000000105064a98 PyObject_Vectorcall + 88
25  libpython3.12.dylib                 0x0000000105142cd8 _PyEval_EvalFrameDefault + 37148
26  libpython3.12.dylib                 0x0000000105064960 _PyVectorcall_Call + 116
27  cachefunc.cpython-312-darwin.so     0x00000001059717fc __pyx_pw_4sage_4misc_9cachefunc_18CachedMethodCaller_5_instance_call + 216
28  libpython3.12.dylib                 0x00000001050ac910 cfunction_call + 92
29  cachefunc.cpython-312-darwin.so     0x000000010596f414 __pyx_pw_4sage_4misc_9cachefunc_18CachedMethodCaller_7__call__ + 2776
30  libpython3.12.dylib                 0x0000000105064388 _PyObject_MakeTpCall + 252
31  libpython3.12.dylib                 0x0000000105142cd8 _PyEval_EvalFrameDefault + 37148
32  libpython3.12.dylib                 0x000000010513998c PyEval_EvalCode + 260
33  libpython3.12.dylib                 0x0000000105137578 builtin_exec + 1008
34  libpython3.12.dylib                 0x0000000105143adc _PyEval_EvalFrameDefault + 40736
35  libpython3.12.dylib                 0x0000000105064170 _PyObject_FastCallDictTstate + 140
36  libpython3.12.dylib                 0x00000001050651cc _PyObject_Call_Prepend + 160
37  libpython3.12.dylib                 0x00000001050c8f84 slot_tp_call + 208
38  libpython3.12.dylib                 0x0000000105064388 _PyObject_MakeTpCall + 252
39  libpython3.12.dylib                 0x0000000105142cd8 _PyEval_EvalFrameDefault + 37148
40  libpython3.12.dylib                 0x00000001050641f8 _PyObject_FastCallDictTstate + 276
41  libpython3.12.dylib                 0x00000001050651cc _PyObject_Call_Prepend + 160
42  libpython3.12.dylib                 0x00000001050ca0a0 slot_tp_init + 208
43  libpython3.12.dylib                 0x00000001050c3e78 type_call + 396
44  libpython3.12.dylib                 0x0000000105064388 _PyObject_MakeTpCall + 252
45  libpython3.12.dylib                 0x0000000105142cd8 _PyEval_EvalFrameDefault + 37148
46  libpython3.12.dylib                 0x000000010513998c PyEval_EvalCode + 260
47  libpython3.12.dylib                 0x00000001051947e4 run_mod + 168
48  libpython3.12.dylib                 0x0000000105192f80 _PyRun_SimpleFileObject + 860
49  libpython3.12.dylib                 0x00000001051929f0 _PyRun_AnyFileObject + 140
50  libpython3.12.dylib                 0x00000001051b43b0 Py_RunMain + 2004
51  libpython3.12.dylib                 0x00000001051b4734 pymain_main + 248
52  libpython3.12.dylib                 0x00000001051b477c Py_BytesMain + 40
53  dyld                                0x0000000185daf154 start + 2476
------------------------------------------------------------------------
Unhandled SIGSEGV during signal handling.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.
------------------------------------------------------------------------

**********************************************************************
----------------------------------------------------------------------
sage -t --long --warn-long 30.0 --random-seed=0 src/sage/rings/polynomial/multi_polynomial_ideal.py  # Killed due to segmentation fault

Additional Information

For lack of an upstream bug tracker, will use this one to track the issue

Environment

  • macOS
  • Sage 10.5.beta7, also previous versions

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@parisseb
Copy link

I need to reproduce that with giac natively. I understand it's a call to gbasis with katsura 9 (but maybe with katsura10, katsura indexation is not always consistent)
kat9:=[x1 + 2*x2 + 2*x3 + 2*x4 + 2*x5 + 2*x6 + 2*x7 + 2*x8 + 2*x9 - 1, x1^2 + 2*x2^2 + 2*x3^2 + 2*x4^2 + 2*x5^2 + 2*x6^2 + 2*x7^2 + 2*x8^2 + 2*x9^2 - x1, 2*x1*x2 + 2*x2*x3 + 2*x3*x4 + 2*x4*x5 + 2*x5*x6 + 2*x6*x7 + 2*x7*x8 + 2*x8*x9 - x2, x2^2 + 2*x1*x3 + 2*x2*x4 + 2*x3*x5 + 2*x4*x6 + 2*x5*x7 + 2*x6*x8 + 2*x7*x9 - x3, 2*x2*x3 + 2*x1*x4 + 2*x2*x5 + 2*x3*x6 + 2*x4*x7 + 2*x5*x8 + 2*x6*x9 - x4, x3^2 + 2*x2*x4 + 2*x1*x5 + 2*x2*x6 + 2*x3*x7 + 2*x4*x8 + 2*x5*x9 - x5, 2*x3*x4 + 2*x2*x5 + 2*x1*x6 + 2*x2*x7 + 2*x3*x8 + 2*x4*x9 - x6, x4^2 + 2*x3*x5 + 2*x2*x6 + 2*x1*x7 + 2*x2*x8 + 2*x3*x9 - x7, 2*x4*x5 + 2*x3*x6 + 2*x2*x7 + 2*x1*x8 + 2*x2*x9 - x8]; H:=gbasis(kat9,[x1,x2,x3,x4,x5,x6,x7,x8,x9])
Can you reproduce the crash while running from giac interpreter, that is if you put the code above in a text file, say katsura9 and run
icas katsura9
N.B.: If you have the source code of giac, this file is already available in the examples/groebner subdirectory.
If you can reproduce the crash, I will also need some additional informations: how many threads are processed in parallel? (this is displayed at startup with something like
// Maximum number of parallel threads 1
)
And I'll check when I'll go back at the office where I have a mac.
Thank you

@vbraun
Copy link
Member Author

vbraun commented Oct 27, 2024

buildbot-sage@Mini-M2:~/worker/sage_git/build$ giac
// Maximum number of parallel threads 1
// Unable to find keyword file /Applications/usr/share/giac/doc/en/keywords
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> kat9:=[x1 + 2*x2 + 2*x3 + 2*x4 + 2*x5 + 2*x6 + 2*x7 + 2*x8 + 2*x9 - 1, x1^2 + 2*x2^2 + 2*x3^2 + 2*x4^2 + 2*x5^2 + 2*x6^2 + 2*x7^2 + 2*x8^2 + 2*x9^2 - x1, 2*x1*x2 + 2*x2*x3 + 2*x3*x4 + 2*x4*x5 + 2*x5*x6 + 2*x6*x7 + 2*x7*x8 + 2*x8*x9 - x2, x2^2 + 2*x1*x3 + 2*x2*x4 + 2*x3*x5 + 2*x4*x6 + 2*x5*x7 + 2*x6*x8 + 2*x7*x9 - x3, 2*x2*x3 + 2*x1*x4 + 2*x2*x5 + 2*x3*x6 + 2*x4*x7 + 2*x5*x8 + 2*x6*x9 - x4, x3^2 + 2*x2*x4 + 2*x1*x5 + 2*x2*x6 + 2*x3*x7 + 2*x4*x8 + 2*x5*x9 - x5, 2*x3*x4 + 2*x2*x5 + 2*x1*x6 + 2*x2*x7 + 2*x3*x8 + 2*x4*x9 - x6, x4^2 + 2*x3*x5 + 2*x2*x6 + 2*x1*x7 + 2*x2*x8 + 2*x3*x9 - x7, 2*x4*x5 + 2*x3*x6 + 2*x2*x7 + 2*x1*x8 + 2*x2*x9 - x8]; H:=gbasis(kat9,[x1,x2,x3,x4,x5,x6,x7,x8,x9])
zsh: segmentation fault  giac

@vbraun
Copy link
Member Author

vbraun commented Oct 27, 2024

And in the debugger

$ sudo lldb giac
(lldb) target create "giac"
Current executable set to '/Users/vbraun/Sage/local/bin/giac' (arm64).
(lldb) run
Process 76999 launched: '/Users/vbraun/Sage/local/bin/giac' (arm64)
// Maximum number of parallel threads 1
// Unable to find keyword file /Applications/usr/share/giac/doc/en/keywords
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See kat9:=[x1 + 2*x2 + 2*x3 + 2*x4 + 2*x5 + 2*x6 + 2*x7 + 2*x8 + 2*x9 - 1, x1^2 + 2*x2^2 + 2*x3^2 + 2*x4^2 + 2*x5^2 + 2*x6^2 + 2*x7^2 + 2*x8^2 + 2*x9^2 - x1, 2*x1*x2 + 2*x2*x3 + 2*x3*x4 + 2*x4*x5 + 2*x5*x6 + 2*x6*x7 + 2*x7*x8 + 2*x8*x9 - x2, x2^2 + 2*x1*x3 + 2*x2*x4 + 2*x3*x5 + 2*x4*x6 + 2*x5*x7 + 2*x6*x8 + 2*x7*x9 - x3, 2*x2*x3 + 2*x1*x4 + 2*x2*x5 + 2*x3*x6 + 2*x4*x7 + 2*x5*x8 + 2*x6*x9 - x4, x3^2 + 2*x2*x4 + 2*x1*x5 + 2*x2*x6 + 2*x3*x7 + 2*x4*x8 + 2*x5*x9 - x5, 2*x3*x4 + 2*x2*x5 + 2*x1*x6 + 2*x2*x7 + 2*x3*x8 + 2*x4*x9 - x6, x4^2 + 2*x3*x5 + 2*x2*x6 + 2*x1*x7 + 2*x2*x8 + 2*x3*x9 - x7, 2*x4*x5 + 2*x3*x6 + 2*x2*x7 + 2*x1*x8 + 2*x2*x9 - x8]; H:=gbasis(kat9,[x1,x2,x3,x4,x5,x6,x7,x8,x9])
Process 76999 stopped help
* thread #9, stop reason = EXC_BAD_ACCESS (code=1, address=0x11f200000) 1, x1^2 + 2*x2^2 + 2*x3^2 + 2*x4^2 + 2*x5^2 + 2*x6^2 + 2*x7^2 + 2*x8^2 + 2*x9^2 - x1, 2*x1*x2 + 2*x2*x3 + 2*x3*x4 + 2*x4*x5 + 2*x5*x6 + 2*x    frame #0: 0x000000010253234c libgiac.0.dylib`void giac::zmakelinesplit<giac::tdeg_t14>(giac::zpolymod<giac::tdeg_t14> const&, giac::tdeg_t14 const*, std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>> const&, void*, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>*, int) + 656at9,[x1,x2,x3,x4,x5,x6,x7,x8,x9])
libgiac.0.dylib`giac::zmakelinesplit<giac::tdeg_t14>:
->  0x10253234c <+656>: ldp    x12, x13, [x8]
    0x102532350 <+660>: cmp    x12, x9
    0x102532354 <+664>: ccmp   x13, x11, #0x0, eq
    0x102532358 <+668>: b.eq   0x102532374               ; <+696>
Target 0: (giac) stopped.
(lldb) bt
* thread #9, stop reason = EXC_BAD_ACCESS (code=1, address=0x11f200000)
  * frame #0: 0x000000010253234c libgiac.0.dylib`void giac::zmakelinesplit<giac::tdeg_t14>(giac::zpolymod<giac::tdeg_t14> const&, giac::tdeg_t14 const*, std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>> const&, void*, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>*, int) + 656
    frame #1: 0x0000000102531dd8 libgiac.0.dylib`void giac::do_zbuildM<giac::tdeg_t14>(giac::vectzpolymod<giac::tdeg_t14> const&, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>> const&, int, bool, std::__1::vector<std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>>, std::__1::allocator<std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>>>> const&, std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>> const&, std::__1::vector<int, std::__1::allocator<int>> const&, void*, std::__1::vector<giac::coeffindex_t, std::__1::allocator<giac::coeffindex_t>>&, unsigned int, std::__1::vector<std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>, std::__1::allocator<std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>>>&, std::__1::vector<std::__1::vector<int, std::__1::allocator<int>>, std::__1::allocator<std::__1::vector<int, std::__1::allocator<int>>>>&, std::__1::vector<giac::sparse_element, std::__1::allocator<giac::sparse_element>>&, int, int, int) + 404
    frame #2: 0x0000000102529978 libgiac.0.dylib`void giac::zbuildM<giac::tdeg_t14>(giac::vectzpolymod<giac::tdeg_t14> const&, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>> const&, int, bool, int, std::__1::vector<std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>>, std::__1::allocator<std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>>>> const&, std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>> const&, std::__1::vector<int, std::__1::allocator<int>> const&, void*&, std::__1::vector<giac::coeffindex_t, std::__1::allocator<giac::coeffindex_t>>&, unsigned int, std::__1::vector<std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>, std::__1::allocator<std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>>>&, std::__1::vector<std::__1::vector<int, std::__1::allocator<int>>, std::__1::allocator<std::__1::vector<int, std::__1::allocator<int>>>>&, std::__1::vector<giac::sparse_element, std::__1::allocator<giac::sparse_element>>&, int) + 264
    frame #3: 0x0000000102521d38 libgiac.0.dylib`int giac::zf4mod<giac::tdeg_t14>(giac::vectzpolymod<giac::tdeg_t14>&, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>> const&, int, std::__1::vector<giac::paire, std::__1::allocator<giac::paire>> const&, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>> const*&, giac::vectzpolymod<giac::tdeg_t14>&, bool, unsigned int&, std::__1::vector<giac::paire, std::__1::allocator<giac::paire>>*, std::__1::vector<giac::zinfo_t<giac::tdeg_t14>, std::__1::allocator<giac::zinfo_t<giac::tdeg_t14>>>&, unsigned int&, bool, int, bool, int, int) + 4348
    frame #4: 0x0000000102517ef0 libgiac.0.dylib`bool giac::in_zgbasis<giac::tdeg_t14>(giac::vectpolymod<giac::tdeg_t14>&, unsigned int, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>>&, int, bool, std::__1::vector<giac::paire, std::__1::allocator<giac::paire>>*, std::__1::vector<giac::zinfo_t<giac::tdeg_t14>, std::__1::allocator<giac::zinfo_t<giac::tdeg_t14>>>&, bool, bool, bool, int, bool) + 6400
    frame #5: 0x000000010250669c libgiac.0.dylib`bool giac::zgbasisrur<giac::tdeg_t14>(giac::vectpoly8<giac::tdeg_t14>&, giac::vectpolymod<giac::tdeg_t14>&, std::__1::vector<unsigned int, std::__1::allocator<unsigned int>>&, int, bool, std::__1::vector<giac::paire, std::__1::allocator<giac::paire>>*, std::__1::vector<giac::zinfo_t<giac::tdeg_t14>, std::__1::allocator<giac::zinfo_t<giac::tdeg_t14>>>&, bool, bool, bool, bool, int, bool, int&, giac::vectpolymod<giac::tdeg_t14>&, giac::polymod<giac::tdeg_t14>&, giac::polymod<giac::tdeg_t14>&, giac::polymod<giac::tdeg_t14>&, giac::polymod<giac::tdeg_t14>*, giac::polymod<giac::tdeg_t14>*) + 376
    frame #6: 0x00000001024ff288 libgiac.0.dylib`int giac::in_mod_gbasis<giac::tdeg_t14>(giac::vectpoly8<giac::tdeg_t14>&, bool, bool, int&, giac::context const*, giac::gbasis_param_t, int) + 4476
    frame #7: 0x00000001024ecc9c libgiac.0.dylib`giac::gbasis8(giac::vectpoly const&, giac::order_t&, giac::vectpoly&, giac::environment*, bool, bool, int&, giac::context const*, giac::gbasis_param_t) + 552
    frame #8: 0x000000010200c484 libgiac.0.dylib`giac::giac_gbasis(giac::vectpoly&, giac::gen const&, giac::environment*, int, int&, giac::context const*, giac::gbasis_param_t) + 960
    frame #9: 0x000000010200be98 libgiac.0.dylib`giac::gbasis(giac::vectpoly const&, giac::gen const&, bool, int, giac::environment*, int&, giac::context const*, giac::gbasis_param_t) + 672
    frame #10: 0x000000010200dbd8 libgiac.0.dylib`giac::_gbasis(giac::gen const&, giac::context const*) + 3812
    frame #11: 0x0000000101eeca24 libgiac.0.dylib`giac::symbolic::eval(int, giac::context const*) const + 1320
    frame #12: 0x0000000102712fc8 libgiac.0.dylib`giac::gen::in_eval(int, giac::gen&, giac::context const*) const + 1304
    frame #13: 0x0000000101eed42c libgiac.0.dylib`giac::eval_sto(giac::gen const&, int, giac::context const*) + 1824
    frame #14: 0x0000000102712fc8 libgiac.0.dylib`giac::gen::in_eval(int, giac::gen&, giac::context const*) const + 1304
    frame #15: 0x00000001027128ac libgiac.0.dylib`giac::eval_VECT(giac::gen const&, giac::gen&, int, int, giac::context const*) + 956
    frame #16: 0x00000001027199ac libgiac.0.dylib`giac::in_eval_vect(giac::gen const&, giac::gen&, int, giac::context const*) + 9344
    frame #17: 0x00000001024ba3b8 libgiac.0.dylib`giac::protectevalorevalf(giac::gen const&, int, bool, giac::context const*) + 808
    frame #18: 0x0000000102291bc8 libgiac.0.dylib`giac::in_thread_eval(void*) + 284
    frame #19: 0x0000000186139f94 libsystem_pthread.dylib`_pthread_start + 136

@parisseb
Copy link

Thanks for the detailled information. The lldb session would be more interesting if giac was compiled with debug infos, it should be possible to see the precise line where the segfault happens, and examine variables. I'll do that when I'll have access to a Mac, should be on Tuesday November 5th or Wednesday 6th.
Hopefully, that's a mono-thread execution, this should be easier to fix than a multi-threaded gbasis.

@vbraun
Copy link
Member Author

vbraun commented Oct 29, 2024

Compiled with debug symbols:

(lldb) run
Process 43866 launched: '/Users/vbraun/Sage/local/bin/giac' (arm64)
// Maximum number of parallel threads 1
// Unable to find keyword file /Applications/usr/share/giac/doc/en/keywords
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See kat9:=[x1 + 2*x2 + 2*x3 + 2*x4 + 2*x5 + 2*x6 + 2*x7 + 2*x8 + 2*x9 - 1, x1^2 + 2*x2^2 + 2*x3^2 + 2*x4^2 + 2*x5^2 + 2*x6^2 + 2*x7^2 + 2*x8^2 + 2*x9^2 - x1, 2*x1*x2 + 2*x2*x3 + 2*x3*x4 + 2*x4*x5 + 2*x5*x6 + 2*x6*x7 + 2*x7*x8 + 2*x8*x9 - x2, x2^2 + 2*x1*x3 + 2*x2*x4 + 2*x3*x5 + 2*x4*x6 + 2*x5*x7 + 2*x6*x8 + 2*x7*x9 - x3, 2*x2*x3 + 2*x1*x4 + 2*x2*x5 + 2*x3*x6 + 2*x4*x7 + 2*x5*x8 + 2*x6*x9 - x4, x3^2 + 2*x2*x4 + 2*x1*x5 + 2*x2*x6 + 2*x3*x7 + 2*x4*x8 + 2*x5*x9 - x5, 2*x3*x4 + 2*x2*x5 + 2*x1*x6 + 2*x2*x7 + 2*x3*x8 + 2*x4*x9 - x6, x4^2 + 2*x3*x5 + 2*x2*x6 + 2*x1*x7 + 2*x2*x8 + 2*x3*x9 - x7, 2*x4*x5 + 2*x3*x6 + 2*x2*x7 + 2*x1*x8 + 2*x2*x9 - x8]; H:=gbasis(kat9,[x1,x2,x3,x4,x5,x6,x7,x8,x9])
Process 43866 stopped
* thread #9, stop reason = EXC_BAD_ACCESS (code=1, address=0x11b800000) 1, x1^2 + 2*x2^2 + 2*x3^2 + 2*x4^2 + 2*x5^2 + 2*x6^2 + 2*x7^2 + 2*x8^2 + 2*x9^2 - x1, 2*x1*x2 + 2*x2*x3 + 2*x3*x4 + 2*x4*x5 + 2*x5*x6 + 2*x    frame #0: 0x000000010253234c libgiac.0.dylib`void giac::zmakelinesplit<giac::tdeg_t14>(giac::zpolymod<giac::tdeg_t14> const&, giac::tdeg_t14 const*, std::__1::vector<giac::tdeg_t14, std::__1::allocator<giac::tdeg_t14>> const&, void*, std::__1::vector<int, std::__1::allocator<int>> const&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>&, std::__1::vector<unsigned short, std::__1::allocator<unsigned short>>*, int) [inlined] giac::operator==(x=0x000000011b800000, y=0x0000000170253a30) at cocoa.cc:16304:12 [opt]
   16301	#ifdef INT128
   16302	    return * (const uint128_t *) &x == * (uint128_t *) &y;
   16303	#else
-> 16304	    return ((longlong *) x.tab)[0] == ((longlong *) y.tab)[0] && ((longlong *) x.tab)[1] == ((longlong *) y.tab)[1];
   16305	#endif
   16306	  }
   16307	  inline bool operator != (const tdeg_t14 & x,const tdeg_t14 & y){ 
Target 0: (giac) stopped.
warning: libgiac.0.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb) print x.tab
error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory
(lldb) print x
(const giac::tdeg_t14 &) 0x000000011b800000: {
   = {
    tab = ""
     = {
      tdeg = <read memory from 0x11b800000 failed (0 of 1 bytes read)>

      tdeg2 = <read memory from 0x11b800001 failed (0 of 1 bytes read)>

      order_ = (o = <read memory from 0x11b800002 failed (0 of 2 bytes read)>, dim = <read memory from 0x11b800004 failed (0 of 1 bytes read)>, lex = <read memory from 0x11b800005 failed (0 of 1 bytes read)>)
      ui = <read memory from 0x11b800008 failed (0 of 8 bytes read)>

    }
  }
}
(lldb) print y
(const giac::tdeg_t14 &) 0x0000000170253a30: {
   = {
    tab = "\U00000003\0\0\0\0\0\U00000001\0\0\0\0\0\0\0\0\U00000002"
     = {
      tdeg = '\x03'
      tdeg2 = '\0'
      order_ = (o = 0, dim = '\0', lex = '\0')
      ui = 0x0200000000000000
    }
  }
}
(lldb) up 
frame #1: 0x000000010253234c libgiac.0.dylib`void giac::zmakelinesplit<giac::tdeg_t14>(p=0x000000011a808258, shiftptr=0x000000011a80f1d0, R=size=708, Rhashptr=<unavailable>, Rdegpos=size=6, v=size=3, prevline=<unavailable>, start=0) at cocoa.cc:10956:11 [opt]
   10953		  }
   10954		}
   10955		for (;jt!=jtend;++jt){
-> 10956		  if (*jt==u){
   10957		    pushsplit(v,pos,int(jt-Rbegin));
   10958		    ++jt;
   10959		    break;

@parisseb
Copy link

parisseb commented Oct 30, 2024

It seems your source code is not synchronized with mine, so it's hard to find some useful information here, most probably the x variable refers to a non existent address, and the y variable itself is suspect (dimension 0). Moreover since there are optimizations in the data structure, printing variables is not very informative for the type of x and y. I have a gdb macro in my .gdbinit file

echo Defining v as print command for giac types\n
set print repeats 0
define v
print ($arg0).dbgprint()
end

if it applies to lldb as well, then you can type v varname instead of p varname. Otherwise p varname.dbgprint() will display a monomial power in a more informative way.
But it's probably best to wait next week, I'll check with my own compilation of giac on macos and debug it myself if it fails for me too. BTW, my binary distribution of Giac/Xcas for MacOS is available here if you want to check before :
https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/xcas_mac.dmg.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants