MCPcopy Index your code
hub / github.com/amit-davidson/Chronos

github.com/amit-davidson/Chronos @v.0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v.0.1.0 ↗ · + Follow
410 symbols 769 edges 161 files 16 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Chronos

<img src="https://i.imgur.com/AhLyxVh.jpeg" width="150" height="225">

made-with-Go made-with-Go MIT license PRs Welcome amit-davidson

Chronos is a static race detector for the Go language written in Go.

Quick Start:

Download the package

go get -v github.com/amit-davidson/Chronos/cmd/chronos

Pass the entry point

chronos --file <path_to_main>

Help

Usage of ./chronos:
  -file string
        The file containing the entry point of the program
  -pkg string
        Path to the to pkg of the file. Tells Chronos where to perform the search. By default, it assumes the file is inside $GOPATH

Example:

<img src="https://i.imgur.com/LJMP9c2.png" width="245" height="300">
<img src="https://i.imgur.com/S2mDG7A.png" width="575" height="300">

Features:

Support:

  • Detects races on pointers passed around the program.
  • Analysis of conditional branches, nested functions, interfaces, and defers.
  • Synchronization using mutex and goroutines starts.

Limitations:

  • Big programs and external packages. (Due to stack overflow)
  • Analysis of panics, for loops, goto, recursion, and select.
  • Synchronization using channels, waitgroups, once, cond and atomic.

Chronos vs go race:

Chronos successfully reports cases where go race fails thanks to his static nature. Mostly because data races appear in unexpected production workloads, which are hard to produce in dev. In addition, go race is having trouble with short programs where without contrived synchronization the program may exit too quickly.

In contrast, Chronos managed to report only 244/403 = 60.5% of go race test cases. This can be explained by Chronos partial support with Go's features so this number will increase in the future. Also, it lacked due to his static nature where context/path/flow sensitivity was required.

Therefore, I suggest using both according the strengths and weaknesses of each of the race detectors.

Credits:

Jan Wen, J., Jhala, R., & Lerner, S. (n.d.). RELAY: Static Race Detection on Millions of Lines of Code
Colin J. Fidge (February 1988). Timestamps in Message-Passing Systems That Preserve the Partial Ordering"

More examples:

<img src="https://i.imgur.com/NvVWFRf.png" width="230" height="440">
<img src="https://i.imgur.com/eCNFAX7.png" width=600" height="300">

<img src="https://i.imgur.com/app5tBc.png" width="285" height="450">
<img src="https://i.imgur.com/Lw0LTPp.png" width="545" height="300">

Extension points exported contracts — how you extend this code

Inter (Interface)
(no doc) [9 implementers]
e2e-tests/stdlib/TestNoRaceMethodValue/prog1.go
IceCreamMaker (Interface)
(no doc) [6 implementers]
e2e-tests/pointerAnalysis/DataRaceInterfaceOverChannel/prog1.go
IceCreamMaker (Interface)
(no doc) [6 implementers]
e2e-tests/interfaces/DataRaceIceCreamMaker/prog1.go
Inter (Interface)
(no doc) [9 implementers]
e2e-tests/stdlib/TestRaceInterCall/prog1.go
IceCreamMaker (Interface)
(no doc) [6 implementers]
e2e-tests/interfaces/NestedInterface/prog1.go
Inter (Interface)
(no doc) [9 implementers]
e2e-tests/stdlib/TestRaceMethodValue/prog1.go
IceCreamMaker (Interface)
(no doc) [6 implementers]
e2e-tests/interfaces/InterfaceWithLock/prog1.go
Inter (Interface)
(no doc) [9 implementers]
e2e-tests/stdlib/TestRaceMethodCall/prog1.go

Core symbols most depended-on inside this repo

AddGuardedAccess
called by 23
domain/GuardedAccess.go
Foo
called by 20
e2e-tests/stdlib/TestRaceMethodValue3/prog1.go
Copy
called by 7
domain/Lockset.go
GetRelativePath
called by 6
e2e-tests/testutils/JsonDomains.go
HandleCallCommon
called by 5
ssaUtils/Functions.go
GetEmptyFunctionState
called by 5
domain/FunctionState.go
MergeStates
called by 5
domain/FunctionState.go
String
called by 5
domain/GuardedAccess.go

Shape

Function 198
Method 93
Struct 73
TypeAlias 27
Interface 19

Languages

Go100%

Modules by API surface

ssaUtils/CFG.go8 symbols
e2e-tests/testutils/JsonDomains.go8 symbols
domain/Lockset.go8 symbols
domain/FunctionState.go8 symbols
utils/util.go7 symbols
e2e-tests/stdlib/TestRaceMethodValue3/prog1.go7 symbols
e2e-tests/stdlib/TestRaceMethodValue2/prog1.go7 symbols
e2e-tests/stdlib/TestRaceMethodValue/prog1.go7 symbols
e2e-tests/stdlib/TestRaceMethodCall2/prog1.go7 symbols
e2e-tests/stdlib/TestRaceMethodCall/prog1.go7 symbols
e2e-tests/stdlib/TestRaceInterCall2/prog1.go7 symbols
e2e-tests/stdlib/TestRaceInterCall/prog1.go7 symbols

For agents

$ claude mcp add Chronos \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact