jbrukh / ggit

ggit
17 stars 2 forks source link

Bad file descriptor for pack. #38

Closed jbrukh closed 11 years ago

jbrukh commented 11 years ago

This very well may be my fault because I started effing with your close method, here:

https://github.com/jbrukh/ggit/commit/3b9a5e6cbda613aa077d01468e57318f4f1df2a9

And here:

https://github.com/jbrukh/ggit/commit/dd05b6017b482b6e176bde3cfa08496385bb0a9e (see pack.go)

The error looks like this:

406c8f39ff02:__derefs_packed brukhman$ ggit cat-file -p d7558871ed4242ca7de216a3bdc49140833eb04c^{tree}
Could not read 49 bytes from 273 of pack file /var/folders/c2/scnhksl14mscymh3_f01lb81hb5kp2/T/__derefs_packed/.git/objects/pack/pack-d953427f119fba4d3cfb4f5411537a002940bcb2.pack: read /var/folders/c2/scnhksl14mscymh3_f01lb81hb5kp2/T/__derefs_packed/.git/objects/pack/pack-d953427f119fba4d3cfb4f5411537a002940bcb2.pack: bad file descriptor

Steps to reproduce:

(1) Run the tests or benchmarks so your repo test cases get generated. The fastest way to do this is by running "ggbench" from the dotfiles/bashrc script. Note that benchmarks fail for a particular oid.

(2) Take the path that gets created for the case "__derefs_packed" and go to that directory: this is the git repo that represents the test case.

(3) Try some cat-file on the oid and see the failure above.

jbrukh commented 11 years ago

Here is the bench output... interesting data nonetheless (oid has changed from above):

Benchmark__readLooseBlobByOid      50000         67334 ns/op
Benchmark__readLooseCommitByOid    10000        102299 ns/op
Benchmark__readLooseTreeByOid      50000         66422 ns/op
Benchmark__readLooseBlobByShort    10000        145200 ns/op
Benchmark__readLooseTreeByShort    10000        164868 ns/op
Benchmark__readLooseCommitByShort      10000        192705 ns/op
Benchmark__readPackedBlobByOid     50000         69049 ns/op
Benchmark__readPackedCommitByOid      200000          7680 ns/op
Benchmark__readPackedTreeByOid    200000          8296 ns/op
Benchmark__readPackedCommitByShort    100000         24323 ns/op
Benchmark__readPackedTreeByShort      100000         21975 ns/op
Benchmark__derefLooseTreeFromCommit    10000        215365 ns/op
Benchmark__derefPackedTreeFromCommit    --- FAIL: Benchmark__derefPackedTreeFromCommit
bechmarks_test.go:78:   could not read object: a4a7bf1d437786d868bdb13712e88890854a1771^{tree}
ok      github.com/jbrukh/ggit/api  30.996s
jbrukh commented 11 years ago

This only happens when you do ^{tree}. I'm taking a look at my rev parsing logic for clues.

jbrukh commented 11 years ago

I have fixed this bug with my latest set of patches. I believe the issue was that the rev parsing was trying to resolve packed objects twice and the second time, the file handle ended up being closed, but not nil'ed. In any case, tests and benches are now operational.