Martin Margo | 1 Jul 02:08 2009
Picon

Sample quickstartindex unable to create database on Windows 2008


Hello

My desktop is running Windows 2008 and I used Microsoft Visual Studio 2008 to compile 1.0.13 Xapian and Ruby
bindings. 
I then copy and paste this code from xapian website to my new project and link it with Xapian lib. Everything
builds and links nicely

http://xapian.org/docs/quickstartindex.cc.html

I ran it with the following args
XapianIndex.exe C:\tmp\junk14 "hello hello" hello 

C:\tmp\junk14 exists and empty.

The app crashed. 

First-chance exception at 0x7771f328 in XapianIndex.exe: Microsoft C++ exception:
Xapian::DatabaseCreateError at memory location 0x006bf9d8..
Unhandled exception at 0x7771f328 in XapianIndex.exe: Microsoft C++ exception:
Xapian::DatabaseCreateError at memory location 0x006bf9d8..
The program '[4800] XapianIndex.exe: Native' has exited with code 0 (0x0).

Has anyone encountered this error before? How can I fix it?

Thanks in advance
Olly Betts | 1 Jul 04:30 2009

Re: Sample quickstartindex unable to create database on Windows 2008

On Tue, Jun 30, 2009 at 05:08:33PM -0700, Martin Margo wrote:
> My desktop is running Windows 2008 and I used Microsoft Visual Studio
> 2008 to compile 1.0.13 Xapian and Ruby bindings.  I then copy and
> paste this code from xapian website to my new project and link it with
> Xapian lib. Everything builds and links nicely
> 
> http://xapian.org/docs/quickstartindex.cc.html
> 
> I ran it with the following args
> XapianIndex.exe C:\tmp\junk14 "hello hello" hello 
> 
> C:\tmp\junk14 exists and empty.

And is a directory?  You don't need it to exist, but if it exists and is
a file that won't work.

> The app crashed. 
> 
> First-chance exception at 0x7771f328 in XapianIndex.exe: Microsoft C++
> exception: Xapian::DatabaseCreateError at memory location 0x006bf9d8..
> Unhandled exception at 0x7771f328 in XapianIndex.exe: Microsoft C++
> exception: Xapian::DatabaseCreateError at memory location 0x006bf9d8..
> The program '[4800] XapianIndex.exe: Native' has exited with code 0 (0x0).

It seems to have failed to catch the exception, which is pretty broken.
Are you using any unusual compiler options?

And does "simpleindex" in the example work?

> Has anyone encountered this error before? How can I fix it?
(Continue reading)

Martin Margo | 1 Jul 20:11 2009
Picon

Re: Sample quickstartindex unable to create database on Windows 2008


Thanks for your reply.

C:\tmp\junk14 existed. I deleted the dir and XapianIndex.exe still crashes.

I debugged the program and in database.cc in Xapian code line 205 function 
WritableDatabase::WritableDatabase(const std::string &path, int action) : Database ()

'path' variable is preceeded with weird characters, such as so:
"ÌÌÌÌC:\tmp\junk14"

const std::basic_string<char,std::char_traits<char>,std::allocator<char> > &

While it should have read 'C:\tmp\junk14'. 

Thanks for your help.

Martin

----- Original Message ----
From: Olly Betts <olly <at> survex.com>
To: Martin Margo <martin_margo <at> yahoo.com>
Cc: xapian-devel <at> lists.xapian.org
Sent: Tuesday, June 30, 2009 7:30:09 PM
Subject: Re: [Xapian-devel] Sample quickstartindex unable to create database on  Windows 2008

On Tue, Jun 30, 2009 at 05:08:33PM -0700, Martin Margo wrote:
> My desktop is running Windows 2008 and I used Microsoft Visual Studio
> 2008 to compile 1.0.13 Xapian and Ruby bindings.  I then copy and
> paste this code from xapian website to my new project and link it with
(Continue reading)

Olly Betts | 2 Jul 04:48 2009

Re: Sample quickstartindex unable to create database on Windows 2008

