Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nil pointer dereference HandleCallCommon Functions.go:64 #26

Open
jtorvald opened this issue Nov 14, 2020 · 20 comments
Open

nil pointer dereference HandleCallCommon Functions.go:64 #26

jtorvald opened this issue Nov 14, 2020 · 20 comments

Comments

@jtorvald
Copy link

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

@amit-davidson
Copy link
Owner

@jtorvald first of all sorry for the inconvenience with the panics. I consider this project to be early in its development so many bugs are expected (unfortunately).
Regarding the issue:

  1. Is it possible to share the code you ran on?
  2. Also, what do you mean by "all other packages work well"? other than what?

@jtorvald
Copy link
Author

@amit-davidson I completely understand. I didn't meant to sound complaining. Just eager to test this out and provide you with the things that go wrong so you can improve it.

  1. Unfortunately I'm not in the position to disclose the source.
  2. I mean: there is one package in my application (a large one) that doesn't work. Which gives me the nil pointer dereference above. If I run the command to filter on other package names in my project, then the application seems to work and gives me that there are "No data races found"

If you have any idea what could cause this I might be able to deduct what in my code causes this and I can maybe create a separate project for you to debug that issue.

@amit-davidson
Copy link
Owner

amit-davidson commented Nov 15, 2020

@jtorvald ohhhhh...
Yea I know you weren't complaining. I just wanted to come forward to the status project and explain why the panics happen. Hard to express a mood in words :) Also, thank you for testing the package. It means a lot to me.

  1. Understood
  2. The -pkg flag is intended to be used as a limit to what packages shouldn't be searched. It's used mostly to guard against big codebases where the program might take too much memory (I plan to make optimizations and remove it all). In your case, you used it to guard against entering problematic packages is which is fair use.
    The nil is due to blockStateRet which means the traversal of the control flow graph didn't go well. I don't know exactly what caused this but I remember I got a similar error when I had a function containing only (or almost only) a for loop without a header - for {}. for true {} or for ; err == nil; {} are better but the first example messes up everything. You can check if one of the packages you excluded contains it. If so, you can try to use for true {} for example. Anyway, I will later today push a fix that can help without changing the code. It doesn't solve the problem I'm having but makes the flow that fails run in fewer occurrences so it'll solve the issue for you.

@jtorvald
Copy link
Author

@amit-davidson cool!
Yeah there is a couple of those constructs (for {}) in the code. When you have a new update I will try it out!

@amit-davidson
Copy link
Owner

amit-davidson commented Nov 17, 2020

@jtorvald You can already try to use master. It should solve it for you.

@jtorvald
Copy link
Author

@amit-davidson thanks! Hereby the next issue I run into.

panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0121052c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:97 +0x7c4
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013ce8780, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013cf3cc0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013ddaa00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0138fcc80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc014113a40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a0e3c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc014112a00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017bc5900, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017bc57c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017bc92c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017bc9400, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017cb9b80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc015119400, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017d61b80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017d61cc0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a0a780, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a0a8c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a46000, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a45680, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a45540, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a443c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a0e140, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc019778640, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc016e6cc80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc019758c80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc016f22a00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a07a40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0124b7040, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012111b80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012111900, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0121117c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013de8280, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013de0f00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013ff5040, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013d34c80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017a0e500, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01773bb80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc014110dc0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013839cc0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01362ac80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01362e8c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013e5fa40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0141117c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0124a4500, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355cf00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355cb40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355c8c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355e000, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355cdc0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013825b80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012ad43c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012ad4280, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017eb2500, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc016d93b80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013838000, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017daaf00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012aec000, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0124b7b80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0124b88c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013824140, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0136aa780, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012ddbcc0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012df23c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012debe00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012756640, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc016c62dc0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0124b8140, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013626b40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012112a00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012112780, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017fa1400, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0121123c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012112140, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012111e00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012111540, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012111680, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355eb40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355ec80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355e500, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01355da40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01837c500, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0124b9540, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0124b9a40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0136e28c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017eb3680, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017eb3a40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc016d937c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017dab7c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc017dab900, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc012aeca00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01297c780, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc01383b180, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013824c80, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013824b40, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013824a00, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc013824780, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5
github.com/amit-davidson/Chronos/ssaPureUtils.IsFunctionContainingLocks(0xc02ac5b0e0, 0xc0138248c0, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaPureUtils/preProcess.go:107 +0x4e5

@amit-davidson
Copy link
Owner

@jtorvald Wow. Actually, it surprises me. Basically, it fails since it detects a call to Lock/Unlock (Checks for this name(*sync.Mutex).Unlock). But it fails since the function has no arguments (len(0)-1 -> [-1]) which is super weird. In other words, it detects a lock/unlock with a receiver.
I have no idea in what scenario it could happen. Anyway, in general, I really appreciate your cooperation and I don't want to tire you with this discussion. If you prefer, we can do a quick session and I'll probably be able to solve all the issues you're facing.

@jtorvald
Copy link
Author

@amit-davidson Not sure if I understand you 100%. Unlock does not have arguments right? Or that is exactly the problem...
Can that be a mutex embedded in a struct or something?

I managed to figure this out:
F (*sync.Mutex).Unlock
functionName: Wait
Pkg: package sync
Pos: 2128809
Syntax: [2128793 2129152]

Is there a way to do a "Stacktrace" to see where it originates?

@amit-davidson
Copy link
Owner

@jtorvald
The receiver is counted as an argument. The program wants to know the receiver to understand what lock/unlock was changed. And yes, as you say for some reason it detects a call to an unlock but without a receiver.

Mutex in a struct as a field, or even embedded works so that's not the case. I also tried to reproduce it locally by calling Wait on WaitGroup (it looks like the problem), but it didn't work.

About seeing where it originates, that's good idea. There's no need to calculate the "entire" stacktrace to determine the flow, just to see where it's located in the code which is the Pos parameter.

You can use the function GetRelativePath from testutils. Add those lines under line 31 (just after the program loads). It'll give you the path to that code.

	path := testutils.GetRelativePath(2128809, ssaProg)
	_ = path

If it still doesn't work for you, I would suggest a session. (if that's something you're comfortable with of course. I don't want to push it).

