Chronos - A static race detector for the go language

Overview

Chronos

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> --mod <path_to_module>

Help

Usage of ./chronos:
  --file string
    	The file containing the entry point of the program
  --mod string
    	Absolute path to the module where the search should be performed. Should end in the format:{VCS}/{organization}/{package}. Packages outside this path are excluded rom the search.

Example:

Features:

Support:

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

Limitations:

  • Big programs and external packages. (Due to stack overflow)
  • Synchronization using channels, waitgroups, once, cond and atomic.

Chronos vs go race:

Chronos successfully reports cases where go race fails thanks to it's 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 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:


Comments
  • what  “--mod <path_to_module>” means in chronos

    what “--mod ” means in chronos

    My project structure is:

    - main
        - main.go
    

    And in main.go, I copied code from chronos testdata:

    package main
    
    type A struct {
    	X int
    }
    
    func main() {
    	a := A{}
    	go func() {
    		a.X = 1
    	}()
    	a.X = 2
    }
    

    But when I tried the args :

    --file <path to project>\main\main.go --mod <path to project>\main
    

    The output is No data races found What's wrong? And what's mod in chronos? Thanks.

    opened by ChenhuaYang 5
  • Another invalid memory address

    Another invalid memory address

    Using the latest build

    zhouqiang@MacBook-Pro-4 bin % ./chronos --file /Users/zhouqiang/go/src/github.com/pingcap/tidb/tidb-server/main.go 
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x146f456]
    
    goroutine 1 [running]:
    github.com/amit-davidson/Chronos/ssaUtils.GetTopLevelPackageName(0x0, 0x0, 0x0, 0x0, 0x0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Packages.go:56 +0x26
    github.com/amit-davidson/Chronos/ssaUtils.SetGlobals(0xc020293b80, 0x0, 0x0, 0x0, 0x0, 0x0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Packages.go:48 +0xf2
    main.main()
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/cmd/chronos/main.go:26 +0x21a
    
    opened by zhouqiang-cl 4
  • Could Chronos detect one arbitrary go file?

    Could Chronos detect one arbitrary go file?

    Chrono privide such way to use. $ chronos --file <path_to_main> --mod <path_to_module>

    Why should I specify path_to_main, could I just detect one arbitrary go file, like: $ go run -race mysrc.go

    opened by ChenhuaYang 3
  • Fixing a few code quality issues

    Fixing a few code quality issues

    Hey @amit-davison, I recently ran the DeepSource static analyzer on this repo, and it generated this report that I think you should check it out!

    I am opening this PR to fix a few of them, as mentioned below:

    • Omit comparison with boolean constant
    • Simplify returning boolean expression
    • Add DeepSource config
    opened by de-sh 3
  • SIGSEGV on analysing a repo

    SIGSEGV on analysing a repo

    Command executed:

    chronos --pkg gitlab.com/poldi1405/bulkrename --file main.go
    

    Version: 29ca1294314363b29d66bd61348f38a8cef1a1b6

    Output:

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6c8598]
    
    goroutine 1 [running]:
    github.com/amit-davidson/Chronos/ssaUtils.GetDefersSummary(0xc00a036640, 0xc002f7ef20, 0x9fd698, 0x0, 0x0, 0xc002211f50)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:95 +0x238
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc00a036640, 0xc005090780, 0x1)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:177 +0x1dc
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc00a036640, 0xc00617a140, 0x405529, 0x0)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:45 +0x49b
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc00a036640, 0xc006161ef0, 0x744980)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:133 +0x4ff
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc00a036640, 0xc006161ef0, 0x0)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:58 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0018c9a40, 0xc00a036640, 0xc006161ef0)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:121 +0x1f0
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc00a036640, 0xc006161ef0, 0x7ffd54d59bbf, 0x1f)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:69 +0xdb
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc00a036640, 0xc005090500, 0x1)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc00a036640, 0xc0018c9980, 0x4054c9, 0x0)
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:45 +0x49b
    main.main()
    	/home/moritz/go/src/github.com/amit-davidson/Chronos/cmd/chronos/main.go:34 +0x43c
    
    opened by mpldr 3
  • Panic while self check

    Panic while self check

    Runnig chronos on ./cmd/main.go will cause a panic

    Call: chronos -file ./cmd/main.go

    Result:

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6c78d8]
    
    goroutine 1 [running]:
    github.com/amit-davidson/Chronos/ssaUtils.GetDefersSummary(0xc01ea325c0, 0xc019c78790, 0xa00880, 0x0, 0x0, 0xc011cfec80)
    	/dev/Chronos/ssaUtils/CFG.go:94 +0x238
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc01ea325c0, 0xc010bc68c0, 0x1)
    	/dev/Chronos/ssaUtils/Functions.go:177 +0x1dc
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc01ea325c0, 0xc010d982c0, 0x9b09b5, 0x0)
    	/dev/Chronos/ssaUtils/Functions.go:45 +0x49b
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc01ea325c0, 0xc0037c33f0, 0x1)
    	/dev/Chronos/ssaUtils/Functions.go:133 +0x4ff
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc01ea325c0, 0xc0037c33f0, 0x2)
    	/dev/Chronos/ssaUtils/CFG.go:57 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc01ea295c0, 0xc01ea325c0, 0xc0037c33f0)
    	/dev/Chronos/ssaUtils/CFG.go:114 +0x11d
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc01ea295c0, 0xc01ea325c0, 0xc0037c3340)
    	/dev/Chronos/ssaUtils/CFG.go:131 +0x1bd
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc01ea295c0, 0xc01ea325c0, 0xc0037c3290)
    	/dev/Chronos/ssaUtils/CFG.go:131 +0x1bd
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc01ea325c0, 0xc0037c3290, 0xc001d62240, 0x21)
    	/dev/Chronos/ssaUtils/CFG.go:68 +0xdb
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc01ea325c0, 0xc010c1ea00, 0x1)
    	/dev/Chronos/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc01ea325c0, 0xc01ea29500, 0x9b0810, 0x0)
    	/dev/Chronos/ssaUtils/Functions.go:45 +0x49b
    main.main()
    	/dev/Chronos/cmd/main.go:34 +0x43c
    
    opened by ninedraft 3
  • Panic in the tests (37a9373)

    Panic in the tests (37a9373)

    Running on 37a9373

    go test -race ./e2e-tests/
    

    will cause

    --- FAIL: TestE2E (3.24s)
        --- FAIL: TestE2E/Lock (3.24s)
    panic: runtime error: index out of range [1] with length 1 [recovered]
    	panic: runtime error: index out of range [1] with length 1
    
    goroutine 22 [running]:
    testing.tRunner.func1.1(0x9b86a0, 0xc000e6a9c0)
    	/usr/lib/go/src/testing/testing.go:1076 +0x46a
    testing.tRunner.func1(0xc000082d80)
    	/usr/lib/go/src/testing/testing.go:1079 +0x636
    panic(0x9b86a0, 0xc000e6a9c0)
    	/usr/lib/go/src/runtime/panic.go:975 +0x3e9
    github.com/amit-davidson/Chronos/e2e-tests/testutils.GetRelativePath(0x1a09dc, 0xc000f9ca00, 0xc000641bf8, 0x0)
    	/dev/pet/Chronos/e2e-tests/testutils/JsonDomains.go:68 +0x276
    github.com/amit-davidson/Chronos/e2e-tests/testutils.LocksetToJSON(0xc003570030, 0x8db85e)
    	/dev/pet/Chronos/e2e-tests/testutils/JsonDomains.go:48 +0x1e5
    github.com/amit-davidson/Chronos/e2e-tests/testutils.NewTestResult(0xc003570030, 0xc003570070, 0x2, 0x2, 0xc0037fbf08)
    	/dev/pet/Chronos/e2e-tests/testutils/utils.go:18 +0x56
    github.com/amit-davidson/Chronos/e2e-tests.TestE2E.func1(0xc000082d80)
    	/dev/pet/Chronos/e2e-tests/summary_test.go:187 +0x599
    testing.tRunner(0xc000082d80, 0xc0000963f0)
    	/usr/lib/go/src/testing/testing.go:1127 +0x203
    created by testing.(*T).Run
    	/usr/lib/go/src/testing/testing.go:1178 +0x797
    FAIL	github.com/amit-davidson/Chronos/e2e-tests	3.287s
    FAIL
    
    opened by ninedraft 2
  • golang pointer analysis

    golang pointer analysis

    @amit-davidson Was wondering if updates w.r.t. Golang pointer analysis would be interesting for this project? Note there has been a fix recently (eg https://github.com/golang/go/issues/45735) and also I am working on (still pre-alpha: https://github.com/go-air/pal)

    Would you be interested in seeing if either of these could help this project?

    opened by scott-cotton 1
  • invalid memory address

    invalid memory address

    zhouqiang@MacBook-Pro-4 tidb % /Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/cmd/chronos/chronos --file tidb-server/main.go
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1439ea0]
    
    goroutine 1 [running]:
    github.com/amit-davidson/Chronos/ssaUtils.GetDefersSummary(0xc0875e6300, 0xc0695b8580, 0x19acde8, 0x0, 0x0, 0xc0811a60f0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:96 +0x250
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc0875e6300, 0xc065e523c0, 0x1)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:177 +0x1cd
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc0875e6300, 0xc0722538c0, 0x2e85ae2, 0x0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:45 +0x549
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc0875e6300, 0xc072257130, 0x14f5620)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:133 +0x520
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc0875e6300, 0xc072257130, 0x0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:59 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc087c93680, 0xc0875e6300, 0xc072257130)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:122 +0x1e5
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc0875e6300, 0xc072257130, 0xc06a70c000, 0x18)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:70 +0xd6
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc0875e6300, 0xc065e588c0, 0x1)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:174 +0x190
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc0875e6300, 0xc067e319c0, 0x2e8528b, 0x0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:45 +0x549
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc0875e6300, 0xc045e84e70, 0x1)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:133 +0x520
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc0875e6300, 0xc045e84e70, 0x2)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:59 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc087c93040, 0xc0875e6300, 0xc045e84e70)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:122 +0x1e5
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc087c93040, 0xc0875e6300, 0xc045e84dc0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:139 +0x288
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc087c93040, 0xc0875e6300, 0xc045e84d10)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:139 +0x288
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc0875e6300, 0xc045e84d10, 0xc06a70c000, 0x18)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:70 +0xd6
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc0875e6300, 0xc065e58140, 0x1)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:174 +0x190
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc0875e6300, 0xc087c92f40, 0x2e85221, 0x0)
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:45 +0x549
    main.main()
    	/Users/zhouqiang/go/src/github.com/amit-davidson/Chronos/cmd/chronos/main.go:34 +0x431
    
    opened by zhouqiang-cl 1
  • panic: runtime error: invalid memory address or nil pointer dereference

    panic: runtime error: invalid memory address or nil pointer dereference

    I'm using the following version:

    +github.com/amit-davidson/Chronos v0.0.0-20201017170051-1634412958f8 h1:MZrylyYLgUexduUsYWV9DbgxqJduLk3phvT2jGPKJfU=
    +github.com/amit-davidson/Chronos v0.0.0-20201017170051-1634412958f8/go.mod h1:w8yL4vxG5cWT/GztYUDpB3vRuOuSimZf0yWp2eRx6Fc=
    

    When trying to analyse a command (sorry, closed source!) I am getting:

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6c7c07]
    
    goroutine 1 [running]:
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc058872260, 0xc04387ca50, 0xc017beb8c0, 0x1a)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:69 +0xe7
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc058872260, 0xc0399fbe00, 0x1)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc058872260, 0xc0439024c0, 0x1f86e74, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:45 +0x49b
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc058872260, 0xc04387c840, 0xc058937df0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:133 +0x4ff
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc058872260, 0xc04387c840, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:57 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc05895c900, 0xc058872260, 0xc04387c840)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:114 +0x11d
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc058872260, 0xc04387c840, 0xc017beb8c0, 0x1a)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:68 +0xdb
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc058872260, 0xc0399fbcc0, 0x1)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc058872260, 0xc03d6c94c0, 0x1f87a7e, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:45 +0x49b
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc058872260, 0xc03cb456b0, 0xc058936fd0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:133 +0x4ff
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc058872260, 0xc03cb456b0, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:57 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc058945180, 0xc058872260, 0xc03cb456b0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:114 +0x11d
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc058872260, 0xc03cb456b0, 0xc017beb8c0, 0x1a)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:68 +0xdb
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc058872260, 0xc0399fba40, 0x1)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc058872260, 0xc0436ec840, 0x1f9767a, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:45 +0x49b
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc058872260, 0xc0436e0bb0, 0xc0589364c0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:133 +0x4ff
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc058872260, 0xc0436e0bb0, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:57 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc058927cc0, 0xc058872260, 0xc0436e0bb0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:114 +0x11d
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc058872260, 0xc0436e0bb0, 0xc017beb8c0, 0x1a)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:68 +0xdb
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc058872260, 0xc039a34780, 0x1)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc058872260, 0xc03d26da40, 0x1f99056, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:45 +0x49b
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc058872260, 0xc02a05e210, 0xc058861e70)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:133 +0x4ff
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc058872260, 0xc02a05e210, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:57 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0588652c0, 0xc058872260, 0xc02a05e210)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:114 +0x11d
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc058872260, 0xc02a05e210, 0xc017beb8c0, 0x1a)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:68 +0xdb
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc058872260, 0xc039a61b80, 0x1)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc058872260, 0xc027dff8c0, 0x1f993ed, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:45 +0x49b
    github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc058872260, 0xc025c76790, 0xc058861a70)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:133 +0x4ff
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary.func1(0xc058872260, 0xc025c76790, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:57 +0x35
    github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc058864b80, 0xc058872260, 0xc025c76790)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:114 +0x11d
    github.com/amit-davidson/Chronos/ssaUtils.GetBlocksSummary(0xc058872260, 0xc025c76790, 0xc017beb8c0, 0x1a)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/CFG.go:68 +0xdb
    github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc058872260, 0xc039a61e00, 0x1)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:174 +0x19f
    github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc058872260, 0xc058864ac0, 0x1f9932d, 0x0)
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/[email protected]/ssaUtils/Functions.go:45 +0x49b
    main.main()
    	/home/rjeczalik/pkg/mod/github.com/amit-davidson/!c[email protected]/cmd/main.go:34 +0x43c
    
    opened by rjeczalik 1
  • Improve control flow graph to support for loops

    Improve control flow graph to support for loops

    Proposal

    The control flow graph traverses between vertices from the start to the last block using DFS. If it reaches a block where not all of his dependencies are calculated (A block after a condition where not all the preceding branches were visited yet), then it returns up the graph, and the block will be reached again later from a different path. Loops pose a problem since the graph is cyclic (due to the back edge between the loop body and header). As a result, the dependencies can't be calculated since each vertice depends on the other. The traversing function should be improved to support such cases.

    For more details: https://en.wikipedia.org/wiki/Control-flow_graph

    good first issue 
    opened by amit-davidson 1
  • Add more user-friendly errors

    Add more user-friendly errors

    Enhancement

    When the program panics the entire stack trace is returned. A more user friendly should be returned. It should contain the failing stacktrace but also the following messages as in the example stacktrace below (taken from that of the stdlib pointer package):

    • Internal panic in while performing analysis: at the top

    • Error in analysis (please report this bug) at the bottom

    For that, a recover should be added to the start of the program and catch all panics and wrap them with the added messages.

    Internal panic in while performing analysis:
    goroutine 1 [running]:
    runtime/debug.Stack(0x24, 0x0, 0x0)
            /usr/local/Cellar/go/1.15.3/libexec/src/runtime/debug/stack.go:24 +0x9f
    runtime/debug.PrintStack()
            /usr/local/Cellar/go/1.15.3/libexec/src/runtime/debug/stack.go:16 +0x25
    golang.org/x/tools/go/pointer.Analyze.func1(0xc05b607b00)
            /Users/amdavidson/go/pkg/mod/golang.org/x/[email protected]/go/pointer/analysis.go:227 +0x10b
    panic(0x13502e0, 0xc03aff2380)
            /usr/local/Cellar/go/1.15.3/libexec/src/runtime/panic.go:969 +0x1b9
    golang.org/x/tools/go/pointer.(*analysis).taggedValue(0xc042b7d340, 0xc00002acfd, 0x2, 0x64, 0xc00d7a8000)
            /Users/amdavidson/go/pkg/mod/golang.org/x/[email protected]/go/pointer/gen.go:272 +0x105
    golang.org/x/tools/go/pointer.(*invokeConstraint).solve(0xc0499eb780, 0xc042b7d340, 0xc082a8e400)
            /Users/amdavidson/go/pkg/mod/golang.org/x/[email protected]/go/pointer/solve.go:317 +0x24e
    golang.org/x/tools/go/pointer.(*analysis).solveConstraints(0xc042b7d340, 0xc049a7f620, 0xc082a8e400)
            /Users/amdavidson/go/pkg/mod/golang.org/x/[email protected]/go/pointer/solve.go:165 +0x178
    golang.org/x/tools/go/pointer.(*analysis).solve(0xc042b7d340)
            /Users/amdavidson/go/pkg/mod/golang.org/x/[email protected]/go/pointer/solve.go:59 +0x1ad
    golang.org/x/tools/go/pointer.Analyze(0xc042efc690, 0x0, 0x1437dc0, 0xc03aff2390)
            /Users/amdavidson/go/pkg/mod/golang.org/x/[email protected]/go/pointer/analysis.go:331 +0x4bc
    github.com/amit-davidson/Chronos/pointerAnalysis.Analysis(0xc02ebbdb00, 0xc02e1361e0, 0xc042cd6f00, 0x5c, 0x60, 0x0, 0x7c)
            /Users/amdavidson/go/pkg/mod/github.com/amit-davidson/[email protected]/pointerAnalysis/PointerAnalysis.go:51 +0x38a
    main.main()
            /Users/amdavidson/go/pkg/mod/github.com/amit-davidson/[email protected]/cmd/chronos/main.go:35 +0x473
    Error in analysis (please report this bug)
    
    enhancement good first issue 
    opened by amit-davidson 2
  • Add command line argument for shorter warning output

    Add command line argument for shorter warning output

    Enhancement

    At the moment, a lengthy description of all the possible race conditions is printed. It includes all the race conditions pairs and the stack trace of that flow. This might be too long and too complicated. A new command-line argument called --short should be added that will allow displaying less information. It should include:

    • The total amount of possible race conditions

    • The variables themselves (same as in the more lengthy version)

    • Path to the variable (without including the stacktrace)

    enhancement good first issue 
    opened by amit-davidson 0
  • nil pointer dereference HandleCallCommon Functions.go:64

    nil pointer dereference HandleCallCommon Functions.go:64

    After my first try a month ago when I had a nil pointer exception I now first I ran: go get -u github.com/amit-davidson/Chronos/cmd/chronos

    Then tried again to run the application but no luck. The issue is within a single package I think. I tried with the -pkg flag and seems that all the other packages work well including internal.

    Hope this helps you: Functions.go:64 fs := domain.CreateFunctionState(blockStateRet.GuardedAccesses, blockStateRet.Lockset)

    panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x146e3c4]

    goroutine 1 [running]: github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc04186c780, 0xc02ad5be08, 0x13a592c, 0x0) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:64 +0x774 github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc0259b9f48, 0xc02ad4c840, 0xb) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:160 +0x43e github.com/amit-davidson/Chronos/ssaUtils.(*CFG).calculateBlockStateIfNeeded(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c840) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:90 +0x75 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c840) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:33 +0xa8 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c790) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c6e0) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c630) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c420) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c4d0) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02ad4c370) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02a551ce0) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc02a551c30) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc00c0f9ce0) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc00c0f9c30) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc00c0f9b80) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).traverseGraph(0xc0259b9ce8, 0xc0259b9f48, 0xc0259b9ba8) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:41 +0x4c2 github.com/amit-davidson/Chronos/ssaUtils.(*CFG).calculateFunctionState(0xc0259b9ce8, 0xc0259b9f48, 0xc00c0f9b80) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/CFG.go:27 +0xd0 github.com/amit-davidson/Chronos/ssaUtils.HandleFunction(0xc0259b9f48, 0xc02840b040, 0xc0239a1e60) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:201 +0x298 github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc0259b9f48, 0xc04185ae40, 0x13a565f, 0x0) /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:63 +0x767 main.main() /Users/developer/go/src/github.com/amit-davidson/Chronos/cmd/chronos/main.go:34 +0x4b9

    opened by jtorvald 20
  • Internal panic in pointer analysis

    Internal panic in pointer analysis

    $ chronos --file ./pilot/cmd/pilot-agent/main.go
    Internal panic in pointer analysis:
    goroutine 1 [running]:
    runtime/debug.Stack(0x24, 0x0, 0x0)
            /usr/local/go/src/runtime/debug/stack.go:24 +0x9d
    runtime/debug.PrintStack()
            /usr/local/go/src/runtime/debug/stack.go:16 +0x22
    golang.org/x/tools/go/pointer.Analyze.func1(0xc03e10fad0)
            /usr/local/google/home/howardjohn/go/pkg/mod/golang.org/x/[email protected]/go/pointer/analysis.go:227 +0x10b
    panic(0x8b8b20, 0xc0b6a0a760)
            /usr/local/go/src/runtime/panic.go:967 +0x15d
    golang.org/x/tools/go/pointer.(*analysis).taggedValue(0xc07a85d6c0, 0xc0000984b7, 0x2, 0x64, 0xc0338c5880)
            /usr/local/google/home/howardjohn/go/pkg/mod/golang.org/x/[email protected]/go/pointer/gen.go:272 +0x102
    golang.org/x/tools/go/pointer.(*invokeConstraint).solve(0xc0bb920750, 0xc07a85d6c0, 0xc070062140)
            /usr/local/google/home/howardjohn/go/pkg/mod/golang.org/x/[email protected]/go/pointer/solve.go:317 +0x24c
    golang.org/x/tools/go/pointer.(*analysis).solveConstraints(0xc07a85d6c0, 0xc0aea87170, 0xc070062140)
            /usr/local/google/home/howardjohn/go/pkg/mod/golang.org/x/[email protected]/go/pointer/solve.go:165 +0x171
    golang.org/x/tools/go/pointer.(*analysis).solve(0xc07a85d6c0)
            /usr/local/google/home/howardjohn/go/pkg/mod/golang.org/x/[email protected]/go/pointer/solve.go:59 +0x1a2
    golang.org/x/tools/go/pointer.Analyze(0xc040099180, 0x0, 0xa290a0, 0xc0b6a0a7b0)
            /usr/local/google/home/howardjohn/go/pkg/mod/golang.org/x/[email protected]/go/pointer/analysis.go:331 +0x4a5
    github.com/amit-davidson/Chronos/pointerAnalysis.Analysis(0xc05177de00, 0xc0102010e0, 0xc0462aae00, 0x7, 0x8, 0x0, 0x7c)
            /usr/local/google/home/howardjohn/go/pkg/mod/github.com/amit-davidson/[email protected]/pointerAnalysis/PointerAnalysis.go:51 +0x36a
    main.main()
            /usr/local/google/home/howardjohn/go/pkg/mod/github.com/amit-davidson/[email protected]/cmd/chronos/main.go:35 +0x468
    Error in analysis:internal error in pointer analysis: not a tagged object: n623799 (please report this bug)
    

    Codebase is run against https://github.com/istio/istio

    opened by howardjohn 4
Releases(v.0.1.0)
  • v.0.1.0(Oct 19, 2020)

    Support for:

    • Pointer analysis of variables (does not include synchronization mechanisms such as locks, channels, etc)
    • Analysis of:
      • Conditional branches
      • Functions with a single return
      • Nested functions
      • Interfaces
      • Defers
    • Synchronization using:
      • Mutexes
      • Goroutines starts
    Source code(tar.gz)
    Source code(zip)
Owner
Amit Davidson
Amit Davidson
Vulnerability Static Analysis for Containers

Clair Note: The main branch may be in an unstable or even broken state during development. Please use releases instead of the main branch in order to

QUAY 9.3k Jan 4, 2023
Static analysis for CloudFormation templates to identify common misconfigurations

cfsec What is it? cfsec scans your yaml or json CloudFormation configuration files for common security misconfigurations. Installation Home Brew - Mac

Aqua Security 56 Nov 7, 2022
debiman generates a static manpage HTML repository out of a Debian archive

debiman Goals debiman makes (Debian) manpages accessible in a web browser. Its goals are, in order: completeness: all manpages in Debian should be ava

The Universal OS 145 Jan 4, 2023
A fake kube-apiserver that serves static data from files

Static KAS A fake kube-apiserver that serves static data from an Openshift must-gather. Dynamically discovers resources and supports logs. Requires go

Alvaro Aleman 34 Nov 19, 2022
Build powerful pipelines in any programming language.

Gaia is an open source automation platform which makes it easy and fun to build powerful pipelines in any programming language. Based on HashiCorp's g

Gaia 4.9k Jan 3, 2023
A serverless cluster computing system for the Go programming language

Bigslice Bigslice is a serverless cluster data processing system for Go. Bigslice exposes composable API that lets the user express data processing ta

GRAIL 516 Dec 14, 2022
A template repository to quickly scaffold a Kubewarden policy written with Go language

go-policy-template This is a template repository that can be used to to quickly scaffold a Kubewarden policy written with Go language. Don't forget to

Kubewarden 5 Sep 7, 2022
Not another markup language. Framework for replacing Kubernetes YAML with Go.

Not another markup language. Replace Kubernetes YAML with raw Go! Say so long ?? to YAML and start using the Go ?? programming language to represent a

Kris Nóva 1.2k Jan 3, 2023
Common Expression Language -- specification and binary representation

The Common Expression Language (CEL) implements common semantics for expression evaluation, enabling different applications to more easily interoperate.

Google 1.6k Jan 8, 2023
A cross-language distributed transaction manager

English Docs 跨语言分布式事务管理器 DTM是一款golang开发的分布式事务管理器,解决了跨数据库、跨服务、跨语言栈更新数据的一致性问题。 他优雅

DTM Development and Communities 8.1k Dec 31, 2022
🥑 Language focused docker images, minus the operating system.

"Distroless" Docker Images "Distroless" images contain only your application and its runtime dependencies. They do not contain package managers, shell

null 14.5k Jan 9, 2023
A very simple, silly little kubectl plugin / utility that guesses which language an application running in a kubernetes pod was written in.

A very simple, silly little kubectl plugin / utility that guesses which language an application running in a kubernetes pod was written in.

Tom Granot 2 Mar 9, 2022
Github-language-trends - Github trending languages API

Github trending languages API This API provides list of most popular github lang

Artur Veske 0 Feb 15, 2022
helm-lint-ls is helm lint language server protocol LSP.

helm-lint-ls is helm lint language server protocol LSP.

MrJosh 25 Dec 27, 2022
An Oracle Cloud (OCI) Pulumi resource package, providing multi-language access to OCI

Oracle Cloud Infrastructure Resource Provider The Oracle Cloud Infrastructure (OCI) Resource Provider lets you manage OCI resources. Installing This p

Pulumi 14 Dec 2, 2022
Gopherscript is a secure and minimal scripting language written in Go.

Gopherscript Gopherscript is a secure scripting/configuration language written in Go. It features a fined-grain permission system and enforces a stron

Debloat 20 Oct 2, 2022
Retry, Race, All, Some, etc strategies for http.Client calls

reqstrategy Package reqstrategy provides functions for coordinating http.Client calls. It wraps typical call strategies like making simultaneous reque

Sergiy Yavorsky 11 Apr 30, 2021
How we can run unit tests in parallel mode with failpoint injection taking effect and without injection race

This is a simple demo to show how we can run unit tests in parallel mode with failpoint injection taking effect and without injection race. The basic

amyangfei 1 Oct 31, 2021
Splits heat 1 from the feature race to make it easy to upload multi-heat races to simracerhub as individual races

simracerhub_heat_splitter Splits heat 1 from the feature race to make it easy to upload multi-heat races to simracerhub as individual races Install Yo

Bjorn Stange 0 Jan 9, 2022
A faster file programming language detector

Programming language detector and toolbox to ignore binary or vendored files. enry, started as a port to Go of the original Linguist Ruby library, that has an improved 2x performance.

go-enry 317 Jan 1, 2023