On Wed, Jul 01, 2009 at 11:11:45AM -0700, Martin Margo wrote:
> I debugged the program and in database.cc in Xapian code line 205 function 
> WritableDatabase::WritableDatabase(const std::string &path, int action) : Database ()
> 
> 'path' variable is preceeded with weird characters, such as so:
> "ÌÌÌÌC:\tmp\junk14"
> 
> const std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
> 
> While it should have read 'C:\tmp\junk14'. 

But that is just passed straight in from argv[1] by
quickstartindex.cc...

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.

Cheers,
    Olly
Charlie Hull | 2 Jul 12:43 2009
Picon

Re: Sample quickstartindex unable to create database on Windows 2008

Olly Betts wrote:
> On Wed, Jul 01, 2009 at 11:11:45AM -0700, Martin Margo wrote:
>> I debugged the program and in database.cc in Xapian code line 205 function 
>> WritableDatabase::WritableDatabase(const std::string &path, int action) : Database ()
>>
>> 'path' variable is preceeded with weird characters, such as so:
>> "ÌÌÌÌC:\tmp\junk14"
>>
>> const std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
>>
>> While it should have read 'C:\tmp\junk14'. 
> 
> But that is just passed straight in from argv[1] by
> quickstartindex.cc...
> 
> 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.

Hi all,

I've confirmed this problem on Visual C++ 2005 Express. Debugging inside 
the WritableDatabase constructor:

WritableDatabase::WritableDatabase(const std::string &path, int action)
     : Database()
(Continue reading)

Olly Betts | 3 Jul 06:18 2009

Re: 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"
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.

(Continue reading)

Martin Margo | 8 Jul 20:40 2009
Picon

Re: Sample quickstartindex unable to create database on Windows 2008


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\R
(Continue reading)

Martin Margo | 11 Jul 01:26 2009
Picon

Re: Sample quickstartindex unable to create database on Windows 2008


Mark this thread as solved.

Thanks to people at Microsoft
Forum, I learned std::string class is not binary compatible between my
driver project (VC2008 IDE) and Xapian (built using nmake). I have in
my compile option '_DEBUG'. Once I changed my configuration manager to
'Release/Win32' and transferred proper header and include lib dirs, my
program runs successfully.

Hopefully this will help other people in my position. I'm curious if this change will fix Charlie's problem
as well.

Here's my thread at Microsoft Forum
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/ca90f16f-e893-464f-971c-fed86e0726f5

-Martin

----- 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,
(Continue reading)

Charlie Hull | 11 Jul 17:56 2009
Picon

Re: Sample quickstartindex unable to create database on Windows 2008

Martin Margo wrote:
> 
> Mark this thread as solved.
> 
> Thanks to people at Microsoft
> Forum, I learned std::string class is not binary compatible between my
> driver project (VC2008 IDE) and Xapian (built using nmake). I have in
> my compile option '_DEBUG'. Once I changed my configuration manager to
> 'Release/Win32' and transferred proper header and include lib dirs, my
> program runs successfully.
> 
> Hopefully this will help other people in my position. I'm curious if this change will fix Charlie's
problem as well.
> 
> Here's my thread at Microsoft Forum
> http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/ca90f16f-e893-464f-971c-fed86e0726f5

That's interesting to know. I'd traced the problem as far as pack_uint 
in the Xapian core, which was causing some horrible overflow errors, 
which may have been due to mixing debug and non-debug versions of 
std::string.

Thanks for letting us know.

Cheers

Charlie

> 
> -Martin
(Continue reading)

Olly Betts | 12 Jul 07:31 2009

Re: Sample quickstartindex unable to create database on Windows 2008

On Fri, Jul 10, 2009 at 04:26:26PM -0700, Martin Margo wrote:
> [Binary incompatibility between code compiled with and without _DEBUG]

There are similar issues with GCC and _GLIBCXX_DEBUG which we handle by
generating a check in "include/xapian/version.h" that the setting of
_GLIBCXX_DEBUG is the same as it was when the library was built - e.g.
if you build the library without _GLIBCXX_DEBUG, version.h contains:

#ifdef _GLIBCXX_DEBUG
#error You are compiling with _GLIBCXX_DEBUG defined, but the library
#error was not compiled with this flag. The settings must match or your
#error program will not work correctly.
#endif

It would be nice to have a similar check for _DEBUG under MSVC.

Cheers,
    Olly

Gmane