Пример #1
0
/**
 * Report there's no matching nonblocking call for request var used by wait.
 *
 * @param callExpr
 * @param requestVar
 * @param node
 */
void MPIBugReporter::reportUnmatchedWait(
    const CallEvent &callEvent, const clang::ento::MemRegion *requestRegion,
    const ExplodedNode *const node) const {
    std::string errorText{"Request '" + util::variableName(requestRegion) +
                          "' has no matching nonblocking call. "};

    auto bugReport =
        llvm::make_unique<BugReport>(*unmatchedWaitBugType_, errorText, node);
    bugReport->addRange(callEvent.getSourceRange());
    SourceRange r = util::sourceRange(requestRegion);
    if (r.isValid()) bugReport->addRange(r);
    bugReporter_.emitReport(std::move(bugReport));
}
void DoubleFetchChecker::reportDoubleFetch(CheckerContext &Ctx, const CallEvent &Call) const {
	// We reached a bug, stop exploring the path here by generating a sink.
	ExplodedNode *ErrNode = Ctx.generateErrorNode(Ctx.getState());
	// If we've already reached this node on another path, return.
	if (!ErrNode)
		return;

	// Generate the report.
	auto R = llvm::make_unique<BugReport>(*DoubleFetchType,
			"Double-Fetch", ErrNode);
	R->addRange(Call.getSourceRange());
	Ctx.emitReport(std::move(R));
}
void BlockInCriticalSectionChecker::reportBlockInCritSection(
    SymbolRef BlockDescSym, const CallEvent &Call, CheckerContext &C) const {
  ExplodedNode *ErrNode = C.generateNonFatalErrorNode();
  if (!ErrNode)
    return;

  std::string msg;
  llvm::raw_string_ostream os(msg);
  os << "Call to blocking function '" << Call.getCalleeIdentifier()->getName()
     << "' inside of critical section";
  auto R = llvm::make_unique<BugReport>(*BlockInCritSectionBugType, os.str(), ErrNode);
  R->addRange(Call.getSourceRange());
  R->markInteresting(BlockDescSym);
  C.emitReport(std::move(R));
}
Пример #4
0
void SimpleStreamChecker::reportDoubleClose(SymbolRef FileDescSym,
                                            const CallEvent &Call,
                                            CheckerContext &C) const {
  // We reached a bug, stop exploring the path here by generating a sink.
  ExplodedNode *ErrNode = C.generateErrorNode();
  // If we've already reached this node on another path, return.
  if (!ErrNode)
    return;

  // Generate the report.
  auto R = llvm::make_unique<BugReport>(*DoubleCloseBugType,
      "Closing a previously closed file stream", ErrNode);
  R->addRange(Call.getSourceRange());
  R->markInteresting(FileDescSym);
  C.emitReport(std::move(R));
}
Пример #5
0
/**
 * Report duplicate request use by waits.
 *
 * @param observedCall
 * @param requestVar
 * @param node
 */
void MPIBugReporter::reportDoubleWait(const CallEvent &observedCall,
                                      const RequestVar &requestVar,
                                      const ExplodedNode *const node) const {
    std::string lineNo{lineNumber(requestVar.lastUser_)};
    std::string lastUser =
        requestVar.lastUser_->getCalleeIdentifier()->getName();
    std::string errorText{"Request '" + requestVar.variableName() +
                          "' is already waited upon by '" + lastUser +
                          "' in line " + lineNo + ". "};

    auto bugReport =
        llvm::make_unique<BugReport>(*doubleWaitBugType_, errorText, node);
    bugReport->addRange(observedCall.getSourceRange());
    bugReport->addRange(requestVar.lastUser_->getSourceRange());
    SourceRange r = util::sourceRange(requestVar.memRegion_);
    if (r.isValid()) bugReport->addRange(r);
    bugReporter_.emitReport(std::move(bugReport));
}