Bug 92600 - [11/12/13/14 Regression] ICE: symtab_node::verify failed, building 523.xalancbmk_r with -flto -fno-inline since r267359
Summary: [11/12/13/14 Regression] ICE: symtab_node::verify failed, building 523.xalanc...
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 10.0
: P2 normal
Target Milestone: 11.5
Assignee: Jan Hubicka
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2019-11-20 17:13 UTC by pthaugen
Modified: 2024-01-02 20:18 UTC (History)
3 users (show)

See Also:
Host: powerpc64le-unknown-linux-gnu, x86_64-linux-gnu
Target: powerpc64le-unknown-linux-gnu, x86_64-linux-gnu
Build: powerpc64le-unknown-linux-gnu, x86_64-linux-gnu
Known to work: 8.3.0
Known to fail: 10.0, 9.2.0
Last reconfirmed: 2019-11-21 00:00:00


Attachments
Clean up test-case (1.28 KB, application/x-bzip)
2020-01-09 16:16 UTC, Martin Liška
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pthaugen 2019-11-20 17:13:43 UTC
I'm seeing the following ICE when building CPU2017 523.xalancbmk_r with the options "-O2 -mcpu=power8 -flto -fno-inline". The errors are emitted during the link step.


AttributeListImpl.cpp:246:8: warning: type 'struct NameCompareFunctor' violates the C++ One Definition Rule [-Wodr]
  246 | struct NameCompareFunctor
      |        ^
AttributesImpl.cpp:266:8: note: a different type is defined in another translation unit
  266 | struct NameCompareFunctor
      |        ^
AttributeListImpl.cpp:261:21: note: the first difference of corresponding definitions is field 'm_name'
  261 |  const XMLCh* const m_name;
      |                     ^
AttributesImpl.cpp:281:21: note: a field with different name is defined in another translation unit
  281 |  const XMLCh* const m_qname;
      |                     ^
AttributeListImpl.cpp:246:8: note: type 'struct NameCompareFunctor' itself violates the C++ One Definition Rule
  246 | struct NameCompareFunctor
      |        ^
AttributesImpl.cpp:266:8: note: the incompatible type is defined here
  266 | struct NameCompareFunctor
      |        ^
lto1: error: Two symbols with same comdat_group are not linked by the same_comdat_group list.
_ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv/871705 (resetEntities) @0x71d34b022ec0
  Type: function definition analyzed
  Visibility: externally_visible undef public weak comdat comdat_group:_ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv one_only section:.text._ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv (implicit_section) virtual
  Address is taken.
  References: 
  Referring: *.LTHUNK8/459137 (alias)_ZTVN11xercesc_2_715XercesDOMParserE/1291254 (addr)_ZTVN11xercesc_2_712XSDDOMParserE/872502 (addr)
  Read from file: XSDDOMParser.o
  Function flags: count:1073741824 (estimated locally) merged_comdat
  Called by: 
  Calls: 
_ZThn16_N11xercesc_2_715XercesDOMParser13resetEntitiesEv/459138 (_ZThn16_N11xercesc_2_715XercesDOMParser13resetEntitiesEv) @0x71d349e9ef40
  Type: function definition analyzed
  Visibility: externally_visible prevailing_def_ironly public weak comdat comdat_group:_ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv one_only section:.text._ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv (implicit_section) virtual artificial
  Same comdat group as: *.LTHUNK8/459137
  Address is taken.
  References: 
  Referring: _ZTVN11xercesc_2_712XSDDOMParserE/872502 (addr)_ZTVN11xercesc_2_715XercesDOMParserE/1291254 (addr)
  Read from file: IGXMLScanner2.o
  Function flags: calls_comdat_local merged_comdat indirect_call_target
  Thunk fixed offset -16 virtual value 0 indirect_offset 0 has virtual offset 0
  Called by: 
  Calls: *.LTHUNK8/459137 (can throw external) 
during IPA pass: pure-const
lto1: internal compiler error: symtab_node::verify failed
0x102ab7df symtab_node::verify_symtab_nodes()
	/home/pthaugen/src/gcc/trunk/gcc/gcc/symtab.c:1310
0x10654a23 symtab_node::checking_verify_symtab_nodes()
	/home/pthaugen/src/gcc/trunk/gcc/gcc/cgraph.h:648
0x10654a23 symbol_table::remove_unreachable_nodes(_IO_FILE*)
	/home/pthaugen/src/gcc/trunk/gcc/gcc/ipa.c:667
0x101f26f7 read_cgraph_and_symbols(unsigned int, char const**)
	/home/pthaugen/src/gcc/trunk/gcc/gcc/lto/lto-common.c:2910
0x101c3bcb lto_main()
	/home/pthaugen/src/gcc/trunk/gcc/gcc/lto/lto.c:629
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
lto-wrapper: fatal error: /home/pthaugen/install/gcc/trunk/bin/g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status


I thought this might be a possible dup of PR91241 or PR89605 but was unable to reproduce with the GCC 8 or 9 compilers. The build succeeds with trunk if I change the optimization level to -O1 or remove -fno-inline.
Comment 1 Martin Liška 2019-11-21 09:11:59 UTC
Confirmed on x86_64-linux-gnu, I'm reducing that.
Comment 2 Martin Liška 2019-11-21 09:29:09 UTC
Apparently, it's a very old issue, started with GCC 5.1.0:

$ cat 1.ii
namespace xercesc_2_7 {
class XercesDOMParser {
  void resetEntities();
};
void XercesDOMParser::resetEntities() {}
} // namespace xercesc_2_7

$ cat 2.ii
namespace xercesc_2_7 {
class XMLErrorReporter {
public:
  virtual ~XMLErrorReporter();
};
class XMLEntityHandler {
  virtual void resetEntities();
};
class AbstractDOMParser : XMLErrorReporter, XMLEntityHandler {};
class XercesDOMParser : AbstractDOMParser {
  void resetEntities();
};
inline void XercesDOMParser::resetEntities() {}
} // namespace xercesc_2_7

