Skip to content

Fix tests on 32-bit Windows OS #8448

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

Closed
wants to merge 5 commits into from

Conversation

mvorisek
Copy link
Contributor

discovered during GH-8392 devel

see comments for the decisions

@@ -1,18 +0,0 @@
--TEST--
Bug #77269 (Potential unsigned underflow in gdImageScale)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate of ext/gd/tests/bug77272.phpt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, not exactly (this test is supposed to work with pretty old GD, but the other only for somewhat recent versions), but I think it's okay to drop bug77269.phpt now, but for "master" only.

@@ -2,9 +2,6 @@
Test simple recursive watchpoint
--SKIPIF--
<?php
if (PHP_INT_SIZE == 4) {
Copy link
Contributor Author

@mvorisek mvorisek Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fixed, tests pass:

Test simple recursive watchpoint [D:\a\php-src\php-src\sapi\phpdbg\tests\watch_001.phpt] (warn: XFAIL section but test passes)
Test simple array watchpoint with replace [D:\a\php-src\php-src\sapi\phpdbg\tests\watch_002.phpt] (warn: XFAIL section but test passes)
Test simple watchpoint with replace [D:\a\php-src\php-src\sapi\phpdbg\tests\watch_003.phpt] (warn: XFAIL section but test passes)
Test detection of inline string manipulations on zval watch [D:\a\php-src\php-src\sapi\phpdbg\tests\watch_004.phpt] (warn: XFAIL section but test passes)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issues may be solved, but I'd only remove that skipif clause for "master".

Copy link
Contributor Author

@mvorisek mvorisek Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it passes for PHP-8.0, why do not fix this good behaviour for PHP-8.0 too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may pass, but would it pass in all enviroments? I mean the skip reason is "There may be flaws in the implementation of watchpoints that cause failures". This may not have been resolved generally. Maybe @krakjoe can comment on this?

@mvorisek mvorisek force-pushed the fix_32bit_testing branch 2 times, most recently from 7106c77 to a06e8d8 Compare April 27, 2022 21:48
@mvorisek mvorisek marked this pull request as draft April 27, 2022 23:16
@mvorisek mvorisek marked this pull request as ready for review April 28, 2022 00:07
@@ -1,18 +0,0 @@
--TEST--
Bug #77269 (Potential unsigned underflow in gdImageScale)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, not exactly (this test is supposed to work with pretty old GD, but the other only for somewhat recent versions), but I think it's okay to drop bug77269.phpt now, but for "master" only.

@@ -5,6 +5,7 @@ memory_limit=-1
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this test succeed on 32bit Linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2**28 is still within the 32-bit integer range, I need to investigate further

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct, but there are additional allocations, and I think that the scaling uses a truecolor image which requires 4 byte for each pixel. So we're at 2^30 (plus), what usually doesn't work on Windows (usually max. 2 GiB per process), while Linux may allow more.

@@ -2,9 +2,6 @@
Test simple recursive watchpoint
--SKIPIF--
<?php
if (PHP_INT_SIZE == 4) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issues may be solved, but I'd only remove that skipif clause for "master".

@mvorisek mvorisek marked this pull request as draft April 28, 2022 14:05
@mvorisek mvorisek force-pushed the fix_32bit_testing branch from a06e8d8 to 6b2dbb8 Compare May 4, 2022 07:28
@Girgias
Copy link
Member

Girgias commented May 4, 2022

Please wait for #8392 to be merged before working on this, also CI enabling of x86 testing for Windows should be either part of this PR or a follow-up instead of polluting the other one which should just be a change from Appveyor to GitHub

@mvorisek mvorisek force-pushed the fix_32bit_testing branch from 6ed2373 to cf3f55d Compare May 4, 2022 12:17
@mvorisek mvorisek force-pushed the fix_32bit_testing branch from cf3f55d to 978f214 Compare May 4, 2022 13:54
@mvorisek mvorisek marked this pull request as ready for review May 4, 2022 13:54
@mvorisek
Copy link
Contributor Author

mvorisek commented May 9, 2022

@cmb69 can you please review the test changes?

I tested them on Windows x64 with 32 bit php, but I have no access to 32 bit linux nor 32 bit Windows machines.

@mvorisek
Copy link
Contributor Author

@cmb69 I propose all changes made, it fixes 32b build on Win x64 and I have no access to 32b machines. I propose to merge as is, if there is any issue with rate 32b OS combination, then we can add XFAIL/SKIP back, but I belive the issues were already skipped and better to assert no issues in CI if there are no issues known

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with merging the changes to the phpdbg tests into master, and also dropping bug77269.phpt there. I don't think we shouldn't touch bug77272.phpt without closer investigation. The changes to bug72858.phpt defeat the purpose of that test.

@mvorisek
Copy link
Contributor Author

  • phpdbg - will you cherrypick during merge?
  • gd bug77269/bug77272, discussed in Fix tests on 32-bit Windows OS #8448 (comment) - what exactly? I belive the expectation for gd lib < 2.2.5 will not be satisfied by the other test, except different memory limit, there are the same
  • bug72858 - discussed in Fix tests on 32-bit Windows OS #8448 (comment) - the test was NOT skipped on 32b build, but if such build is tested, the test fails, so it needs change, or please advise how to fix the test or php-src

@cmb69
Copy link
Member

cmb69 commented May 16, 2022

bug77272.phpt should run regardless of the architecture, unless it is clear, that it never can pass under 32bit OS (I still believe it passes on Linux).

bug72858.phpt is supposed to run under 32bit only, to trigger shm_attach() failure. I have yet to see that test failing on any 32bit architecture.

@mvorisek
Copy link
Contributor Author

bug77272.phpt should run regardless of the architecture, unless it is clear, that it never can pass under 32bit OS (I still believe it passes on Linux).

it does not pass /w 32b build for Windows, can you reproduce?

bug72858.phpt is supposed to run under 32bit only, to trigger shm_attach() failure. I have yet to see that test failing on any 32bit architecture.

on 32b build, there is no warning, if the test is failing on native 32b architecture/host, how to fix it?

@mvorisek
Copy link
Contributor Author

mvorisek commented May 26, 2022

@cmb69 let's merge this as is, all changes are needed to pass tests when 32-bit php is built

and please revert c344d30 to master as the skips for 32-bit builds are not needed

@cmb69 cmb69 self-assigned this May 27, 2022
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug72858.phpt is supposed to run under 32bit only, to trigger shm_attach() failure. I have yet to see that test failing on any 32bit architecture.

So why did you delete that test?

@mvorisek
Copy link
Contributor Author

@cmb69 because #8448 (comment)

@cmb69
Copy link
Member

cmb69 commented May 27, 2022

Nikita wrote "If this test no longer works on 32-bit,", but for me it works every single time I run it. I still have yet to see a single case where it fails.

@mvorisek
Copy link
Contributor Author

Nikita wrote "If this test no longer works on 32-bit,", but for me it works every single time I run it. I still have yet to see a single case where it fails.

for me, the original expected warning is not present when I compile PHP for x86/32b (and for x64/64b, the test is skipped)

(all tests done on 64 bit host OS)

@mvorisek
Copy link
Contributor Author

@cmb69
Copy link
Member

cmb69 commented May 27, 2022

Okay, thanks. https://github.com/cmb69/php-ftw/actions/runs/2396415661 confirms that. I'll have a closer look.

@cmb69
Copy link
Member

cmb69 commented May 27, 2022

I still think that the test is useful, but the actual $size is not; it is only important that failure to map is caught. So I thought that using PHP_INT_MAX might be a nice opportunity to extend the test to 64bit architectures. There I'd get:

Warning: shm_attach(): Failed for key 0x64: No error in %s on line %d

Task failed successfully! ;)

