llvm / llvm/circt

[handshake-runner] possible race condition when gathering the simulation time

Open
#1,555 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Handshake
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

I'm building on OSX and using Clang version 12, using a unified build and LLVM_USE_SANITIZER:STRING=Address;Undefined. I did a fresh build from scratch today and started seeing this issue.

Many of the handshake-runner tests are spuriously failing due to an error detected by UBSan:

andrewy@ayoung-0504~/w/c/build> /Users/andrewy/wsp/circt/build/bin/circt-opt -create-dataflow /Users/andrewy/wsp/circt/test/handshake-runner/histogram-std.mlir | /Users/andrewy/wsp/circt/build/bin/handshake-runner
0
/Users/andrewy/wsp/circt/tools/handshake-runner/Simulation.cpp:716:25: runtime error: 9.59553e+210 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/andrewy/wsp/circt/tools/handshake-runner/Simulation.cpp:716:25 in
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/andrewy/wsp/circt/build/bin/handshake-runner
fish: Process 98048, '/Users/andrewy/wsp/circt/build/bin/handshake-runner' from job 1, '/Users/andrewy/wsp/circt/build/…' terminated by signal SIGABRT (Abort)

The code in question is here: https://github.com/llvm/circt/blob/main/tools/handshake-runner/Simulation.cpp#L715. When the double named time is larger than an integer can represent, UBSan is aborting the program. I added a printf:

llvm::errs() << "time: " << time << "\N";

right before the aborting line of code, and it looks like each test is 50% of the time printing some stable number (1.150000e+02 for the test above) and 50% of the time printing something very random looking which crashes.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tools/handshake-runner/Simulation.cpp around line 715 and reproduce the failure using the sanitizer-enabled build and the histogram-std.mlir pipeline shown in the report. Compare the stable and random simulation-time results while investigating the reported race condition; done means handshake-runner tests no longer trigger UBSan or abort on an invalid time conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.