$ g++ -flto=16 -O2 -fno-inline 1.ii 2.ii
2.ii:10:7: warning: type 'struct XercesDOMParser' violates the C++ One Definition Rule [-Wodr]
   10 | class XercesDOMParser : AbstractDOMParser {
      |       ^
1.ii:2:7: note: a type with different bases is defined in another translation unit
    2 | class XercesDOMParser {
      |       ^
2.ii:13:13: warning: type of 'resetEntities' does not match original declaration [-Wlto-type-mismatch]
   13 | inline void XercesDOMParser::resetEntities() {}
      |             ^
1.ii:5:6: note: 'resetEntities' was previously declared here
    5 | void XercesDOMParser::resetEntities() {}
      |      ^
lto1: error: Alias and target's section differs
_ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv/0 (resetEntities) @0x7f80058ea580
  Type: function definition analyzed
  Visibility: externally_visible prevailing_def_ironly public
  Address is taken.
  References: 
  Referring: *.LTHUNK0/2 (alias)_ZTVN11xercesc_2_715XercesDOMParserE/4 (addr)
  Read from file: /tmp/cc2Oyr2J.o
  Function flags: count:1073741824 (estimated locally)
  Called by: 
  Calls: 
lto1: error: Alias and target's comdat groups differs
_ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv/0 (resetEntities) @0x7f80058ea580
  Type: function definition analyzed
  Visibility: externally_visible prevailing_def_ironly public
  Address is taken.
  References: 
  Referring: *.LTHUNK0/2 (alias)_ZTVN11xercesc_2_715XercesDOMParserE/4 (addr)
  Read from file: /tmp/cc2Oyr2J.o
  Function flags: count:1073741824 (estimated locally)
  Called by: 
  Calls: 
*.LTHUNK0/2 (*.LTHUNK0) @0x7f80058ea840
  Type: function definition analyzed alias
  Visibility: comdat_group:_ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv section:.text._ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv (implicit_section) artificial
  Same comdat group as: _ZThn8_N11xercesc_2_715XercesDOMParser13resetEntitiesEv/3
  References: _ZN11xercesc_2_715XercesDOMParser13resetEntitiesEv/0 (alias)
  Referring: 
  Read from file: /tmp/ccixDNgJ.o
  Function flags:
  Called by: _ZThn8_N11xercesc_2_715XercesDOMParser13resetEntitiesEv/3 (can throw external) 
  Calls: 
during IPA pass: pure-const
lto1: internal compiler error: verify_cgraph_node failed
0x88e42e cgraph_node::verify_node()
	/home/marxin/Programming/gcc/gcc/cgraph.c:3411
0x880d8c symtab_node::verify()
	/home/marxin/Programming/gcc/gcc/symtab.c:1268
0x8824ff symtab_node::verify_symtab_nodes()
	/home/marxin/Programming/gcc/gcc/symtab.c:1288
0xaf0f5f symtab_node::checking_verify_symtab_nodes()
	/home/marxin/Programming/gcc/gcc/cgraph.h:648
0xaf0f5f symbol_table::remove_unreachable_nodes(_IO_FILE*)
	/home/marxin/Programming/gcc/gcc/ipa.c:667
0x80c54e read_cgraph_and_symbols(unsigned int, char const**)
	/home/marxin/Programming/gcc/gcc/lto/lto-common.c:2910
0x7f2da2 lto_main()
	/home/marxin/Programming/gcc/gcc/lto/lto.c:629
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Comment 3 Martin Liška 2019-11-27 14:28:42 UTC
It's related to PR92599. It's also an ODR violation that leads to the ICE.
Comment 4 Martin Liška 2020-01-09 14:23:21 UTC
(In reply to Martin Liška from comment #3)
> It's related to PR92599. It's also an ODR violation that leads to the ICE.

So it must be something different. There are source files which do not violate ODR:

$ cat 1.ii
unsigned short a;
namespace xercesc_2_7 {
class MemoryManager;
class XMemory {};
class XMLErrorReporter {
  virtual void resetErrors();
};
class XMLBuffer {};
class XMLBufferMgr {
  unsigned fBufCount;
  MemoryManager *fMemoryManager;
  XMLBuffer **fBufList;
};
template <class> class RefVectorOf;
class XMLStringPool;
class GrammarResolver;
class XMLValidator;
template <class> class ValueStackOf;
class XMLEntityHandler;
class ErrorHandler;
class XMLScanner {
public:
  XMLEntityHandler *fEntityHandler;
};
class SGXMLScanner : XMLScanner {
  int *resolveSystemId();
};
class XMLDocumentHandler {
  virtual void endEntityReference();
};
class XMLEntityHandler {
public:
  virtual bool expandSystemId(const unsigned short *, XMLBuffer &);
};
class PSVIHandler {
  virtual void handleElementPSVI();
};
class DOMNode;
class DOMEntity;
class DocTypeHandler {
  virtual void startIntSubset();
};
class DOMDocumentImpl;
class DOMDocumentTypeImpl;
class XMLGrammarPool;
class AbstractDOMParser : XMemory,
                          XMLDocumentHandler,
                          XMLErrorReporter,
                          XMLEntityHandler,
                          DocTypeHandler,
                          PSVIHandler {
  bool fCreateEntityReferenceNodes;
  bool fIncludeIgnorableWhitespace;
  bool fWithinElement;
  bool fParseInProgress;
  bool fCreateCommentNodes;
  bool fDocumentAdoptedByUser;
  bool fCreateSchemaInfo;
  XMLScanner *fScanner;
  unsigned short *fImplementationFeatures;
  DOMNode *fCurrentParent;
  DOMNode *fCurrentNode;
  DOMEntity *fCurrentEntity;
  DOMDocumentImpl *fDocument;
  ValueStackOf<DOMNode *> *fNodeStack;
  DOMDocumentTypeImpl *fDocumentType;
  RefVectorOf<DOMDocumentImpl> *fDocumentVector;
  GrammarResolver *fGrammarResolver;
  XMLStringPool *fURIStringPool;
  XMLValidator *fValidator;
  MemoryManager *fMemoryManager;
  XMLGrammarPool *fGrammarPool;
  XMLBufferMgr fBufMgr;
  XMLBuffer &fInternalSubset;
  PSVIHandler *fPSVIHandler;
};
class EntityResolver;
class XMLEntityResolver;
class XercesDOMParser : AbstractDOMParser {
  virtual void error();
  bool expandSystemId(const unsigned short *, XMLBuffer &);
  EntityResolver *fEntityResolver;
  XMLEntityResolver *fXMLEntityResolver;
  ErrorHandler *fErrorHandler;
};
inline bool XercesDOMParser::expandSystemId(const unsigned short *,
                                            XMLBuffer &) { return false; }
int *SGXMLScanner::resolveSystemId() {
  XMLBuffer b;
  fEntityHandler->expandSystemId(&a, b);
  return 0;
}
} // namespace xercesc_2_7

$ cat 2.ii
namespace xercesc_2_7 {
class DOMNode;
class DOMEntity;
class MemoryManager;
class XMemory {};
class XMLErrorReporter {
public:
  virtual ~XMLErrorReporter();
};
template <class> class RefVectorOf;
class XMLDocumentHandler {
  virtual void XMLDecl();
};
class XMLBuffer;
class XMLEntityHandler {
  virtual bool expandSystemId(const unsigned short *, XMLBuffer &);
};
template <class> class ValueStackOf;
class GrammarResolver;
class XMLStringPool;
class DocTypeHandler {
public:
  virtual ~DocTypeHandler();
};
class XMLBufferMgr {
  unsigned fBufCount;
  MemoryManager *fMemoryManager;
  XMLBuffer **fBufList;
};
class PSVIHandler {
  virtual void handlePartialElementPSVI();
};
class XMLScanner;
class XMLValidator;
class DOMDocumentImpl;
class DOMDocumentTypeImpl;
class XMLGrammarPool;
class AbstractDOMParser : XMemory,
                          XMLDocumentHandler,
                          XMLErrorReporter,
                          XMLEntityHandler,
                          DocTypeHandler,
                          PSVIHandler {
  bool fCreateEntityReferenceNodes;
  bool fIncludeIgnorableWhitespace;
  bool fWithinElement;
  bool fParseInProgress;
  bool fCreateCommentNodes;
  bool fDocumentAdoptedByUser;
  bool fCreateSchemaInfo;
  XMLScanner *fScanner;
  unsigned short *fImplementationFeatures;
  DOMNode *fCurrentParent;
  DOMNode *fCurrentNode;
  DOMEntity *fCurrentEntity;
  DOMDocumentImpl *fDocument;
  ValueStackOf<DOMNode *> *fNodeStack;
  DOMDocumentTypeImpl *fDocumentType;
  RefVectorOf<DOMDocumentImpl> *fDocumentVector;
  GrammarResolver *fGrammarResolver;
  XMLStringPool *fURIStringPool;
  XMLValidator *fValidator;
  MemoryManager *fMemoryManager;
  XMLGrammarPool *fGrammarPool;
  XMLBufferMgr fBufMgr;
  XMLBuffer &fInternalSubset;
  PSVIHandler *fPSVIHandler;
};
class EntityResolver;
class ErrorHandler;
class XMLEntityResolver;
class XercesDOMParser : AbstractDOMParser {
  bool expandSystemId(const unsigned short *, XMLBuffer &);
  EntityResolver *fEntityResolver;
  XMLEntityResolver *fXMLEntityResolver;
  ErrorHandler *fErrorHandler;
};
inline bool XercesDOMParser::expandSystemId(const unsigned short *,
                                            XMLBuffer &) { return false; }
} // namespace xercesc_2_7

$ g++-9 -O2 -flto -fno-inline -shared -fPIC 1.ii 2.ii -fchecking
lto1: error: Two symbols with same comdat_group are not linked by the same_comdat_group list.
_ZN11xercesc_2_715XercesDOMParser14expandSystemIdEPKtRNS_9XMLBufferE/7 (expandSystemId) @0x7f9cfcb50b40
  Type: function definition analyzed
  Visibility: externally_visible undef public weak comdat comdat_group:_ZN11xercesc_2_715XercesDOMParser14expandSystemIdEPKtRNS_9XMLBufferE one_only section:.text._ZN11xercesc_2_715XercesDOMParser14expandSystemIdEPKtRNS_9XMLBufferE (implicit_section) virtual
  Address is taken.
  References: 
  Referring: *.LTHUNK0/2 (alias)_ZTVN11xercesc_2_715XercesDOMParserE/10 (addr)
  Read from file: /tmp/cchvQQd7.o
  Function flags: count:1073741824 (estimated locally)
  Called by: 
  Calls: 
_ZThn16_N11xercesc_2_715XercesDOMParser14expandSystemIdEPKtRNS_9XMLBufferE/3 (_ZThn16_N11xercesc_2_715XercesDOMParser14expandSystemIdEPKtRNS_9XMLBufferE) @0x7f9cfcb50870
  Type: function definition analyzed
  Visibility: externally_visible prevailing_def_ironly_exp public weak comdat comdat_group:_ZN11xercesc_2_715XercesDOMParser14expandSystemIdEPKtRNS_9XMLBufferE one_only section:.text._ZN11xercesc_2_715XercesDOMParser14expandSystemIdEPKtRNS_9XMLBufferE (implicit_section) virtual artificial
  Same comdat group as: *.LTHUNK0/2
  Address is taken.
  References: 
  Referring: _ZTVN11xercesc_2_715XercesDOMParserE/10 (addr)
  Read from file: /tmp/cceOf484.o
  Function flags: calls_comdat_local merged_comdat
  Thunk fixed offset -16 virtual value 0 indirect_offset 0 has virtual offset 0
  Called by: 
  Calls: *.LTHUNK0/2 
(null):0: confused by earlier errors, bailing out
lto-wrapper: fatal error: g++-9 returned 1 exit status
compilation terminated.
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Started with r267359.
Comment 5 Martin Liška 2020-01-09 16:16:54 UTC
Created attachment 47621 [details]
Clean up test-case

So the now the diff of the source file is minimal:

$ diff -u 1.ii 2.ii
--- 1.ii	2020-01-09 17:14:33.000405474 +0100
+++ 2.ii	2020-01-09 17:14:33.000405474 +0100
@@ -79,7 +79,6 @@
 class ErrorHandler;
 class XMLEntityResolver;
 class XercesDOMParser : AbstractDOMParser {
-  virtual void error_that_causes_ice();
   bool expandSystemId(const unsigned short *, XMLBuffer &);
   EntityResolver *fEntityResolver;
   XMLEntityResolver *fXMLEntityResolver;
@@ -87,10 +86,4 @@
 };
 inline bool XercesDOMParser::expandSystemId(const unsigned short *,
                                             XMLBuffer &) { return false; }
-int *SGXMLScanner::resolveSystemId() {
-  unsigned short a;
-  XMLBuffer b;
-  fEntityHandler->expandSystemId(&a, b);
-  return 0;
-}
 } // namespace xercesc_2_7

Honza, does it explain now better?
Comment 6 Jan Hubicka 2020-01-14 15:07:28 UTC
Well, because the source files differs, the comdat group differs and the loosing one has fewer symbols in it.  So we end up keeping some symbols from the other comdat group that happens to have same name.  The compilation is bound to fail, so I guess question is how best to silence the ICE.  I suppose we may get around by dissoling comdat groups of all UNDEF symbols
Comment 7 Martin Liška 2020-01-15 09:05:05 UTC
(In reply to Jan Hubicka from comment #6)
> Well, because the source files differs, the comdat group differs and the
> loosing one has fewer symbols in it.  So we end up keeping some symbols from
> the other comdat group that happens to have same name.  The compilation is
> bound to fail, so I guess question is how best to silence the ICE.  I
> suppose we may get around by dissoling comdat groups of all UNDEF symbols

Btw. is this a violation of ODR? Maybe, we could provide a warning for such a situation?
Comment 8 Jakub Jelinek 2020-03-12 11:59:00 UTC
GCC 9.3.0 has been released, adjusting target milestone.
Comment 9 Richard Biener 2021-06-01 08:15:32 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 10 Andrew Pinski 2021-12-20 03:59:11 UTC
The undefined testcase is almost definitely a dup of bug 87501. I have not looked into it otherwise.
Comment 11 Richard Biener 2022-05-27 09:41:32 UTC
GCC 9 branch is being closed
Comment 12 Jakub Jelinek 2022-06-28 10:38:55 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 13 Richard Biener 2023-07-07 10:36:12 UTC
GCC 10 branch is being closed.