amit-davidson / Chronos

Chronos - A static race detector for the go language
MIT License
424 stars 11 forks source link

Another invalid memory address #20

Closed zhouqiang-cl closed 3 years ago

zhouqiang-cl commented 3 years ago

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
amit-davidson commented 3 years ago

Thanks for notifying @zhouqiang-cl . Just a quick update. The panic happens in a different part of the code. Right at the beginning when it loads the package before the analysis even begins. I debugged the code and I saw errors in packages.Load when trying to load the package. They were along this line: could not import <import_name> (no metadata for <import_name>) I'm not sure why it happens and if it problems in Chronos or stdlib packages.Load.

zhouqiang-cl commented 3 years ago

Thanks for notifying @zhouqiang-cl . Just a quick update. The panic happens in a different part of the code. Right at the beginning when it loads the package before the analysis even begins. I debugged the code and I saw errors in packages.Load when trying to load the package. They were along this line: could not import <import_name> (no metadata for <import_name>) I'm not sure why it happens and if it problems in Chronos or stdlib packages.Load.

Thank you @amit-davidson This project is an awesome project, hope I can use someday 😝

amit-davidson commented 3 years ago

@zhouqiang-cl Thank you for your support and patience! It started as a side project so I didn't give it much attention at first and that's why there are many problems with the code. I agree it's awesome :). That's why I'm putting a lot of focus on stabilizing it and adding critical features so hopefully, it'll be ready soon.

amit-davidson commented 3 years ago

@zhouqiang-cl Hey! So had the time to handle this problem and found out it had to with specifying the path where the loading function should operate on. My initial thought was it's enough to pass the file but the module path is needed as well. I fixed the problem in this PR: https://github.com/amit-davidson/Chronos/pull/39 and changed the flags so it means you'll need to run it this way:

./chronos --file /Users/zhouqiang/go/src/github.com/pingcap/tidb/tidb-server/main.go --mod /Users/zhouqiang/go/src/github.com/pingcap/tidb/tidb-server/

I tested it as well and it loads it correctly. My last focus before I release a new version is to improve performance so until that, it'll probably take a long amount of time since tidb-server is a (relatively) big codebase.