-Wp,-D_GLIBCXX_ASSERTIONS

Librairie C++ de calcul formel/ C++ symbolic computation library

Modérateur : xcasadmin

frederic han
Messages : 1137
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

-Wp,-D_GLIBCXX_ASSERTIONS

Message par frederic han » mar. janv. 10, 2023 2:58 pm

Hi bernard,
in fedora giac is built with the following:
-Wp,-D_GLIBCXX_ASSERTIONS

but the follwing test crashes (any versions 1.7 and 1.9)

Code : Tout sélectionner

0>> factor((x^202+x^101+1)/(x^2+x+1))

[New Thread 0x7fffc9ffb640 (LWP 135666)]
/usr/include/c++/12/bits/stl_vector.h:1142: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

Thread 15 "icas" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffc9ffb640 (LWP 135666)]
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
Downloading 0.00 MB source file /usr/src/debug/glibc-2.35-21.fc36.x86_64/nptl/pthread_kill.c
44	      return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff588ec73 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff583e986 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff58287f4 in __GI_abort () at abort.c:79
#4  0x00007ffff5cd7da0 in std::__glibcxx_assert_fail (file=file@entry=0x7ffff781fee8 "/usr/include/c++/12/bits/stl_vector.h", line=line@entry=1142, 
    function=function@entry=0x7ffff7820a90 "std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned i"..., condition=condition@entry=0x7ffff781fbbe "__n < this->size()") at ../../../../../libstdc++-v3/src/c++11/debug.cc:60
#5  0x00007ffff6d300a7 in std::vector<int, std::allocator<int> >::operator[] (this=0x7fffc9fee650, __n=0) at /usr/include/c++/12/bits/stl_vector.h:1140
#6  std::vector<int, std::allocator<int> >::operator[] (__n=<optimized out>, this=<optimized out>) at /usr/include/c++/12/bits/stl_vector.h:1140
#7  giac::a_minus_qsize2_b (ua=std::vector of length 0, capacity 256, q=std::vector of length 2, capacity 2 = {...}, ub=std::vector of length 1, capacity 256 = {...}, 
    ur=std::vector of length 1, capacity 256 = {...}, p=p@entry=2013265921) at modpoly.cc:3976
#8  0x00007ffff6d300e9 in giac::a_minus_qsize2_b (ua=std::vector of length 0, capacity 256, q=std::vector of length 2, capacity 2 = {...}, 
    ub=std::vector of length 1, capacity 256 = {...}, ur=std::vector of length 1, capacity 256 = {...}, p=p@entry=2013265921, q0inv=<optimized out>, q1inv=@0x7fffc9fee170: 0)
    at modpoly.cc:4029


parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: -Wp,-D_GLIBCXX_ASSERTIONS

Message par parisse » mar. janv. 10, 2023 6:08 pm

Seems strange, the line where the assertion fails is

Code : Tout sélectionner

    longlong q1=-q[0],q0=-q[1];
and in your trace q has size 2.
I suggest to recompile with -g and without -O2 and run under gdb.

frederic han
Messages : 1137
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: -Wp,-D_GLIBCXX_ASSERTIONS

Message par frederic han » mer. janv. 11, 2023 10:52 am

isn't it a bit later with ua? (NB debug is with 1.9.0.29 source)

Code : Tout sélectionner

Thread 15 "icas" hit Breakpoint 1, giac::a_minus_qsize2_b (ua=std::vector of length 0, capacity 256, q=std::vector of length 2, capacity 2 = {...}, ub=std::vector of length 1, capacity 256 = {...}, ur=std::vector of length 0, capacity 256, p=2013265921) at modpoly.cc:3974
3974	  void a_minus_qsize2_b(const vector<int> & ua,const vector<int> & q,const vector<int> &ub,vector<int> & ur,int p){
(gdb) n
3975	    double invp=find_invp(p);
(gdb) n
3976	    longlong q1=-q[0],q0=-q[1];
(gdb) p ua
$2 = std::vector of length 0, capacity 256
(gdb) p q
$3 = std::vector of length 2, capacity 2 = {920598989, 1986596038}
(gdb) n
3977	    ur.clear(); ur.push_back((q1*ub.front())%p);
(gdb) n

Thread 15 "icas" hit Breakpoint 2, giac::a_minus_qsize2_b (ua=std::vector of length 0, capacity 256, q=std::vector of length 2, capacity 2 = {...}, ub=std::vector of length 1, capacity 256 = {...}, ur=std::vector of length 1, capacity 256 = {...}, p=2013265921) at modpoly.cc:3978
3978	    const int * it=&ub[0],*itend=it-1+ub.size(),*itmid=it+ub.size()-ua.size(),*jt=&ua[0];
(gdb) p ua
$4 = std::vector of length 0, capacity 256
(gdb) p ub
$5 = std::vector of length 1, capacity 256 = {1}
(gdb) p it
$6 = (const int *) 0x0
(gdb) n
/usr/include/c++/12/bits/stl_vector.h:1142: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

Thread 15 "icas" received signal SIGABRT, Aborted.
0x00007ffff4e8ec0c in __pthread_kill_implementation () from /lib64/libc.so.6

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: -Wp,-D_GLIBCXX_ASSERTIONS

Message par parisse » mer. janv. 11, 2023 11:29 am

Indeed, *jt=&ua[0] should be initialized later.

frederic han
Messages : 1137
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: -Wp,-D_GLIBCXX_ASSERTIONS

Message par frederic han » jeu. janv. 12, 2023 7:30 pm

Thank you.
When running read("testnormalize") (in the check dir) there is also:

Code : Tout sélectionner

/usr/include/c++/12/bits/stl_vector.h:1206: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::front() [with _Tp = giac::T_unsigned<int, long long unsigned int>; _Alloc = std::allocator<giac::T_unsigned<int, long long unsigned int> >; reference = giac::T_unsigned<int, long long unsigned int>&]: Assertion '!this->empty()' failed.
[Thread 0x7fff877fe640 (LWP 23400) exited]
/usr/include/c++/12/bits/stl_vector.h:1206: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::front() [with _Tp = giac::T_unsigned<int, long long unsigned int>; _Alloc = std::allocator<giac::T_unsigned<int, long long unsigned int> >; reference = giac::T_unsigned<int, long long unsigned int>&]: Assertion '!this->empty()' failed.
/usr/include/c++/12/bits/stl_vector.h:1206: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::front() [with _Tp = giac::T_unsigned<int, long long unsigned int>; _Alloc = std::allocator<giac::T_unsigned<int, long long unsigned int> >; reference = giac::T_unsigned<int, long long unsigned int>&]: Assertion '!this->empty()' failed.

Thread 15 "icas" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffb97fa640 (LWP 22917)]
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44	      return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff4e8ec73 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff4e3e986 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff4e287f4 in __GI_abort () at abort.c:79
#4  0x00007ffff52d7da0 in std::__glibcxx_assert_fail (file=<optimized out>, line=<optimized out>, function=<optimized out>, condition=<optimized out>)
    at ../../../../../libstdc++-v3/src/c++11/debug.cc:60
#5  0x00007ffff663f217 in std::vector<giac::T_unsigned<int, unsigned long long>, std::allocator<giac::T_unsigned<int, unsigned long long> > >::front (
    this=0x7fff9c3bfad8) at /usr/include/c++/12/bits/stl_vector.h:1206
#6  0x00007ffff66d522d in giac::mod_gcd (p_orig=std::vector of length 18, capacity 32 = {...}, q_orig=std::vector of length 19, capacity 32 = {...}, 
    modulo=536871001, d=std::vector of length 8, capacity 8 = {...}, pcofactor=std::vector of length 0, capacity 1, qcofactor=std::vector of length 0, capacity 0, 
    vars=std::vector of length 2, capacity 3 = {...}, compute_pcofactor=true, compute_qcofactor=false, divtest=@0x7fffb97bd7c4: true, 
    pv=std::vector of length 4, capacity 4 = {...}, qv=std::vector of length 5, capacity 5 = {...}, dv=std::vector of length 3, capacity 3 = {...}, 
    dpv=std::vector of length 2, capacity 2 = {...}, dim2gcdv=std::vector of length 6, capacity 6 = {...}, 
    dim2pcofactorv=std::vector of length 6, capacity 6 = {...}, dim2qcofactorv=std::vector of length 6, capacity 6 = {...}, nthreads=1) at threaded.cc:2976
