databases/mongodb fails to start, assertion failure in unit test

Waitman Gobble uzimac at da3m0n8t3r.com
Mon Jan 28 17:13:54 UTC 2013


Wesley Shields <wxs at FreeBSD.org> wrote ..
> On Sat, Jan 26, 2013 at 07:06:21AM -0800, Waitman Gobble wrote:
> > Waitman Gobble <uzimac at da3m0n8t3r.com> wrote ..
> > > 
> > > Hi,
> > > 
> > > I've installed databases/mongodb and get an error when starting.
> > > 
> > > # /usr/local/etc/rc.d/mongod start
> > > Starting mongod.
> > > forked process: 59576
> > > all output going to: /var/db/mongodb/mongod.log
> > > /usr/local/etc/rc.d/mongod: WARNING: failed to start mongod
> > > 
> > > # cat /var/db/mongodb/mongod.log
> > > 
> > > Fri Jan 25 00:30:57   Assertion failure l < bigl src/mongo/db/btree.cpp 1973
> > > 0x5a503d 0x5eb41d 0x74dce9 0x547638 0x545ed9 0x542bc1 
> > >  0x5a503d <_ZN5mongo12verifyFailedEPKcS1_j+285> at /usr/local/bin/mongod
> > >  0x5eb41d <_ZN5mongo10BTUnitTest3runEv+333> at /usr/local/bin/mongod
> > >  0x74dce9 <_ZN5mongo11StartupTest8runTestsEv+57> at /usr/local/bin/mongod
> > >  0x547638 <main+5992> at /usr/local/bin/mongod
> > >  0x545ed9 <main+9> at /usr/local/bin/mongod
> > >  0x542bc1 <_start+145> at /usr/local/bin/mongod
> > > Fri Jan 25 00:30:57 Got signal: 6 (Abort trap: 6).
> > > 
> > > 
> > >     
> > > # portversion -v mongodb
> > > mongodb-2.2.0_1             =  up-to-date with port
> > > 
> > > # uname -a
> > > FreeBSD kamira.waitman.net 9.1-STABLE FreeBSD 9.1-STABLE #0 r245772M: Tue Jan
> 22
> > > 06:09:00 PST 2013     root at kamira.waitman.net:/usr/obj/usr/src/sys/BURPLEX
> amd64
> > > 
> > >     
> > > I added a couple lines to print the values before the failure.
> > > 
> > > 
> > > src/mongo/db/btree.h
> > > 
> > > ..
> > > 
> > >     struct BTUnitTest : public StartupTest {
> > >         void run() {
> > >             DiskLoc big(0xf12312, 0x70001234);
> > >             DiskLoc56Bit bigl;
> > >             {
> > >                 bigl = big;
> > >                 verify( big == bigl );
> > >                 DiskLoc e = bigl;
> > >                 verify( big == e );
> > >             }
> > >             {
> > >                 DiskLoc d;
> > >                 verify( d.isNull() );
> > >                 DiskLoc56Bit l;
> > >                 l = d;
> > >                 verify( l.isNull() );
> > >                 d = l;
> > >                 verify( d.isNull() );
> > > 
> > > printf("bigl %s\n",bigl.toString().c_str());
> > > printf("l %s\n",l.toString().c_str());
> > > 
> > >                 verify( l < bigl );
> > >             }
> > >         }
> > >     } btunittest;
> > > ..
> > > 
> > > 
> > > output:
> > >    
> > > bigl f12312:70001234
> > > l null
> > > Thu Jan 24 23:18:17   Assertion failure l < bigl src/mongo/db/btree.cpp 1978
> > >    
> > > 
> > > looking at    
> > > src/mongo/db/diskloc.h
> > >    
> > >     bool isNull() const { return _a == -1; }
> > > ..   
> > >     int compare(const DiskLoc& b) const {
> > >             int x = _a - b._a;
> > >             if ( x )
> > >                 return x;
> > >             return ofs - b.ofs;
> > >         }
> > >         bool operator<(const DiskLoc& b) const {
> > >             return compare(b) < 0;
> > >         }
> > > ..
> > >         void Null() {
> > >             _a = -1;
> > >             ofs = 0; /* note NullOfs is different. todo clean up.  see refs
> to
> > > NullOfs in code - use is valid but outside DiskLoc context so confusing as-is.
> > > */
> > >         }
> > > 
> > > 
> > >    
> > > it seems that this should be working!
> > > 
> > > test model:
> > > 
> > > #include <stdio.h>
> > > 
> > > int
> > > compare (int a, int b)
> > > {
> > >         int x = a - b;
> > >             if ( x )
> > >                 return x;
> > >         return 555;
> > > }
> > > 
> > > bool
> > > ncompare (int a, int b)
> > > {
> > >         return compare(a,b) < 0;
> > > }
> > > 
> > > int
> > > main (void)
> > > {
> > >         int a, b;
> > >         a = -1;
> > >         b = 0xf12312;
> > >         int c = a - b;
> > >         printf("%d\n",c);
> > >         c = compare(a,b);
> > >         printf("%d\n",c);
> > >         bool d = ncompare(a,b);
> > >         printf("%d\n",d);
> > >         bool e = ncompare(b,a);
> > >         printf("%d\n",e);
> > >         return 0;
> > > }
> > > 
> > > # clang++ -o test test.cpp
> > > # ./test
> > > -15803155
> > > -15803155
> > > 1
> > > 0
> > > 
> > > 
> > > I'm missing something...
> > >  
> > > Suggestions, tips, hints much appreciated. 
> > > 
> > > Thanks,
> > > 
> > > -- 
> > > Waitman Gobble
> > > San Jose California USA
> > 
> > Hi,
> > 
> > I've tinkered around with this problem. Commenting out the 'verify( l
> > < bigl );' line in src/mongo/db/btree.h solves the assertion failure
> > problem, and mongodb starts and runs. However, after reviewing the
> > code it seems this 'start' unit test is only actually testing if the
> > thing can 'subtract integers.' I'm very puzzled as to why it is
> > failing, it's bombing out when it does 'verify ((-1 - 0xf12312)<0)'.
> > which seems trivial.
> > 
> > The code that runs the unit test/StartupTest is simple, but i haven't
> > yet found the 'verify' macro, at least i believe it's a macro. 
> > 
> > Anyhow, commenting out the test line gets mongodb running, but I'm
> > wondering what other problems there could be. (?) 
> > 
> > I found that compiling with base gcc avoids the startup problem, so
> > this indeed seems to be an issue related to building with clang. clang
> > builds mongodb without error, however running the mongodb compiled
> > with clang fails during 'startuptest'. 
> > 
> > IMHO It would be good to track down the problem, at least understand
> > the cause, but at this moment it seems like compiling mongodb with gcc
> > is the way to go.
> > 
> > I've updated the port to use the latest release/ 2.2.2 version of
> > mongodb, I'll submit a PR in a bit, (it does not appear to have been
> > submitted already) maybe somebody wants to use it. (The startup
> > assertion failure affects the existing port '2.2.0' as well as 2.2.2)
> 
> Please CC me on the PR as I would like to get that in the tree.
> 
> As for the clang problem, I think this might be something to take up
> with the mongodb developers.
> 
> -- WXS


Hi Wesley,

Sorry for the delay,

Here's the PR for mongodb server
http://www.freebsd.org/cgi/query-pr.cgi?pr=175608

Also, related - I added two new ports,

C Driver
http://www.freebsd.org/cgi/query-pr.cgi?pr=175613
 
CXX Driver
http://www.freebsd.org/cgi/query-pr.cgi?pr=175616

I thought about it more yesterday, I think the CXX probably needs more work. I realized I linked to 'latest' and it could likely change, which would wreck the distinfo hash. Also I have a replacement 'modified' SConstruct for the CXX driver I did several months ago that gives more compile options, ie clang, and this could be integrated into the port. The SConstruct in the CXX driver is very limited in functionality.

I agree with what you say re: clang problem, I'd like to spend a little more time trying to understand the exact cause of issue first. I've posted the issue on the mongodb mailing list, so far without response, however generally the developers are responsive.

Thanks,


-- 
Waitman Gobble
San Jose California USA



More information about the freebsd-ports mailing list