Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the MongoDB CPAN distribution.

Maintainer(s)' notes

Please don't report bugs here. Please use the MongoDB Perl driver issue tracker instead.

Report information
The Basics
Id: 52648
Status: resolved
Priority: 0/
Queue: MongoDB

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.26
Fixed in: (no value)



Subject: MongoDB 0.26 and Perl 5.8.7, Newx(z) with 3 args
Hello and thank you for MongoDB 0.26, I'm running Perl 5.8.7 (on x86_64-linux) Running make produces: cc -c -I. -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -DVERSION=\"0.26\" -DXS_VERSION=\"0.26\" -o xs/Connection.o -fpic "-I<removed>perl-5.8.7/lib/5.8.7/x86_64-linux/CORE" xs/Connection.c xs/Connection.xs: In function `XS_MongoDB__Connection_connect': xs/Connection.xs:52: error: syntax error before "mongo_link" xs/Connection.xs:63: error: syntax error before "char" xs/Connection.xs:68: error: syntax error before "char" xs/Connection.xs:75: error: syntax error before "char" xs/Connection.xs: In function `XS_MongoDB__Connection__insert': xs/Connection.xs:118: error: syntax error before "char" xs/Connection.xs: In function `XS_MongoDB__Connection__remove': xs/Connection.xs:147: error: syntax error before "char" xs/Connection.xs: In function `XS_MongoDB__Connection__update': xs/Connection.xs:170: error: syntax error before "char" make: *** [xs/Connection.o] Error 1 Line 52 of xs/Connection.xs is: Newx(link, 1, mongo_link); I'm using version 2.21 of ExtUtils::ParseXS Line 122 of xs/Connection.c is: Newx(link, 1, mongo_link); According to http://perldoc.perl.org/perlapi.html In 5.9.3, Newx() and friends replace the older New() API, and drops the first parameter, x, a debug aid which allowed callers to identify themselves. Looking at perlapi for 5.8.7 (http://search.cpan.org/~nwclark/perl-5.8.7/pod/perlapi.pod) I see: New The XSUB-writer's interface to the C malloc function. void New(int id, void* ptr, int nitems, type) No mention of Newx, so I changed line 52 of xs/Connection.xs to: New(0, link, 1, mongo_link); and this seemed to work, I also made the following changes: MongoDB-0.26/mongo_link.c 245c245 Show quoted text
> New(0, cursor->buf.start, cursor->header.length, char);
--- < Newx(cursor->buf.start, cursor->header.length, char); MongoDB-0.26/mongo_link.h 88c88 Show quoted text
> New(0, buf.start, size, char); \
--- < Newx(buf.start, size, char); \ MongoDB-0.26/xs/Connection.xs 52c52 Show quoted text
> New(0, link, 1, mongo_link);
--- < Newx(link, 1, mongo_link); 63c63 Show quoted text
> Newz(0, link->server.pair.left_host, llen+1, char);
--- < Newxz(link->server.pair.left_host, llen+1, char); 68c68 Show quoted text
> Newz(0, link->server.pair.right_host, rlen+1, char);
--- < Newxz(link->server.pair.right_host, rlen+1, char); 75c75 Show quoted text
> Newz(0, link->server.single.host, len+1, char);
--- < Newxz(link->server.single.host, len+1, char); MongoDB-0.26/xs/Cursor.xs 115,116c115 Show quoted text
> New(0, buf.start, size, char);
--- < Newx(buf.start, size, char); 190c189 Show quoted text
> New(0, cursor, 1, mongo_cursor);
--- < Newx(cursor, 1, mongo_cursor); make now completes without error and make test when running against the stable version of mongod just fails 4 tests in t/collection.t (I have not looked into these failures yet) not ok 74 # Failed test at t/collection.t line 256. # got: '1' # expected: '2' ok 75 not ok 76 # Failed test at t/collection.t line 263. # got: undef # expected: '4' not ok 77 # Failed test at t/collection.t line 267. # got: '1' # expected: '2' ok 78 not ok 79 # Failed test at t/collection.t line 274. # got: undef # expected: '4' I've not tested the change with any other version of perl. Hope this is of some use. Cheers, Peter (Stig) Edwards
Thanks for the patch! I've credited you in the Changes file. The tests that failed look like they're caused by running an "old" database (pre-1.1.3). I'll try to fix the tests to skip ones that require a newer version of the db than the user has. On Thu Dec 10 04:55:51 2009, cpan@pjedwards.co.uk wrote: Show quoted text
> Hello and thank you for MongoDB 0.26, > > I'm running Perl 5.8.7 (on x86_64-linux) > > Running make produces: > > cc -c -I. -fno-strict-aliasing -pipe -I/usr/local/include > -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 > -DVERSION=\"0.26\" -DXS_VERSION=\"0.26\" -o xs/Connection.o -fpic > "-I<removed>perl-5.8.7/lib/5.8.7/x86_64-linux/CORE" xs/Connection.c > xs/Connection.xs: In function `XS_MongoDB__Connection_connect': > xs/Connection.xs:52: error: syntax error before "mongo_link" > xs/Connection.xs:63: error: syntax error before "char" > xs/Connection.xs:68: error: syntax error before "char" > xs/Connection.xs:75: error: syntax error before "char" > xs/Connection.xs: In function `XS_MongoDB__Connection__insert': > xs/Connection.xs:118: error: syntax error before "char" > xs/Connection.xs: In function `XS_MongoDB__Connection__remove': > xs/Connection.xs:147: error: syntax error before "char" > xs/Connection.xs: In function `XS_MongoDB__Connection__update': > xs/Connection.xs:170: error: syntax error before "char" > make: *** [xs/Connection.o] Error 1 > > Line 52 of xs/Connection.xs is: > > Newx(link, 1, mongo_link); > > I'm using version 2.21 of ExtUtils::ParseXS > > Line 122 of xs/Connection.c is: > > Newx(link, 1, mongo_link); > > According to http://perldoc.perl.org/perlapi.html In 5.9.3, Newx() and > friends replace the older New() API, and drops the first parameter, x, a > debug aid which allowed callers to identify themselves. Looking at > perlapi for 5.8.7 > (http://search.cpan.org/~nwclark/perl-5.8.7/pod/perlapi.pod) I see: > > New > The XSUB-writer's interface to the C malloc function. > void New(int id, void* ptr, int nitems, type) > > No mention of Newx, so I changed line 52 of xs/Connection.xs to: > > New(0, link, 1, mongo_link); > > and this seemed to work, I also made the following changes: > > MongoDB-0.26/mongo_link.c > 245c245
> > New(0, cursor->buf.start, cursor->header.length, char);
> --- > < Newx(cursor->buf.start, cursor->header.length, char); > > MongoDB-0.26/mongo_link.h > 88c88
> > New(0, buf.start, size, char); \
> --- > < Newx(buf.start, size, char); \ > > MongoDB-0.26/xs/Connection.xs > 52c52
> > New(0, link, 1, mongo_link);
> --- > < Newx(link, 1, mongo_link); > 63c63
> > Newz(0, link->server.pair.left_host, llen+1, char);
> --- > < Newxz(link->server.pair.left_host, llen+1, char); > 68c68
> > Newz(0, link->server.pair.right_host, rlen+1, char);
> --- > < Newxz(link->server.pair.right_host, rlen+1, char); > 75c75
> > Newz(0, link->server.single.host, len+1, char);
> --- > < Newxz(link->server.single.host, len+1, char); > > MongoDB-0.26/xs/Cursor.xs > 115,116c115
> > New(0, buf.start, size, char);
> --- > < Newx(buf.start, size, char); > 190c189
> > New(0, cursor, 1, mongo_cursor);
> --- > < Newx(cursor, 1, mongo_cursor); > > make now completes without error and make test when running against the > stable version of mongod just fails 4 tests in t/collection.t (I have > not looked into these failures yet) > > not ok 74 > # Failed test at t/collection.t line 256. > # got: '1' > # expected: '2' > ok 75 > not ok 76 > # Failed test at t/collection.t line 263. > # got: undef > # expected: '4' > not ok 77 > # Failed test at t/collection.t line 267. > # got: '1' > # expected: '2' > ok 78 > not ok 79 > # Failed test at t/collection.t line 274. > # got: undef > # expected: '4' > > I've not tested the change with any other version of perl. > > Hope this is of some use. > > Cheers, > Peter (Stig) Edwards
Thank you. Just FYI my compiler (using Relaxed_ANSI) noticed in perl_mongo.c in perl_mongo_serialize_oid the lines: digit1 = digit1 >= 'a' && digit1 <= 'f' ? digit1 -= 87 : digit1; digit1 = digit1 >= 'A' && digit1 <= 'F' ? digit1 -= 55 : digit1; digit1 = digit1 >= '0' && digit1 <= '9' ? digit1 -= 48 : digit1; digit2 = digit2 >= 'a' && digit2 <= 'f' ? digit2 -= 87 : digit2; digit2 = digit2 >= 'A' && digit2 <= 'F' ? digit2 -= 55 : digit2; digit2 = digit2 >= '0' && digit2 <= '9' ? digit2 -= 48 : digit2; produce the warning: In this statement, the expression "digit1=digit1>='a'&&digit1<='f'?digit1-=87:digit1" modifies the variable "digit1" more than once without an intervening sequence point. This behavior is undefined. I changed them to: digit1 = digit1 >= 'a' && digit1 <= 'f' ? digit1 - 87 : digit1; digit1 = digit1 >= 'A' && digit1 <= 'F' ? digit1 - 55 : digit1; digit1 = digit1 >= '0' && digit1 <= '9' ? digit1 - 48 : digit1; digit2 = digit2 >= 'a' && digit2 <= 'f' ? digit2 - 87 : digit2; digit2 = digit2 >= 'A' && digit2 <= 'F' ? digit2 - 55 : digit2; digit2 = digit2 >= '0' && digit2 <= '9' ? digit2 - 48 : digit2;