#7  0x00007ffff66d0c11 in giac::do_recursive_gcd_call (ptr_=0x7fffb97bdd28) at threaded.cc:2418
#8  0x00007ffff66d5f97 in giac::mod_gcd (p_orig=std::vector of length 18, capacity 18 = {...}, q_orig=std::vector of length 19, capacity 19 = {...}, 
    modulo=536871001, d=std::vector of length 0, capacity 0, pcofactor=std::vector of length 1, capacity 1 = {...}, 
    qcofactor=std::vector of length 1, capacity 1 = {...}, vars=std::vector of length 3, capacity 3 = {...}, compute_pcofactor=true, compute_qcofactor=true, 
    divtest=@0x7fffb97ebe12: true, pv=std::vector of length 4, capacity 4 = {...}, qv=std::vector of length 5, capacity 5 = {...}, 
    dv=std::vector of length 3, capacity 3 = {...}, dpv=std::vector of length 2, capacity 2 = {...}, dim2gcdv=std::vector of length 6, capacity 6 = {...}, 
    dim2pcofactorv=std::vector of length 6, capacity 6 = {...}, dim2qcofactorv=std::vector of length 6, capacity 6 = {...}, nthreads=4) at threaded.cc:3066

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: -Wp,-D_GLIBCXX_ASSERTIONS

Message par parisse » ven. janv. 13, 2023 9:16 am

Was hard to debug... Here is the fix:
https://github.com/geogebra/giac/commit ... 99fc49d8a7

frederic han
Messages : 1137
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: -Wp,-D_GLIBCXX_ASSERTIONS

Message par frederic han » sam. janv. 14, 2023 11:18 am

Thank you,
there is a last one in the test suite when running TP17-sol.cas

Code : Tout sélectionner

usr/include/c++/12/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

