Re: [Monetdb-developers] [Monetdb-pf-checkins] pathfinder/modules/pftijah pftijah.mx, 1.123, 1.124
Update of /cvsroot/monetdb/pathfinder/modules/pftijah In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10231
Modified Files: pftijah.mx Log Message: - try to repair pftijah "testcoll2" bug on 64bit archs
Index: pftijah.mx =================================================================== RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/pftijah.mx,v retrieving revision 1.123 retrieving revision 1.124 diff -u -d -r1.123 -r1.124 --- pftijah.mx 25 May 2007 12:34:24 -0000 1.123 +++ pftijah.mx 29 May 2007 12:20:18 -0000 1.124 @@ -3267,15 +3267,16 @@ return GDK_FAIL; }
- doc_start = *(oid*)BUNtail(doc_firstpre,r); - oid tj_nextIndex = tj_docIndex + 1; + // 64bit ERROR?? doc_start = *(oid*)BUNtail(doc_firstpre,r); ^^^^^^^^^^^^^ No, a bug in the code: BAT doc_firstpre is [oid,int]., i.e., its tail is int, not oid, and int != oid; ========
On Tue, May 29, 2007 at 12:20:21PM +0000, Jan Flokstra wrote: pathfinder/modules/pftijah/pftijah.mx-73-.COMMAND pf2tijah_node( pathfinder/modules/pftijah/pftijah.mx-74- BAT[oid,str] doc_name, pathfinder/modules/pftijah/pftijah.mx:75: BAT[oid,int] doc_firstpre, ^^^^^^^^^^^^^^^^^^^^^^^^^ pathfinder/modules/pftijah/pftijah.mx-76- BAT[oid,oid] pfpre, pathfinder/modules/pftijah/pftijah.mx-77- BAT[oid,oid] item, pathfinder/modules/pftijah/pftijah.mx-78- BAT[oid,int] kind, pathfinder/modules/pftijah/pftijah.mx-79- BAT[oid,str] doc_loaded) pathfinder/modules/pftijah/pftijah.mx-80- : BAT[void,oid] = CMDpf2tijah_node; pathfinder/modules/pftijah/pftijah.mx-81- "Translate Pathfinder node sequence to tijah node sequence" ======== hence, to access the tail in C, you (obviously!) need to use int doc_start = *(int*) BUNtail(doc_firstpre,r); ^^^ ^^^ if (for what ever reason) doc_start needs to be of type oid instead of int, you need to use oid doc_start = (oid) *(int*) BUNtail(doc_firstpre,r); ^^^ ^^^ ^^^ (as you do below); in fact, you should first check, whether the respective tail value of doc_firstpre is not negative, before you caat it to oid!
+ doc_start = (oid)*(int*)BUNtail(doc_firstpre,r); + oid tj_nextIndex = tj_docIndex + (oid)1; if ( BATcount(doc_firstpre) > tj_nextIndex ) { r = BUNfnd(doc_firstpre,&tj_nextIndex); if ( !r ) { stream_printf(GDKout,"Cannot do range for tijah-firstpre @ %d.\n",tj_docIndex); return GDK_FAIL; } - doc_end = *(oid*)BUNtail(doc_firstpre,r) - 1; + doc_end = *(oid*)BUNtail(doc_firstpre,r) - (oid)1;
NOPE! either int doc_end = *(int*) BUNtail(doc_firstpre,r) - 1; or oid doc_end = (oid) (*(int*) BUNtail(doc_firstpre,r) - 1); plus a check, whether *(int*) BUNtail(doc_firstpre,r) is > 0 ! Stefan
} else { doc_end = oid_nil; }
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Monetdb-pf-checkins mailing list Monetdb-pf-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
On Tuesday 29 May 2007 15:38, Stefan Manegold wrote:
On Tue, May 29, 2007 at 12:20:21PM +0000, Jan Flokstra wrote:
Update of /cvsroot/monetdb/pathfinder/modules/pftijah In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10231
Modified Files: pftijah.mx Log Message: - try to repair pftijah "testcoll2" bug on 64bit archs
Index: pftijah.mx =================================================================== RCS file: /cvsroot/monetdb/pathfinder/modules/pftijah/pftijah.mx,v retrieving revision 1.123 retrieving revision 1.124 diff -u -d -r1.123 -r1.124 --- pftijah.mx 25 May 2007 12:34:24 -0000 1.123 +++ pftijah.mx 29 May 2007 12:20:18 -0000 1.124 @@ -3267,15 +3267,16 @@ return GDK_FAIL; }
- doc_start = *(oid*)BUNtail(doc_firstpre,r); - oid tj_nextIndex = tj_docIndex + 1; + // 64bit ERROR?? doc_start = *(oid*)BUNtail(doc_firstpre,r);
^^^^^^^^^^^^^ No, a bug in the code: BAT doc_firstpre is [oid,int]., i.e., its tail is int, not oid, and int != oid; ========
We were aware of this tail type and that's why we created the cast. Henning was a bit hesitant to change the bat type to [oid,oid] because he expected problems with '<' and '>' so we decided to create the extra cast. The value can never be negative so we never checked for this. We could make it an assert(); Furthermore the text //64bit ERROR was to remind us of our own error on 64bit oid arch's and not an error of monetdb. JanF.
pathfinder/modules/pftijah/pftijah.mx-73-.COMMAND pf2tijah_node( pathfinder/modules/pftijah/pftijah.mx-74- BAT[oid,str] doc_name, pathfinder/modules/pftijah/pftijah.mx:75: BAT[oid,int] doc_firstpre, ^^^^^^^^^^^^^^^^^^^^^^^^^ pathfinder/modules/pftijah/pftijah.mx-76- BAT[oid,oid] pfpre, pathfinder/modules/pftijah/pftijah.mx-77- BAT[oid,oid] item, pathfinder/modules/pftijah/pftijah.mx-78- BAT[oid,int] kind, pathfinder/modules/pftijah/pftijah.mx-79- BAT[oid,str] doc_loaded) pathfinder/modules/pftijah/pftijah.mx-80- : BAT[void,oid] = CMDpf2tijah_node; pathfinder/modules/pftijah/pftijah.mx-81- "Translate Pathfinder node sequence to tijah node sequence" ======== hence, to access the tail in C, you (obviously!) need to use int doc_start = *(int*) BUNtail(doc_firstpre,r); ^^^ ^^^ if (for what ever reason) doc_start needs to be of type oid instead of int, you need to use oid doc_start = (oid) *(int*) BUNtail(doc_firstpre,r); ^^^ ^^^ ^^^ (as you do below); in fact, you should first check, whether the respective tail value of doc_firstpre is not negative, before you caat it to oid!
+ doc_start = (oid)*(int*)BUNtail(doc_firstpre,r); + oid tj_nextIndex = tj_docIndex + (oid)1; if ( BATcount(doc_firstpre) > tj_nextIndex ) { r = BUNfnd(doc_firstpre,&tj_nextIndex); if ( !r ) { stream_printf(GDKout,"Cannot do range for tijah-firstpre @ %d.\n",tj_docIndex); return GDK_FAIL; } - doc_end = *(oid*)BUNtail(doc_firstpre,r) - 1; + doc_end = *(oid*)BUNtail(doc_firstpre,r) - (oid)1;
NOPE! either int doc_end = *(int*) BUNtail(doc_firstpre,r) - 1; or oid doc_end = (oid) (*(int*) BUNtail(doc_firstpre,r) - 1); plus a check, whether *(int*) BUNtail(doc_firstpre,r) is > 0 !
Stefan
} else { doc_end = oid_nil; }
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Monetdb-pf-checkins mailing list Monetdb-pf-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins
On Tue, May 29, 2007 at 04:09:27PM +0200, Jan Flokstra wrote: [...]
We were aware of this tail type and that's why we created the cast. Henning was a bit hesitant to change the bat type to [oid,oid] because he expected problems with '<' and '>' so we decided to create the extra cast.
What kind of problems do you mean? Clean and proper use of types should prevent such problems; "arbitrary" casting calls for such (and other) problems. Hence, choose the proper types at all places, and cast as little as possible. (just my humble advice) Stefan
The value can never be negative so we never checked for this. We could make it an assert(); Furthermore the text //64bit ERROR was to remind us of our own error on 64bit oid arch's and not an error of monetdb.
JanF. [...]
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
participants (2)
-
Jan Flokstra
-
Stefan Manegold