chrsmithdemos / codesearch

Automatically exported from code.google.com/p/codesearch
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

cindex fails on the first run: mmap() returns EINVAL #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. build all utils (or download binaries from this site)
2. be sure that there is no .csearchindex (or it has zero size)
3. run `cindex /usr/include` or any other path

`cindex` fails, because mmap returns error with EINVAL code.
This happens inside mmap_linux.go, on line 24.
That function (mmapFile) calls mmap with zero size, which fails.
I had manually copy ~/.csearchindex\~ to ~/.csearchindex.
That fixed the issue.

I expected cindex to work right out of the box, even with no .csearchindex.

I'm using:
Gentoo Base System release 2.0.3, Linux 3.1.6, amd64.
Go repository is the newest (built a few minutes ago from head).

Original issue reported on code.google.com by zaitsev....@gmail.com on 19 Jan 2012 at 8:10

GoogleCodeExporter commented 9 years ago
Thanks for the report.  I think cindex does work right out of the box
with no .csearchindex.  The bug you've identified happens if there
_is_ a .csearchindex, but it has size 0.  That's an invalid index,
since among other things it is missing its header.  Maybe you interrupted
a run of cindex and it left a zero-length index behind?

I will fix the code to handle mmap of 0 bytes gracefully and then also
to diagnose the corrupt index in this case.

Original comment by rsc@swtch.com on 20 Jan 2012 at 4:34

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 549d3bf04580.

Original comment by rsc@swtch.com on 20 Jan 2012 at 4:41