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

Martin Margo martin_margo at yahoo.com
Wed Jul 8 19:40:28 BST 2009

Steps I took

I put a cout << path << endl; in WritableDatabase function and it prints out correct string even though the debugger says 'path' contains bad pointer.

Next step I took was to build the example simpleindexer from $XAPIANHOME/win32 and run 'nmake'. Once the executable is built, I can run it successfully. 

I copied and paste the source code from simpleindex.cc to my indexer.cc and rebuild (not using nmake but using Visual Studio 2008 IDE) and it builds successfully but I ran into the same problem during runtime. Therefore, maybe the difference lays in the environment between Xapian makefile and Visual Studio 2008 build options/link options.

Here's my VC2008 build option
/Od /I "C:\Users\Martin\Downloads\xapian-core-1.0.13\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt

and link option
/OUT:"C:\Users\Martin\Documents\Visual Studio 2008\XapianIndex\Debug\XapianIndex.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs" /MANIFEST /MANIFESTFILE:"Debug\XapianIndex.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\Users\Martin\Documents\Visual Studio 2008\XapianIndex\Debug\XapianIndex.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT wsock32.lib Ws2_32.lib C:\gnu\lib\zdll.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libcommon.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libbackend.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libexpand.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libflint.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libquartz.lib
 C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libinmemory.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libmulti.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libmatcher.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libnet.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\liblanguages.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libapi.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libremote.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libunicode.lib C:\Users\Martin\Downloads\xapian-core-1.0.13\win32\Release\libs\libqueryparser.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Can anybody spot a glaring mistake? Thanks

----- Original Message ----
From: Olly Betts <olly at survex.com>
To: Charlie Hull <charlie at juggler.net>
Cc: Xapian Development <xapian-devel at lists.xapian.org>
Sent: Thursday, July 2, 2009 9:18:43 PM
Subject: Re: [Xapian-devel] Sample quickstartindex unable to create database on Windows 2008

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"


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

> 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


Xapian-devel mailing list
Xapian-devel at lists.xapian.org

More information about the Xapian-devel mailing list