[Xapian-devel] Sample quickstartindex unable to create database on Windows 2008

Olly Betts olly at survex.com
Fri Jul 3 05:18:43 BST 2009


On Thu, Jul 02, 2009 at 11:43:03AM +0100, Charlie Hull wrote:
> Olly Betts wrote:
> > What is argv[1] as passed to quickstartindex?
> > 
> > And what are these 4 bytes exactly?  They're showing up as 0xcc here,
> > but it's not clear if they've been mangled from their original values.
> > 
> > Or are you looking at the raw data inside the string class?  That would
> > probably have the length followed by the string data.
> 
> I've confirmed this problem on Visual C++ 2005 Express. Debugging inside 
> the WritableDatabase constructor:
> 
> WritableDatabase::WritableDatabase(const std::string &path, int action)
>      : Database()
> {
> The debugger shows 'path' is a '<Bad Ptr>'. Somehow VC++ doesn't like 
> passing const references to std::strings in this way.

It can't be that simple or else very little of Xapian would work, and
indeed a lot of other C++ software would fail as passing std::string
by const reference is very common.  This finds "about 281,000"
occurrences:

http://www.google.com/codesearch?q=\(const\+(std%3A%3A)%3Fstring\+*%26

It would be good to see what adding "cout << path << endl;" to the
WritableDatabase constructor gave, as that would help rule out this
being bad debug info.

> BTW copying argv[1] into a temporary buffer to make sure it's definitely 
> zero terminated etc., then making a new std::string round it, then 
> passing a reference to that doesn't help.

OK, but what *is* argv[1] (as I asked above)?  It would be useful to
check that the 4 garbage bytes didn't get added already somehow.

And can you reproduce this in a cut down example without Xapian
involved?

> I'm wondering (though not with any real evidence) if 
> http://trac.xapian.org/ticket/140
> has any relevance.

No, that was just about which is more efficient, and it turns out that
const reference seems to be regardless of how std::string is
implemented.

Cheers,
    Olly



More information about the Xapian-devel mailing list