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

--- Comment #10 from David Abdurachmanov <david.abdurachmanov at gmail dot com> 
---
We have been bitten by DSE with TBB already on GCC 6.2.0.

I decided to try -fno-lifetime-dse on the first bad commit and got some
surprising results. Now it fails with:

pure virtual method called
terminate called without an active exception

In this case we have a standard library container with 7 elements,
std::shared_ptr<TrackingRecHit>, where TrackingRecHit is abstract class, which
has:

  virtual int dimension() const = 0;

If I dump the actual type: typeid(*(x.get())).name() the actual object is of
MuonTransientTrackingRecHit type.

Then the code does std::stable_sort on the collection and now in some cases
MuonTransientTrackingRecHit changes to TrackingRecHit (abstract class). Thus we
are really calling pure virtual method.

This does not happen on x86_64.

I guess, this could be caused by actual MuonTransientTrackingRecHit being
destroyed if the last std::shared_ptr point to it goes away.

DUMP_BEFORE: std::shared_ptr<TrackingRecHit const>
DUMP_BEFORE_TYPE: MuonTransientTrackingRecHit
DUMP_BEFORE: std::shared_ptr<TrackingRecHit const>
DUMP_BEFORE_TYPE: MuonTransientTrackingRecHit
DUMP_BEFORE: std::shared_ptr<TrackingRecHit const>
DUMP_BEFORE_TYPE: MuonTransientTrackingRecHit
DUMP_BEFORE: std::shared_ptr<TrackingRecHit const>
DUMP_BEFORE_TYPE: MuonTransientTrackingRecHit
DUMP_BEFORE: std::shared_ptr<TrackingRecHit const>
DUMP_BEFORE_TYPE: MuonTransientTrackingRecHit
DUMP_BEFORE: std::shared_ptr<TrackingRecHit const>
DUMP_BEFORE_TYPE: MuonTransientTrackingRecHit
DUMP_BEFORE: std::shared_ptr<TrackingRecHit const>
DUMP_BEFORE_TYPE: MuonTransientTrackingRecHit

// after std::stable_sort

DUMP: std::shared_ptr<TrackingRecHit const>
DUMP_TYPE: MuonTransientTrackingRecHit
DUMP: std::shared_ptr<TrackingRecHit const>
DUMP_TYPE: MuonTransientTrackingRecHit
DUMP: std::shared_ptr<TrackingRecHit const>
DUMP_TYPE: TrackingRecHit
DUMP: std::shared_ptr<TrackingRecHit const>
DUMP_TYPE: TrackingRecHit
DUMP: std::shared_ptr<TrackingRecHit const>
DUMP_TYPE: MuonTransientTrackingRecHit
DUMP: std::shared_ptr<TrackingRecHit const>
DUMP_TYPE: TrackingRecHit
DUMP: std::shared_ptr<TrackingRecHit const>
DUMP_TYPE: TrackingRecHit

SIZE: 7

Reply via email to