@mvorisek
Copy link
Contributor Author

mvorisek commented May 27, 2022

I still think that the test is useful, but the actual $size is not; it is only important that failure to map is caught. So I thought that using PHP_INT_MAX might be a nice opportunity to extend the test to 64bit architectures. There I'd get:

Warning: shm_attach(): Failed for key 0x64: No error in %s on line %d

Task failed successfully! ;)

updated, but are you sure it will fail on systems with free memory much larger than PHP_INT_MAX? like when 50 GB is available and the PHP_INT_MAX is 2 GB when build for x86/32b.

@mvorisek mvorisek force-pushed the fix_32bit_testing branch from 21bc6ad to 80f22ab Compare May 27, 2022 17:32
@cmb69 cmb69 closed this in c756e97 Jun 29, 2022
@mvorisek mvorisek deleted the fix_32bit_testing branch June 29, 2022 12:08
@mvorisek
Copy link
Contributor Author

bug77272.phpt should run regardless of the architecture, unless it is clear, that it never can pass under 32bit OS (I still believe it passes on Linux).

you are right, the test should pass, there is some detection in gd overflow2 function (for some reasons, there are almost two identical copies for this function)

do you have any idea how to fix the gd lib?

Bug #77269 (Potential unsigned underflow in gdImageScale) [D:\a\php-src\php-src\ext\gd\tests\bug77269.phpt]
Bug #77272 (imagescale() may return image resource on failure) [D:\a\php-src\php-src\ext\gd\tests\bug77272.phpt]

tests are failing consistently on x86 build

@cmb69
Copy link
Member

cmb69 commented Oct 12, 2022

in gd overflow2 function (for some reasons, there are almost two identical copies for this function)

Ugh, what a mess! The implementation in gd_security.c is used for bundled libgd; the implementation in gd_compat.c might be used for external libgd, although we require libgd >= 2.1.0, which always should have the implementation in gd_security.c. I guess gd_compat.c is superfluous for years. I'm gonna check this out.

Bug #77269 (Potential unsigned underflow in gdImageScale) [D:\a\php-src\php-src\ext\gd\tests\bug77269.phpt]

Like I said above, this test should be removed for "master".

Bug #77272 (imagescale() may return image resource on failure) [D:\a\php-src\php-src\ext\gd\tests\bug77272.phpt]

I suggest to skip this test on 32bit Windows.

@cmb69
Copy link
Member

cmb69 commented Oct 12, 2022

I guess gd_compat.c is superfluous for years. I'm gonna check this out.

Unfortunately, overflow2 is not exported by libgd, and we call it from imageloadfont(). I'm not sure yet whether we should replace these overflow2() calls with something else, or whether I should suggest to deprecate the whole gdfont stuff (which is about primitive pixel fonts, not TTF).

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

Successfully merging this pull request may close these issues.

5 participants