-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1x1e12 eq '' #7984
Comments
From fox@scene.plThis is a bug report for perl from fox@scene.pl, The "x" operator gives an unexpected result (i.e. null string) perl580 -le "print 1x1e8 ne '' ? 'ok' : 'not ok'" perl580 -le "print 1x1e9 ne '' ? 'ok' : 'not ok'" perl580 -le "print 1x1e10 ne '' ? 'ok' : 'not ok'" perl580 -le "print 1x1e12 ne '' ? 'ok' : 'not ok'" perl586 -le "print 1x1e8 ne '' ? 'ok' : 'not ok'" perl586 -le "print 1x1e9 ne '' ? 'ok' : 'not ok'" perl586 -le "print 1x1e10 ne '' ? 'ok' : 'not ok'" perl586 -le "print 1x1e12 ne '' ? 'ok' : 'not ok'" Flags: Site configuration information for perl v5.8.0: Configured by ActiveState at Mon Mar 31 00:45:28 2003. Summary of my perl5 (revision 5 version 8 subversion 0) configuration: Locally applied patches: @INC for perl v5.8.0: Environment for perl v5.8.0: |
From @schwernOn Wed, Jun 22, 2005 at 11:24:12AM -0000, Piotr Fusik wrote:
I believe the issue is you're trying to allocate a string of 1 billion
Though I can't explain why this doesn't crash, too. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @salvaMichael G Schwern wrote:
1e9 < 2**31 but 1e10 > 2**31 so it overflows when converted to an IV on Cheers, - Salvador |
From fox@scene.plThis patch fixes the following: perl -le "print 1x1e12 ne '' ? 'ok' : 'not ok'" perl -le "print 1x(1x12) ne '' ? 'ok' : 'not ok'" perl -le "print +(1)x1e12" perl -le "print +(1)x(1x12)" |
From fox@scene.plInline Patchdiff -ruN perl-current/pp.c perl-patched/pp.c
--- perl-current/pp.c Wed Jun 22 14:23:34 2005
+++ perl-patched/pp.c Thu Jun 23 12:14:04 2005
@@ -1399,30 +1399,12 @@
dPOPss;
if (SvGMAGICAL(sv))
mg_get(sv);
- if (SvIOKp(sv)) {
- if (SvUOK(sv)) {
- UV uv = SvUV(sv);
- if (uv > IV_MAX)
- count = IV_MAX; /* The best we can do? */
- else
- count = uv;
- } else {
- IV iv = SvIV(sv);
- if (iv < 0)
- count = 0;
- else
- count = iv;
- }
- }
- else if (SvNOKp(sv)) {
- NV nv = SvNV(sv);
- if (nv < 0.0)
- count = 0;
- else
- count = (IV)nv;
- }
- else
- count = SvIVx(sv);
+
+ SvIV_please(sv);
+ count = SvIVX(sv);
+ if (SvIsUV(sv) && count < 0)
+ count = IV_MAX;
+
if (GIMME == G_ARRAY && PL_op->op_private & OPpREPEAT_DOLIST) {
dMARK;
I32 items = SP - MARK; |
From @rgarciaOn 6/23/05, Piotr Fusik <fox@scene.pl> wrote:
With your patch, I get : $ ./perl -e 'print "-" x undef' The problem coming from the line : count = SvIVX(sv); when sv is &PL_sv_undef. Moreover you shouldn't be setting count = IV_MAX in all cases, I think. |
From pfusik@op.pl
I'm just a beginner, so I don't know the correct way. How about this: count = sv_2iv(sv); This is at least better than it was. Maybe I should use SvIV or SvIVx instead of sv_2iv? But in this case mg_get doesn't get called I'm also aware that using IV_MAX is not the best way, however it seems less harmful than using I32 for items and max. |
From Matthias.Thullner@de.bosch.comisn't this a general problem when the script is trying to allocate more Another example: This command does neither report an error nor print anything to the The problem is, it is very hard to check each command/function in the |
From @jkeenanReviewing this older ticket tonight, I'm inclined to agree with On Wed Jun 22 14:05:10 2005, schwern wrote:
If this viewpoint is correct, I think we should close this ticket. Better thoughts? Thank you very much. |
From @cpansproutOn Tue Mar 27 19:08:51 2012, jkeenan wrote:
I don’t get a crash (which I would probably consider not-a-bug), but an $ perl5.15.9 -le "print 1x1e10 ne '' ? 'ok' : 'not ok'" So it would be worthwhile checking whether this has to do with the rhs And does it work properly on 64-bit systems (i.e., with a 64-bit range)? -- Father Chrysostomos |
From @doyOn Tue, Mar 27, 2012 at 08:44:30PM -0700, Father Chrysostomos via RT wrote:
$ perl -E'say 1x1e10 ne "" ? "ok" : "not ok"' $ perl -E'say 1x1e20 ne "" ? "ok" : "not ok"' $ perl -V Characteristics of this binary (from libperl): -doy |
From @tonycozOn Tue Mar 27 20:44:29 2012, sprout wrote:
It's a general problem with integer handling in perl - NVs are converted An example where conversion to I32 is the problem: $ ./perl -le '@x = "abc"; print $x[0x100000000]' Based on the discussion, I'm rejecting the patch, but I think this is Tony |
From @khwilliamsonOn 07/01/2013 12:50 AM, Tony Cook via RT wrote:
I just tried this on my 64 bit system, and it works; I'm wondering if it
|
From @shlomifOn Sun Mar 01 21:55:06 2015, public@khwilliamson.com wrote:
On my Mageia Linux 4 i586 VirtualBox VM, bleadperl's "./perl -e" prints "not ok" with that command line. Regards, -- Shlomi Fish
|
Migrated from rt.perl.org#36359 (status was 'open')
Searchable as RT36359$
The text was updated successfully, but these errors were encountered: