Segmentation fault when deleting a non-null pointer

  antlr4, c++, segmentation-fault

I am using antlr4 for cpp and everything works fine until I get Segmentation fault when existing the program. It happens in the destructor of antlr class DFA in runtime src.

DFA::~DFA() {
  bool s0InList = (s0 == nullptr);
  for (auto *state : states) {
    if (state == s0)
      s0InList = true;
    delete state;

  if (!s0InList)
    delete s0;

When I visit some nodes, exception is raised when delete state;. However, stateis not null and its value has nothing different with others. What cause it might be?

Source: Windows Questions C++