https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83263

            Bug ID: 83263
           Summary: [8.0 regression] segmentation fault in alloc_traits
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juergen.reuter at desy dot de
  Target Milestone: ---

Created attachment 42782
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42782&action=edit
reproducer

The following code is a simple XDR reader which produces the following
segmentation violations when run on a simple XDR file (attached). The latest
version which did not show the problems was r253161, the first where I observed
the issue r254916. 
The reproducer tarball contains the header files, the C++ files, the Makefile
and the XDR example file stdhep_4_p.hep to be read in by the produced
executable.
This is the compilation chain:
g++  -c WOXDR.cpp
g++  -c WOStdHep.cpp
g++  -c WOStdHepRdr.cpp
g++   WOXDR.o WOStdHep.o WOStdHepRdr.o -ldl -lstdc++ -o stdhep_rd StdHepRdr.cpp

This is the backtrace: 

Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x6530302e30202c30) at malloc.c:2931
2931    malloc.c: No such file or directory.
(gdb) bt
#0  __GI___libc_free (mem=0x6530302e30202c30) at malloc.c:2931
#1  0x00007ffff7963c06 in deallocate (this=0x7fffffffda60, __p=<optimized out>)
    at
/home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:125
#2  deallocate (__a=..., __n=<optimized out>, __p=<optimized out>) at
/home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/alloc_traits.h:462
#3  _M_destroy (__size=<optimized out>, this=0x7fffffffda60) at
/home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:226
#4  _M_dispose (this=0x7fffffffda60) at
/home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:221
#5  ~basic_string (this=0x7fffffffda60, __in_chrg=<optimized out>) at
/home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:647
#6  ~basic_stringbuf (this=0x7fffffffda18, __in_chrg=<optimized out>) at
/home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/sstream:65
#7  std::__cxx11::basic_stringstream<char, std::char_traits<char>,
std::allocator<char> >::~basic_stringstream (this=0x7fffffffda00,
__in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at
/home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/sstream:732
#8  0x0000000000407cb7 in WOUTIL::WOStdHepRdr::readEvent(std::ostream&, int) ()
#9  0x0000000000408854 in main ()



Originally I believed this to be a problem in the bind(C) implementation but
apparently it seemed to appear also for standalone C++ code. Here is the
Fortran bind(C) example:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83230

The expected output of the XDR reader is the following:
==================================================== 
 WHIZARD StdHep Reader : 
 opened file : stdhep_4_p.hep
====== File Header ===========
    total blocks: 847
         version: 2.01
           title: WHIZARD 2.6.2
         comment: No comment
            date: Sun Dec  3 13:52:19 2017
    closing date: Sun Dec  3 13:52:19 2017
 expected events: 3
          events: 5
      firstTable: -1
        dimTable: 100
        nNTuples: 0
         nBlocks: 8
     block names:
                :  Standard HEP COMMON block, see STDHEP Product
                :  Standard HEP COMMON block with multiple interaction, see
STDHEP Product
                :  Stdhep begin run record, see STDHEP Product
                :  Stdhep end run record, see STDHEP Product
                :  Standard HEP COMMON block with Les Houches, see STDHEP
Product
                :  Standard HEP COMMON block with Les Houches and multiple
interaction
                :  Les Houches HEPEUP common block
                :  Les Houches HEPRUP common block
=============================
 Event #0
[   id   ]index|      PDG |q(el)|    px,      py,        pz    | energy  |  
mass  |sta| vertex x,     y   ,   z     |              spin           |
colorflow | [daughters]
[00000000]    0|        11|-1.00| 0.00e+00, 0.00e+00,  2.50e+02| 2.50e+02|
5.11e-04| 2 | 0.00e+00, 0.00e+00, 0.00e+00| 0.00e+00, 0.00e+00, 0.00e+00|  (0,
0)   | [ 2, 3 ]
[00000001]    1|       -11| 1.00| 0.00e+00, 0.00e+00, -2.50e+02| 2.50e+02|
5.11e-04| 2 | 0.00e+00, 0.00e+00, 0.00e+00| 0.00e+00, 0.00e+00, 0.00e+00|  (0,
0)   | [ 2, 3 ]
[00000002]    2|        15|-1.00| 1.42e+02, 1.99e+02, -5.22e+01| 2.50e+02|
1.78e+00| 1 | 0.00e+00, 0.00e+00, 0.00e+00| 0.00e+00, 0.00e+00, 0.00e+00|  (0,
0)   | [ 0, 0 ]
[00000003]    3|       -15| 1.00|-1.42e+02,-1.99e+02,  5.22e+01| 2.50e+02|
1.78e+00| 1 | 0.00e+00, 0.00e+00, 0.00e+00| 0.00e+00, 0.00e+00, 0.00e+00|  (0,
0)   | [ 0, 0 ]
  converted 1 events - written to stdout
====================================================

Reply via email to