Add script for checking thread locks in funcs that call MakeGitError #138

Merged
sqs merged 2 commits from check-MakeGitError-thread-lock into master 2014-12-08 17:47:41 -06:00
sqs commented 2014-11-18 07:25:29 -06:00 (Migrated from github.com)

This PR adds script/check-MakeGitError-thread-lock.go, which checks for funcs that call MakeGitError and that don't lock the OS thread. Its implementation is a simple string.Contains check on each *ast.FuncDecl. It also adds this script to make test.

These funcs should be fixed before this PR is merged.

The current output is:

28 non-thread-locked calls to MakeGitError found. To fix, add the following to each func below that calls MakeGitError, before the cgo call that might produce the error:

    runtime.LockOSThread()
    defer runtime.UnlockOSThread()

Patch at diff.go:261
DefaultDiffOptions at diff.go:326
DiffTreeToTree at diff.go:377
DiffTreeToWorkdir at diff.go:430
MergeHeadFromFetchHead at merge.go:33
MergeHeadFromId at merge.go:50
MergeHeadFromRef at merge.go:61
DefaultMergeOptions at merge.go:99
SetInt32 at config.go:234
Next at config.go:350
NewOdb at odb.go:25
AddBackend at odb.go:42
ForEach at odb.go:107
NewReadStream at odb.go:141
NewWriteStream at odb.go:155
Read at odb.go:206
Write at odb.go:237
Close at odb.go:252
NewRepositoryWrapOdb at repository.go:72
CreateTag at repository.go:373
ListRemotes at remote.go:250
Fetch at remote.go:543
Ls at remote.go:587
ForEach at packbuilder.go:129
NewRefdb at refdb.go:23
SetBackend at refdb.go:40
Next at reference.go:295
String at patch.go:38

Ref https://github.com/libgit2/git2go/issues/137

This PR adds script/check-MakeGitError-thread-lock.go, which checks for funcs that call MakeGitError and that don't lock the OS thread. Its implementation is a simple `string.Contains` check on each `*ast.FuncDecl`. It also adds this script to `make test`. These funcs should be fixed before this PR is merged. The current output is: ``` 28 non-thread-locked calls to MakeGitError found. To fix, add the following to each func below that calls MakeGitError, before the cgo call that might produce the error: runtime.LockOSThread() defer runtime.UnlockOSThread() Patch at diff.go:261 DefaultDiffOptions at diff.go:326 DiffTreeToTree at diff.go:377 DiffTreeToWorkdir at diff.go:430 MergeHeadFromFetchHead at merge.go:33 MergeHeadFromId at merge.go:50 MergeHeadFromRef at merge.go:61 DefaultMergeOptions at merge.go:99 SetInt32 at config.go:234 Next at config.go:350 NewOdb at odb.go:25 AddBackend at odb.go:42 ForEach at odb.go:107 NewReadStream at odb.go:141 NewWriteStream at odb.go:155 Read at odb.go:206 Write at odb.go:237 Close at odb.go:252 NewRepositoryWrapOdb at repository.go:72 CreateTag at repository.go:373 ListRemotes at remote.go:250 Fetch at remote.go:543 Ls at remote.go:587 ForEach at packbuilder.go:129 NewRefdb at refdb.go:23 SetBackend at refdb.go:40 Next at reference.go:295 String at patch.go:38 ``` Ref https://github.com/libgit2/git2go/issues/137
carlosmn commented 2014-12-05 20:04:49 -06:00 (Migrated from github.com)

I've fixed the instanced pointed out by the script, but the script always errors out on go 1.1 because it seems to want to parse the C file.

I assume there's a way to work around that, but I'm not familiar with the parser package.

I've fixed the instanced pointed out by the script, but the script always errors out on go 1.1 because it seems to want to parse the C file. I assume there's a way to work around that, but I'm not familiar with the parser package.
sqs commented 2014-12-08 15:43:31 -06:00 (Migrated from github.com)

I updated the script to work with Go 1.1, and the Travis CI build now passes.

I updated the script to work with Go 1.1, and the Travis CI build now passes.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jcarr/git2go#138
No description provided.