@amit-davidson
Copy link
Owner

Hey @jtorvald,
So I found the problem. It happens when calling a Cond.Wait() in your code. There's a call inside it to Unlock, but it's a call to Unlock on an interface. In that case, it's not possible to determine the actual receiver since callCommon.Args is nil. Because it's a rare flow, I introduced a test for it and skip recording those kinds of mutexes for now (until pointer analysis for mutexes is introduced) so the program won't panic.

@jtorvald
Copy link
Author

Hey @amit-davidson that is good news. I figured something out a couple of days ago and wanted to write you but haven't had the time. Life is a bit chaotic at the moment.

I figured out what part of the code it comes from and tried to isolate it, but the funny thing is that if I move the code to separate main.go or to merge the code from two libraries in one with only the problem code then it doesn't happen. Exact same code, just copy and paste and removed the import. In my code it has to do with the sync.Pool and maybe an "internal" package name. But not 100% sure what causes the issue since when I move the code to a separate command it doesn't crash. It only checks code that gets in one of the code paths right?

I just updated and tried the new version and the old error seems to be gone. The test program with my library now also gives no data races. So that is good news.

But I got something in return:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1472574]

goroutine 1 [running]:
github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc00b3ef320, 0xc02b8856d8, 0x13a7878, 0x0)
/Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:64 +0x774
github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc03bd11f10, 0xc02b89f810, 0xb)

It's no rush for me to figure it out, just wanted to help you find edge cases. I could do a screenshare or something if you want. Just not sure when I have the time for it. I could drop you a mail and we can see if we can find some time somewhere.

@amit-davidson
Copy link
Owner

@jtorvald Hope everything is fine and you are safe.

It only checks code that gets in one of the code paths right?

Regarding the above. The answer is yes. It inspects all paths deriving from the main functions. I'm not really sure why it stopped panicking after merging the 2 libraries but I assume the problematic code was skipped due to the reason just mentioned.

I'm happy everything is ok now and the program is stable.
What is that panic you mentioned? Was it before the merge? after it? or something completely else?
Also, do you remember the commit? I think the line numbers might be different now.

@jtorvald
Copy link
Author

@amit-davidson yeah, we're good, thanks!
The git hash of the version I tested: 4ab82c6


$ chronos --file cmd/server/main.go 2>&1 |head -n 7 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x14a47d4]

goroutine 1 [running]:
github.com/amit-davidson/Chronos/ssaUtils.HandleCallCommon(0xc01b59c800, 0xc02b0fe198, 0x13a8b43, 0x0)
        /Users/developer/go/src/github.com/amit-davidson/Chronos/ssaUtils/Functions.go:64 +0x774
github.com/amit-davidson/Chronos/ssaUtils.GetBlockSummary(0xc03afdff10, 0xc02b3811e0, 0xb)

The line where it happens:


fs := domain.CreateFunctionState(blockStateRet.GuardedAccesses, blockStateRet.Lockset)

@amit-davidson
Copy link
Owner

@jtorvald I made some fixes in that area and I think it should be better now #36. You can try it again. It should also execute much faster and take less memory.

@jtorvald
Copy link
Author

jtorvald commented Nov 25, 2020

The good news is: no crash... Bad news, it's frying the CPU for like 20 minutes and then I stopped it.
Not sure what is going on. Seems like it's looping or something.

image

image

@amit-davidson
Copy link
Owner

amit-davidson commented Nov 25, 2020

@jtorvald
Could be an endless loop. Is it the same code or something else? Although the changes I did improve the memory usage, it still results in excessive use of the garbage collector, leading to a long time of execution and CPU working hard.

@jtorvald
Copy link
Author

@amit-davidson yeah still the same code. Not so big code base:

-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Go                             116           4779           4152          29329

Some -v verbose option would maybe be helpful to see what it is doing and if it is repeating something? But probably the trick is to spit out the exact useful information... since it's probably a lot that it is doing.

@amit-davidson
Copy link
Owner

@jtorvald
Yea it shouldn't fail for that amount of lines. The problem starts with programs including a much higher number of lines of code.
I agree about adding logs and the -v option. For now, I think there's not much to do. I'll add this option and then we'll see exactly what happens.

@jtorvald
Copy link
Author

@amit-davidson cool. Let me know when I can test that! no rush ;-)

@iivanov
Copy link

iivanov commented Jan 28, 2021

Hello. We got the same issue. Any updates regarding to this trouble?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants