<div>#define CHKERRXX(n)            do {if (PetscUnlikely(n)) {PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,__SDIR__,n,PETSC_ERROR_IN_CXX,0);}} while(0)</div><div><br></div><div>Inside PetscError():</div>
<div><br></div><div>  if (p == PETSC_ERROR_IN_CXX) {</div><div>    const char *str;</div><div>    if (eh->ctx) {</div><div>      std::ostringstream *msg; </div><div>      msg = (std::ostringstream*) eh->ctx;</div><div>
      str = msg->str().c_str();</div><div>    } else {</div><div>      str = "Error detected in C PETSc";</div><div>    }</div><div>    throw PETSc::Exception(str);</div><div>  }</div><div><br></div><div>This causes SEGV because eh is NULL when propagating an error from C (the caller checks a return code using CHKERRXX). This seems like a logic error, but I don't know what was intended.</div>
<div><br></div><div>I changed this to if (eh && eh->ctx) which fixes the SEGV, but I don't know if something else was intended. I only pushed this to petsc-dev, but once we decide on the "right" fix, it should be ported to petsc-3.2.</div>