Skip to content
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

static assert is failing on windows in PerlIO #16648

Closed
p5pRT opened this issue Aug 3, 2018 · 10 comments
Closed

static assert is failing on windows in PerlIO #16648

p5pRT opened this issue Aug 3, 2018 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 3, 2018

Migrated from rt.perl.org#133422 (status was 'resolved')

Searchable as RT133422$

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2018

From @khwilliamson

This is a bug report for perl from khw@​khw-xps-8930.(none),
generated with the help of perlbug 1.41 running under perl 5.29.2.


In, for example, http​://perl5.test-smoke.org/report/68458, we are getting

scalar.xs​: In function 'PerlIOScalar_read'​:
  ..\..\lib\CORE/perl.h​:3430​:36​: error​: static assertion failed​:
"sizeof(long) >= sizeof(len)"
  ..\..\lib\CORE/perl.h​:3446​:52​: note​: in expansion of macro
'STATIC_ASSERT_DECL'
  scalar.xs​:189​:9​: note​: in expansion of macro 'STATIC_ASSERT_STMT'

The code in scalar.xs, is

  /* I assume that Off_t is at least as large as len (which
  * seems safe) and that the size of the buffer in our SV is
  * always less than half the size of the address space
  */
  STATIC_ASSERT_STMT(sizeof(Off_t) >= sizeof(len));
  assert(len < ((~(STRLEN)0) >> 1));

all quoted lines are from

commit 63d073d
  Author​: Tony Cook <tony@​develop-help.com>
  Date​: Wed Dec 17 13​:32​:43 2014 +1100

  [perl #123443] avoid overflowing got into a negative number


Flags​:
  category=library
  severity=high
  module=PerlIO


Site configuration information for perl 5.29.2

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2018

From @tonycoz

On Fri, 03 Aug 2018 08​:43​:48 -0700, public@​khwilliamson.com wrote​:

In, for example, http​://perl5.test-smoke.org/report/68458, we are getting

scalar.xs​: In function 'PerlIOScalar_read'​:
..\..\lib\CORE/perl.h​:3430​:36​: error​: static assertion failed​:
"sizeof(long) >= sizeof(len)"
..\..\lib\CORE/perl.h​:3446​:52​: note​: in expansion of macro
'STATIC_ASSERT_DECL'
scalar.xs​:189​:9​: note​: in expansion of macro 'STATIC_ASSERT_STMT'

The code in scalar.xs, is

/\* I assume that Off\_t is at least as large as len \(which
 \* seems safe\) and that the size of the buffer in our SV is
 \* always less than half the size of the address space
 \*/
STATIC\_ASSERT\_STMT\(sizeof\(Off\_t\) >= sizeof\(len\)\);
assert\(len \< \(\(~\(STRLEN\)0\) >> 1\)\);

all quoted lines are from

commit 63d073d
Author​: Tony Cook <tony@​develop-help.com>
Date​: Wed Dec 17 13​:32​:43 2014 +1100

  \[perl \#123443\] avoid overflowing got into a negative number

The attached fixes it for me.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2018

From @tonycoz

133422-small-off_t.patch
From bdac76d8b892a8d78b71020356f53ee203d66a32 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 8 Aug 2018 14:21:33 +1000
Subject: (perl #133422) handle Off_t smaller than size_t

---
 ext/PerlIO-scalar/scalar.xs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs
index 10a4185899..e717736fab 100644
--- a/ext/PerlIO-scalar/scalar.xs
+++ b/ext/PerlIO-scalar/scalar.xs
@@ -185,11 +185,20 @@ PerlIOScalar_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
         /* I assume that Off_t is at least as large as len (which 
          * seems safe) and that the size of the buffer in our SV is
          * always less than half the size of the address space
+         *
+         * Which turns out not to be the case on 64-bit Windows, since
+         * a build with USE_LARGE_FILES=undef defines Off_t as long,
+         * which is 32-bits on 64-bit Windows.  This doesn't appear to
+         * be the case on other 64-bit platforms.
          */
-        STATIC_ASSERT_STMT(sizeof(Off_t) >= sizeof(len));
+#if Off_t_size >= Size_t_size
         assert(len < ((~(STRLEN)0) >> 1));
         if ((Off_t)len <= s->posn)
 	    return 0;
+#else
+        if (len <= (STRLEN)s->posn)
+            return 0;
+#endif
 	got = len - (STRLEN)(s->posn);
 	if ((STRLEN)got > (STRLEN)count)
 	    got = (STRLEN)count;
-- 
2.11.0


From 3af0f3b7953b29c53ece75b9a22bdb3d47a4993a Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 8 Aug 2018 15:44:42 +1000
Subject: bump $PerlIO::scalar::VERSION

---
 ext/PerlIO-scalar/scalar.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/PerlIO-scalar/scalar.pm b/ext/PerlIO-scalar/scalar.pm
index 61b62ea3a2..6f4fa176be 100644
--- a/ext/PerlIO-scalar/scalar.pm
+++ b/ext/PerlIO-scalar/scalar.pm
@@ -1,5 +1,5 @@
 package PerlIO::scalar;
-our $VERSION = '0.29';
+our $VERSION = '0.30';
 require XSLoader;
 XSLoader::load();
 1;
-- 
2.11.0

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2018

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2018

From @khwilliamson

Fixed by commit
ce6f496
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2018

@khwilliamson - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2018

From @khwilliamson

Oops, I should have said
b9965e1
was the commit number for the patch furnished by Tony
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2018

From [Unknown Contact. See original ticket]

Oops, I should have said
b9965e1
was the commit number for the patch furnished by Tony
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented May 22, 2019

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.30.0, this and 160 other issues have been
resolved.

Perl 5.30.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.30.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 22, 2019

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant