Skip Menu |

This queue is for tickets about the Heap-Simple-XS CPAN distribution.

Report information
The Basics
Id: 86400
Status: new
Priority: 0/
Queue: Heap-Simple-XS

People
Owner: Nobody in particular
Requestors: lindahl [...] pbm.com
Cc:
AdminCc:

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



Subject: bugs in 5.18
Our engineer porting our search engine to 5.18 had this patch to your module. His checkin comment was, "Heap::Simple::XS does some sketchy things to get an overloadable comparison. one of these is to assume whatever is going on that invoked the XS wants a SCALAR which isn't always the case. make sure that when requesting a comparison we want a scalar" There's also a change related to hash randomization. lindahl@greg-desk Heap-Simple-XS-0.10]$ diff -u -w XS.xs.orig XS.xs --- XS.xs.orig 2013-06-25 01:36:52.000000000 -0700 +++ XS.xs 2013-06-25 01:37:15.000000000 -0700 @@ -10,6 +10,11 @@ #include "ppport.h" #define MAGIC 1 /* Support magic */ +#if PERL_VERSION > 16 +# define STABLE_HASH 0 +#else +# define STABLE_HASH 1 +#endif #ifndef INFINITY # ifdef HUGE_VAL @@ -314,11 +319,17 @@ if (!SvROK(value)) croak("Not a reference"); hv = (HV*) SvRV(value); if (SvTYPE(hv) != SVt_PVHV) croak("Not a HASH reference"); +#if STABLE_HASH he = hv_fetch_ent(hv, h->hkey, 0, h->aindex); +#else + he = hv_fetch_ent(hv, h->hkey, FALSE, 0 ); +#endif if (he) { +#if STABLE_HASH /* HASH value for magical hashes seem to jump around */ if (!h->aindex && !(MAGIC && SvMAGICAL(hv))) h->aindex = HeHASH(he); +#endif return HeVAL(he); } else { return &PL_sv_undef; @@ -380,6 +391,7 @@ static int less(pTHX_ heap h, SV *l, SV *r) { SV *result; I32 start, count; + int cmp; struct op dmy_op, *old_op; dSP; @@ -391,17 +403,28 @@ switch(h->order) { case LESS: /* pp_lt(); */ + old_op = PL_op; + PL_op = &dmy_op; + PL_op->op_type = OP_GT; + PL_op->op_flags = OPf_WANT_SCALAR; PL_ppaddr[OP_LT](aTHXR); + PL_op = old_op; break; case MORE: /* pp_gt(); */ + old_op = PL_op; + PL_op = &dmy_op; + PL_op->op_type = OP_GT; + PL_op->op_flags = OPf_WANT_SCALAR; PL_ppaddr[OP_GT](aTHXR); + PL_op = old_op; break; case LT: /* pp_slt(); */ old_op = PL_op; PL_op = &dmy_op; PL_op->op_type = OP_SLT; + PL_op->op_flags = OPf_WANT_SCALAR; PL_ppaddr[OP_SLT](aTHXR); PL_op = old_op; break; @@ -410,6 +433,7 @@ old_op = PL_op; PL_op = &dmy_op; PL_op->op_type = OP_SGT; + PL_op->op_flags = OPf_WANT_SCALAR; PL_ppaddr[OP_SGT](aTHXR); PL_op = old_op; break;