Thread 15 "icas" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffb97fa640 (LWP 83814)]
0x00007ffff4e8ec0c in __pthread_kill_implementation () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-11.fc36.x86_64 cddlib-0.94m-3.fc36.x86_64 cliquer-libs-1.22-3.fc36.x86_64 cocoalib-0.99800-1.fc36.x86_64 cyrus-sasl-lib-2.1.27-18.fc36.x86_64 elfutils-libelf-0.188-3.fc36.x86_64 expat-2.5.0-1.fc36.x86_64 flexiblas-netlib-3.2.1-1.fc36.x86_64 flexiblas-openblas-openmp-3.2.1-1.fc36.x86_64 fltk-1.3.8-2.fc36.x86_64 fontconfig-2.14.1-2.fc36.x86_64 freetype-2.12.1-2.fc36.x86_64 gf2x-1.3.0-6.fc36.x86_64 glib2-2.72.3-1.fc36.x86_64 glibc-2.35-21.fc36.x86_64 glpk-5.0-4.fc36.x86_64 gmp-6.2.1-2.fc36.x86_64 gmp-c++-6.2.1-2.fc36.x86_64 gmp-ecm-libs-7.0.4-17.fc36.x86_64 graphite2-1.3.14-9.fc36.x86_64 gsl-2.6-6.fc36.x86_64 harfbuzz-4.0.0-2.fc36.x86_64 keyutils-libs-1.6.1-4.fc36.x86_64 krb5-libs-1.19.2-12.fc36.x86_64 libX11-1.7.3.1-2.fc36.x86_64 libX11-xcb-1.7.3.1-2.fc36.x86_64 libXau-1.0.9-8.fc36.x86_64 libXcursor-1.2.0-7.fc36.x86_64 libXext-1.3.4-8.fc36.x86_64 libXfixes-6.0.0-3.fc36.x86_64 libXft-2.3.4-2.fc36.x86_64 libXrandr-1.5.2-8.fc36.x86_64 libXrender-0.9.10-16.fc36.x86_64 libao-1.2.0-22.fc36.x86_64 libbrotli-1.0.9-7.fc36.x86_64 libcom_err-1.46.5-2.fc36.x86_64 libcurl-7.82.0-12.fc36.x86_64 libffi-3.4.2-8.fc36.x86_64 libfrobby-0.9.0-25.fc36.x86_64 libgcc-12.2.1-4.fc36.x86_64 libgfan-0.6.2-13.fc36.x86_64 libgfortran-12.2.1-4.fc36.x86_64 libglvnd-glx-1.4.0-4.fc36.x86_64 libgomp-12.2.1-4.fc36.x86_64 libidn2-2.3.4-1.fc36.x86_64 libjpeg-turbo-2.1.2-2.fc36.x86_64 libnauty-2.7.4-1.fc36.x86_64 libnghttp2-1.51.0-1.fc36.x86_64 libpng-1.6.37-12.fc36.x86_64 libpsl-0.21.1-5.fc36.x86_64 libquadmath-12.2.1-4.fc36.x86_64 libselinux-3.3-4.fc36.x86_64 libssh-0.9.6-4.fc36.x86_64 libstdc++-12.2.1-4.fc36.x86_64 libunistring-1.0-1.fc36.x86_64 libxcb-1.13.1-9.fc36.x86_64 libxcrypt-4.4.33-4.fc36.x86_64 libxshmfence-1.3-10.fc36.x86_64 mesa-dri-drivers-22.1.7-1.fc36.x86_64 mesa-libglapi-22.1.7-1.fc36.x86_64 mpfi-1.5.4-1.fc36.x86_64 mpfr-4.1.0-9.fc36.x86_64 ncurses-libs-6.2-9.20210508.fc36.x86_64 ntl-11.5.1-3.fc36.x86_64 openblas-openmp-0.3.19-3.fc36.x86_64 openldap-2.6.3-1.fc36.x86_64 openssl-libs-3.0.5-2.fc36.x86_64 pcre-8.45-1.fc36.1.x86_64 readline-8.2-2.fc36.x86_64 suitesparse-5.10.1-2.fc36.x86_64 vulkan-loader-1.3.204.0-1.fc36.x86_64 xz-libs-5.2.5-9.fc36.x86_64 zlib-1.2.11-33.fc36.x86_64
(gdb) bt
#0  0x00007ffff4e8ec0c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007ffff4e3e986 in raise () from /lib64/libc.so.6
#2  0x00007ffff4e287f4 in abort () from /lib64/libc.so.6
#3  0x00007ffff52d7da0 in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) ()
   from /lib64/libstdc++.so.6
#4  0x00007ffff69ba56f in std::vector<long long, std::allocator<long long> >::operator[] (this=0x7fffb97e7270, __n=9)
    at /usr/include/c++/12/bits/stl_vector.h:1123
#5  0x00007ffff6bcd493 in giac::smallmodrref_upper (N=std::vector of length 2, capacity 2 = {...}, l=0, lmax=2, c=0, 
    cmax=9, modulo=535316269) at vecteur.cc:8282
#6  0x00007ffff6ff8c69 in giac::zf4mod<giac::tdeg_t11> (res=..., G=std::vector of length 4, capacity 4 = {...}, 
    env=535316269, B=std::vector of length 2, capacity 2 = {...}, permuBptr=@0x7fffb97e7b80: 0x7fff9c0b9eb0, 
    f4buchbergerv=..., learning=true, learned_position=@0x7fffb97e78d0: 0, pairs_reducing_to_zero=0x7fffb97e83b0, 
    f4buchberger_info=std::vector of length 1, capacity 1024 = {...}, f4buchberger_info_position=@0x7fffb97e78d4: 0, 
    recomputeR=false, age=1, multimodular=true, parallel=1, interreduce=0) at cocoa.cc:12378
#7  0x00007ffff6f928f8 in giac::in_zgbasis<giac::tdeg_t11> (resmod=..., ressize=4, 
    G=std::vector of length 4, capacity 4 = {...}, env=535316269, totdeg=true, 
    pairs_reducing_to_zero=0x7fffb97e83b0, f4buchberger_info=std::vector of length 1, capacity 1024 = {...}, 
    recomputeR=false, eliminate_flag=false, multimodular=true, parallel=1, interred=true) at cocoa.cc:13169
#8  0x00007ffff6f3701b in giac::zgbasisrur<giac::tdeg_t11> (res8=..., resmod=..., 
    G=std::vector of length 4, capacity 4 = {...}, env=535316269, totdeg=true, 
    pairs_reducing_to_zero=0x7fffb97e83b0, f4buchberger_info=std::vector of length 1, capacity 1024 = {...}, 
    recomputeR=false, convertpoly8=false, eliminate_flag=false, multimodular=true, parallel=1, interred=true, 
    rurinzgbasis=@0x7fffb97e8038: 0, rurv=..., rurs=..., rurlm=..., rurlmmodradical=..., rurgblmptr=0x7fffb97e87b0, 
    rurlmptr=0x7fffb97e8730) at cocoa.cc:13375
#9  0x00007ffff6f309b4 in giac::in_mod_gbasis<giac::tdeg_t11> (res=..., modularcheck=false, zdata=true, 
    rur=@0x7fffb97edff8: 1, contextptr=0x7fffffffd6f0, gbasis_par=..., gbasis_logz_age=0) at cocoa.cc:15273



(gdb) f 5
#5  0x00007ffff6bcd493 in giac::smallmodrref_upper (N=std::vector of length 2, capacity 2 = {...}, l=0, lmax=2, c=0, 
    cmax=9, modulo=535316269) at vecteur.cc:8282
8282		    longlong * ptr= &buffer[C],*ptrend=&buffer[cmax]-4;
(gdb) p cmax
$1 = 9
(gdb) p buffer
$2 = std::vector of length 9, capacity 9 = {1, -21168063, 0, 206820931, 71328779, -2017049, 218771579, 16114079, 
  57360739}
may be: &buffer[cmax-4] ?


NB: In TP11 the pari_isprime(p,1) output has changed from pari, it is now just answering 1 instead of a certificate.
so the output shoud be updated:

Code : Tout sélectionner

[fred@fedora check]$ diff TP11-sol.cas.out1~ TP11-sol.cas.out1
13c13
< matrix[[2,7,1],[3,2,1],[389,2,1],[733,2,1],[156904374622257604823879982847602392900751802349981470895277241,2,matrix[[2,13,1],[3,3,1],[5,2,1],[7,2,1],[56467,2,1],[6553084925887974620811527,2,matrix[[2,5,1],[19,2,1],[71,2,1],[126823,2,1]]]]]],
---
> 1,

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: -Wp,-D_GLIBCXX_ASSERTIONS

Message par parisse » dim. janv. 15, 2023 10:37 am

frederic han a écrit :
sam. janv. 14, 2023 11:18 am
Thank you,
there is a last one in the test suite when running TP17-sol.cas
This seems a false positive.
may be: &buffer[cmax-4] ?
Might fail if cmax<4. I think it's better not to change code because of a false positive test.
NB: In TP11 the pari_isprime(p,1) output has changed from pari, it is now just answering 1 instead of a certificate.
so the output shoud be updated:

Code : Tout sélectionner

[fred@fedora check]$ diff TP11-sol.cas.out1~ TP11-sol.cas.out1
13c13
< matrix[[2,7,1],[3,2,1],[389,2,1],[733,2,1],[156904374622257604823879982847602392900751802349981470895277241,2,matrix[[2,13,1],[3,3,1],[5,2,1],[7,2,1],[56467,2,1],[6553084925887974620811527,2,matrix[[2,5,1],[19,2,1],[71,2,1],[126823,2,1]]]]]],
---
> 1,
It would perhaps be better to modify the test itself, because I have still old versions of PARI where it works.

Répondre