Front page | perl.perl5.porters |
Postings from May 2007
Re: Should SvEND(sv) assert SvPOKp(sv)? (was Re: [PATCH] Math::BigInt::FastCalc v0.15)
Thread Previous
|
Thread Next
From:
Tels
Date:
May 28, 2007 14:50
Subject:
Re: Should SvEND(sv) assert SvPOKp(sv)? (was Re: [PATCH] Math::BigInt::FastCalc v0.15)
Message ID:
200705282344.40637@bloodgate.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Moin,
On Monday 28 May 2007 20:19:34 Nicholas Clark wrote:
> On Mon, May 28, 2007 at 02:02:34PM +0000, Tels wrote:
> > And this:
> >
> > end = SvPV(x, len);
> > end += len;
> > cur = SvEND(x);
> > if (end != cur)
> > {
> > printf ("end: %p, cur: %p\n", cur, end);
> > sv_dump(x);
> > }
> >
> > produces this:
> >
> > # perl -Ilib -Iblib/arch t.pl
> > end: 0xb16ac0, cur: 0x669a32
> > SV = PVIV(0x9c7d20) at 0x786590
> > REFCNT = 1
> > FLAGS = (PADBUSY,PADMY,ROK,OVERLOAD)
> > IV = 0
> > RV = 0xb16ac0
> > PV = 0xb16ac0 ""
> > CUR = 0
> > LEN = 0
> > Argument "\0\0" isn't numeric in addition (+)
> > at /usr/lib/perl5/5.8.8/Math/BigInt/Calc.pm line 281.
> > end: 0xb16ac0, cur: 0x669a12
> > SV = PVIV(0x9c7d20) at 0x786590
> > REFCNT = 1
> > FLAGS = (PADBUSY,PADMY,ROK,OVERLOAD)
> > IV = 0
> > RV = 0xb16ac0
> > PV = 0xb16ac0 ""
> > CUR = 0
> > LEN = 0
> > Argument "\0\0" isn't numeric in numeric eq (==)
> > at /usr/lib/perl5/5.8.8/Math/BigInt/Calc.pm line 304.
> >
> > Hm. So I should have checked for SvPOK() before accessing SvEND() I
> > guess.
>
> Yes. Or, more correctly, I think, just not use it in the general case.
>
> I wondered whether SvEND() should assert that SvPOKp() is set.
Well, if that catches bugs like mine, that would be good. OTOH, I am still
unsure what my code should do with the given SV anyways. Would be SvCUR() +
SvLEN() to access the end be even correct?
> But to do so required 3 tweaks to sv.c, and all this (which is basically
> moving SvPOK_only() to the line before SvEND())
>
> So I'm not sure if it is a great idea, as it will mean that some
> non-buggy code on CPAN will need tweaking. But in return it would catch
> misuse of SvEND() in buggy code.
I cannot comment yet on that as I know not enough. Is my code buggy, or just
right-for-certain-inputs? Can you explain this in a bit more details, esp.
regarding the OVERLOAD flag.
All the best,
Tels
- --
Signed on Mon May 28 23:42:22 2007 with key 0x93B84C15.
Get one of my photo posters: http://bloodgate.com/posters
PGP key on http://bloodgate.com/tels.asc or per email.
"Zudem könnten nun nicht mehr nur Täter, sondern auch Opfer abgehört
werden, um diese besser zu schützen."
-- Jörg Bode, FDP (http://heise.de/newsticker/data/anw-11.12.03-003/)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iQEVAwUBRltpaHcLPEOTuEwVAQIZDAf+PhouXldedaACW1/1ehGfCgzFpuV8LMAX
USd96h2GZC9dMXMdbY6ksUFib098RmObNRa+/uC6ehhsGVldlCDuz8IzhjXYkrYc
76I7/HFB5CNMR+gyvnkCLeGiICZPLGNXfdcy+sv0o4gnE2oLyUVj0hqPmZR5W8Nx
Vb1ObOPakDm6Uqnu3bP2jYLC1Kp+SlpYbtB/g6PkMjxhQ302t0ihVyo/Ws3VvM/k
ieT1UagIVHqBABu/LJ/DBlSyxxQhHK7D68BVDSWe5pE1pCkiDxUlVEUMwiPKQCqx
Z4CJLA3Ll7lkJF+RVVmK1LzaKgfkCiBJpJj64FvsD4Z0QZIoiCKD4A==
=L8Ze
-----END PGP SIGNATURE-----
Thread Previous
|
Thread Next