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

scc --no-duplicates crashes if file is empty #260

Closed
fluggo opened this issue May 11, 2021 · 4 comments
Closed

scc --no-duplicates crashes if file is empty #260

fluggo opened this issue May 11, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@fluggo
Copy link

fluggo commented May 11, 2021

Describe the bug

SCC crashes with a nil pointer dereference in processor/workers.go line 450 if --no-duplicates is specified and one of the files is empty. This is because CountStats skips initializing the hash object if the file is empty.

To Reproduce

$ mkdir test && cd test
$ touch go.c
$ scc --no-duplicates
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x1222b51]

goroutine 11 [running]:
github.com/boyter/scc/v3/processor.processFile(0xc0000da000, 0xc000096048)
        /Users/fluggo/software/extern/scc/processor/workers.go:450 +0x171
github.com/boyter/scc/v3/processor.fileProcessorWorker.func1(0xc000028540, 0xc00037e2b0, 0xc00037e2b8, 0xc00037e2c0, 0xc000028600, 0xc00037e2d0)
        /Users/fluggo/software/extern/scc/processor/workers.go:375 +0x30b
created by github.com/boyter/scc/v3/processor.fileProcessorWorker
        /Users/fluggo/software/extern/scc/processor/workers.go:346 +0xfc
$ echo thing > go.c
$ scc --no-duplicates
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
C                            1         1        0         0        1          0
───────────────────────────────────────────────────────────────────────────────
Total                        1         1        0         0        1          0
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $19
Estimated Schedule Effort (organic) 0.221524 months
Estimated People Required (organic) 0.007670
───────────────────────────────────────────────────────────────────────────────
Processed 6 bytes, 0.000 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

Desktop (please complete the following information):

  • OS: macOS Catalina 10.15.7
@boyter boyter added the bug Something isn't working label May 13, 2021
@boyter
Copy link
Owner

boyter commented May 13, 2021

Oh that's not good. Investigating now.

@boyter boyter closed this as completed in cb04a8d May 13, 2021
@boyter
Copy link
Owner

boyter commented May 13, 2021

Fix sitting in master for it with a integration test.

@fluggo
Copy link
Author

fluggo commented May 14, 2021

Verified. Thank you!

@boyter
Copy link
Owner

boyter commented May 16, 2021

Neat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants