Skip to content

RFC: Add the RoundingMode enum #14833

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

Merged
merged 9 commits into from
Jul 18, 2024
Merged

Conversation

TimWolla
Copy link
Member

@TimWolla TimWolla commented Jul 5, 2024

@TimWolla TimWolla force-pushed the roundingmode-enum branch from a8d1e94 to 7b54dc6 Compare July 5, 2024 20:42
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

At least the BCMath changes and the logic to convert the enum back to a mode seem right.

Comment on lines 719 to 725
zend_argument_value_error(3, "must be a valid rounding mode (PHP_ROUND_*)");
/* This is currently unreachable, but might become reachable when new modes are added. */
zend_argument_value_error(3, " is a rounding mode that is not supported");
Copy link
Member

Choose a reason for hiding this comment

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

I don't see how this can happen now? As the value should always be a correct mode from the enum object, turning this into an assertion seems more logical.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cannot happen now (as the comment indicates), but can happen if additional cases are added to the RoundingMode enum in the future that cannot (easily) be supported with BCMath or where the implementation forgets to adjust BCMath.

This error message is thus intended to fail safely rather than crashing or returning bogus values.

Copy link
Member

Choose a reason for hiding this comment

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

I would rather have this be an assertion and have a test in BC Math that cycles through all the cases of the enum to be sure we don't miss any new ones introduced.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added an additional test based on round_RoundingMode.phpt that goes through all the enum cases, but I've preserved the error message instead of replacing it by an assert. The RoundingMode enum is owned by ext/standard, not ext/bcmath, so to me defensive programming makes sense there.

TimWolla and others added 2 commits July 6, 2024 13:23
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

Great

@TimWolla TimWolla merged commit 5905857 into php:master Jul 18, 2024
11 checks passed
@TimWolla TimWolla deleted the roundingmode-enum branch July 18, 2024 18:44
@drupol
Copy link
Contributor

drupol commented Jul 28, 2024

Hello there,

I bisected to find why bcmatch extension was impossible to build anymore:

❯ git bisect good
5905857fd2652585989ed03e5a5b0beea89ab18e is the first bad commit
commit 5905857fd2652585989ed03e5a5b0beea89ab18e
Author: Tim Düsterhus <tim@bastelstu.be>
Date:   Thu Jul 18 20:44:30 2024 +0200

    RFC: Add the RoundingMode enum (#14833)
    
    see https://wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum
    
    Co-authored-by: Saki Takamachi <saki@php.net>
    Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>

 NEWS                                                              |   5 +++++
 UPGRADING                                                         |  27 ++++++++++++++-------------
 ext/bcmath/bcmath.c                                               |  10 ++++++++--
 ext/bcmath/bcmath.stub.php                                        |   2 +-
 ext/bcmath/bcmath_arginfo.h                                       | Bin 2966 -> 2983 bytes
 ext/bcmath/tests/bcround_all.phpt                                 | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ext/bcmath/tests/bcround_away_from_zero.phpt                      |   4 ++--
 ext/bcmath/tests/bcround_ceiling.phpt                             |   4 ++--
 ext/bcmath/tests/bcround_early_return.phpt                        |  50 ++++++++++++++++++--------------------------------
 ext/bcmath/tests/bcround_error.phpt                               |   7 -------
 ext/bcmath/tests/bcround_floor.phpt                               |   4 ++--
 ext/bcmath/tests/bcround_half_down.phpt                           |   4 ++--
 ext/bcmath/tests/bcround_half_even.phpt                           |   4 ++--
 ext/bcmath/tests/bcround_half_odd.phpt                            |   4 ++--
 ext/bcmath/tests/bcround_half_up.phpt                             |   4 ++--
 ext/bcmath/tests/bcround_test_helper.inc                          |   4 ++--
 ext/bcmath/tests/bcround_toward_zero.phpt                         |   4 ++--
 ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt |  24 +++++++++++-------------
 ext/standard/basic_functions.c                                    |   3 +++
 ext/standard/basic_functions.stub.php                             |  33 ++++++++++++---------------------
 ext/standard/basic_functions_arginfo.h                            | Bin 176996 -> 177445 bytes
 ext/standard/math.c                                               |  38 ++++++++++++++++++++++++++++++++++++--
 ext/standard/php_math_round_mode.h                                |   6 ++++++
 ext/standard/tests/math/round_RoundingMode.phpt                   | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ext/standard/tests/math/round_gh12143_expand-rounding-target.phpt |  16 ++++++++--------
 ext/standard/tests/math/round_modes.phpt                          |  16 ++++++++--------
 ext/standard/tests/math/round_modes_ceiling_and_floor.phpt        |  17 +++++++----------
 ext/standard/tests/math/round_modes_zeros.phpt                    |  16 ++++++++--------
 ext/standard/tests/math/round_valid_rounding_mode.phpt            |   2 +-
 29 files changed, 370 insertions(+), 144 deletions(-)
 create mode 100644 ext/bcmath/tests/bcround_all.phpt
 create mode 100644 ext/standard/tests/math/round_RoundingMode.phpt

Apparently, since this PR we have issue in Nix to build the php-bcmath extension.

Build log + failing tests
php-bcmath> /nix/store/m101dg80ngyjdb02g6jwy80sr7kzj26g-bash-5.2p26/bin/bash /build/source/ext/bcmath/libtool --tag=CC --mode=compile gcc -I. -I/build/source/ext/bcmath -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/main -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/TSRM -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/Zend -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -D_GNU_SOURCE   -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DZEND_COMPILE_DL_EXT=1 -c /build/source/ext/bcmath/libbcmath/src/zero.c -o libbcmath/src/zero.lo  -MMD -MF libbcmath/src/zero.dep -MT libbcmath/src/zero.lo
php-bcmath>  gcc -I. -I/build/source/ext/bcmath -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/main -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/TSRM -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/Zend -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DZEND_COMPILE_DL_EXT=1 -c /build/source/ext/bcmath/libbcmath/src/sub.c -MMD -MF libbcmath/src/sub.dep -MT libbcmath/src/sub.lo  -fPIC -DPIC -o libbcmath/src/.libs/sub.o
php-bcmath>  gcc -I. -I/build/source/ext/bcmath -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/main -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/TSRM -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/Zend -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DZEND_COMPILE_DL_EXT=1 -c /build/source/ext/bcmath/libbcmath/src/str2num.c -MMD -MF libbcmath/src/str2num.dep -MT libbcmath/src/str2num.lo  -fPIC -DPIC -o libbcmath/src/.libs/str2num.o
php-bcmath>  gcc -I. -I/build/source/ext/bcmath -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/main -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/TSRM -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/Zend -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DZEND_COMPILE_DL_EXT=1 -c /build/source/ext/bcmath/libbcmath/src/zero.c -MMD -MF libbcmath/src/zero.dep -MT libbcmath/src/zero.lo  -fPIC -DPIC -o libbcmath/src/.libs/zero.o
php-bcmath> /nix/store/m101dg80ngyjdb02g6jwy80sr7kzj26g-bash-5.2p26/bin/bash /build/source/ext/bcmath/libtool --tag=CC --mode=link gcc -shared -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/main -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/TSRM -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/Zend -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext -I/nix/store/s33fv9p5n840b814z324mdiczr6lx2rv-php-8.4.999-a7d856d-dev/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -D_GNU_SOURCE    -o bcmath.la -export-dynamic -avoid-version -prefer-pic -module -rpath /build/source/ext/bcmath/modules  bcmath.lo libbcmath/src/add.lo libbcmath/src/compare.lo libbcmath/src/convert.lo libbcmath/src/div.lo libbcmath/src/divmod.lo libbcmath/src/doaddsub.lo libbcmath/src/floor_or_ceil.lo libbcmath/src/init.lo libbcmath/src/int2num.lo libbcmath/src/nearzero.lo libbcmath/src/neg.lo libbcmath/src/num2long.lo libbcmath/src/num2str.lo libbcmath/src/raise.lo libbcmath/src/raisemod.lo libbcmath/src/recmul.lo libbcmath/src/rmzero.lo libbcmath/src/round.lo libbcmath/src/sqrt.lo libbcmath/src/str2num.lo libbcmath/src/sub.lo libbcmath/src/zero.lo
php-bcmath> gcc -shared  .libs/bcmath.o libbcmath/src/.libs/add.o libbcmath/src/.libs/compare.o libbcmath/src/.libs/convert.o libbcmath/src/.libs/div.o libbcmath/src/.libs/divmod.o libbcmath/src/.libs/doaddsub.o libbcmath/src/.libs/floor_or_ceil.o libbcmath/src/.libs/init.o libbcmath/src/.libs/int2num.o libbcmath/src/.libs/nearzero.o libbcmath/src/.libs/neg.o libbcmath/src/.libs/num2long.o libbcmath/src/.libs/num2str.o libbcmath/src/.libs/raise.o libbcmath/src/.libs/raisemod.o libbcmath/src/.libs/recmul.o libbcmath/src/.libs/rmzero.o libbcmath/src/.libs/round.o libbcmath/src/.libs/sqrt.o libbcmath/src/.libs/str2num.o libbcmath/src/.libs/sub.o libbcmath/src/.libs/zero.o   -Wl,-soname -Wl,bcmath.so -o .libs/bcmath.so
php-bcmath> creating bcmath.la
php-bcmath> (cd .libs && rm -f bcmath.la && ln -s ../bcmath.la bcmath.la)
php-bcmath> /nix/store/m101dg80ngyjdb02g6jwy80sr7kzj26g-bash-5.2p26/bin/bash /build/source/ext/bcmath/libtool --tag=CC --mode=install cp ./bcmath.la /build/source/ext/bcmath/modules
php-bcmath> cp ./.libs/bcmath.so /build/source/ext/bcmath/modules/bcmath.so
php-bcmath> cp ./.libs/bcmath.lai /build/source/ext/bcmath/modules/bcmath.la
php-bcmath> PATH="$PATH:/sbin" ldconfig -n /build/source/ext/bcmath/modules
php-bcmath> ----------------------------------------------------------------------
php-bcmath> Libraries have been installed in:
php-bcmath>    /build/source/ext/bcmath/modules
php-bcmath> If you ever happen to want to link against installed libraries
php-bcmath> in a given directory, LIBDIR, you must either use libtool, and
php-bcmath> specify the full pathname of the library, or use the `-LLIBDIR'
php-bcmath> flag during linking and do at least one of the following:
php-bcmath>    - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
php-bcmath>      during execution
php-bcmath>    - add LIBDIR to the `LD_RUN_PATH' environment variable
php-bcmath>      during linking
php-bcmath>    - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
php-bcmath> See any operating system documentation about shared libraries for
php-bcmath> more information, such as the ld(1) and ld.so(8) manual pages.
php-bcmath> ----------------------------------------------------------------------
php-bcmath> Build complete.
php-bcmath> Don't forget to run 'make test'.
php-bcmath> Running phase: checkPhase
php-bcmath> Build complete.
php-bcmath> Don't forget to run 'make test'.
php-bcmath> =====================================================================
php-bcmath> PHP         : /nix/store/5mkf9miy9rcb89lbb9r1k9y18daqjx5d-php-8.4.999-a7d856d/bin/php
php-bcmath> Warning: PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /build/source/ext/bcmath/modules/bcmath.so (/build/source/ext/bcmath/modules/bcmath.so: undefined symbol: php_math_round_mode_from_enum), /build/source/ext/bcmath/modules/bcmath.so.so (/build/source/ext/bcmath/modules/bcmath.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-bcmath> PHP_SAPI    : cli
php-bcmath> PHP_VERSION : 8.4.0-dev
php-bcmath> ZEND_VERSION: 4.4.0-dev
php-bcmath> PHP_OS      : Linux - Linux localhost 6.10.0 #1-NixOS SMP PREEMPT_DYNAMIC Sun Jul 14 22:43:32 UTC 2024 x86_64
php-bcmath> INI actual  : /build/source/ext/bcmath/tmp-php.ini
php-bcmath> More .INIs  :
php-bcmath> ---------------------------------------------------------------------
php-bcmath> PHP         : /nix/store/5mkf9miy9rcb89lbb9r1k9y18daqjx5d-php-8.4.999-a7d856d/bin/php-cgi
php-bcmath> PHP_SAPI    : cgi-fcgi
php-bcmath> PHP_VERSION : 8.4.0-dev
php-bcmath> ZEND_VERSION: 4.4.0-dev
php-bcmath> PHP_OS      : Linux - Linux localhost 6.10.0 #1-NixOS SMP PREEMPT_DYNAMIC Sun Jul 14 22:43:32 UTC 2024 x86_64
php-bcmath> INI actual  : /build/source/ext/bcmath/tmp-php.ini
php-bcmath> More .INIs  :
php-bcmath> Warning: PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /build/source/ext/bcmath/modules/bcmath.so (/build/source/ext/bcmath/modules/bcmath.so: undefined symbol: php_math_round_mode_from_enum), /build/source/ext/bcmath/modules/bcmath.so.so (/build/source/ext/bcmath/modules/bcmath.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-bcmath> ---------------------------------------------------------------------
php-bcmath> ---------------------------------------------------------------------
php-bcmath> PHP         : /nix/store/5mkf9miy9rcb89lbb9r1k9y18daqjx5d-php-8.4.999-a7d856d/bin/phpdbg
php-bcmath> PHP_SAPI    : phpdbg
php-bcmath> PHP_VERSION : 8.4.0-dev
php-bcmath> ZEND_VERSION: 4.4.0-dev
php-bcmath> PHP_OS      : Linux - Linux localhost 6.10.0 #1-NixOS SMP PREEMPT_DYNAMIC Sun Jul 14 22:43:32 UTC 2024 x86_64
php-bcmath> INI actual  : /build/source/ext/bcmath/tmp-php.ini
php-bcmath> More .INIs  :
php-bcmath> Warning: PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /build/source/ext/bcmath/modules/bcmath.so (/build/source/ext/bcmath/modules/bcmath.so: undefined symbol: php_math_round_mode_from_enum), /build/source/ext/bcmath/modules/bcmath.so.so (/build/source/ext/bcmath/modules/bcmath.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-bcmath> ---------------------------------------------------------------------
php-bcmath> CWD         : /build/source/ext/bcmath
php-bcmath> Extra dirs  :
php-bcmath> VALGRIND    : Not used
php-bcmath> =====================================================================
php-bcmath> TIME START 2024-07-28 15:30:18
php-bcmath> =====================================================================
php-bcmath> PHP Warning:  PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /build/source/ext/bcmath/modules/bcmath.so (/build/source/ext/bcmath/modules/bcmath.so: undefined symbol: php_math_round_mode_from_enum), /build/source/ext/bcmath/modules/bcmath.so.so (/build/source/ext/bcmath/modules/bcmath.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-bcmath> PHP Warning:  PHP Startup: Unable to load dynamic library 'bcmath.so' (tried: /build/source/ext/bcmath/modules/bcmath.so (/build/source/ext/bcmath/modules/bcmath.so: undefined symbol: php_math_round_mode_from_enum), /build/source/ext/bcmath/modules/bcmath.so.so (/build/source/ext/bcmath/modules/bcmath.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-bcmath> FAIL bcadd() function [tests/bcadd.phpt]
php-bcmath> FAIL bcadd() requires well-formed values [tests/bcadd_error.phpt]
php-bcmath> FAIL bcadd() function with large numbers [tests/bcadd_large_numbers.phpt]
php-bcmath> FAIL bcadd() function with number zero [tests/bcadd_zero.phpt]
php-bcmath> FAIL bcceil() function [tests/bcceil.phpt]
php-bcmath> FAIL bcceil() function with error [tests/bcceil_error.phpt]
php-bcmath> FAIL bccomp() function [tests/bccomp.phpt]
php-bcmath> FAIL bccomp() requires well-formed values [tests/bccomp_error.phpt]
php-bcmath> FAIL bccomp() with non-integers [tests/bccomp_variation001.phpt]
php-bcmath> FAIL bccomp() with negative value [tests/bccomp_variation002.phpt]
php-bcmath> FAIL bcdiv() function [tests/bcdiv.phpt]
php-bcmath> FAIL bcdiv() function with numbers pow 10 [tests/bcdiv_by_pow_10.phpt]
php-bcmath> FAIL bcdiv — Divide two arbitrary precision numbers [tests/bcdiv_error1.phpt]
php-bcmath> FAIL bcdiv() requires well-formed values [tests/bcdiv_error2.phpt]
php-bcmath> FAIL bcdiv() function with large numbers [tests/bcdiv_large_numbers.phpt]
php-bcmath> FAIL bcdiv() function with number zero [tests/bcdiv_zero.phpt]
php-bcmath> FAIL bcfloor() function [tests/bcfloor.phpt]
php-bcmath> FAIL bcfloor() function with error [tests/bcfloor_error.phpt]
php-bcmath> FAIL bcmod() function [tests/bcmod.phpt]
php-bcmath> FAIL bcmod() - mod by 0 [tests/bcmod_error2.phpt]
php-bcmath> FAIL bcmod() requires well-formed values [tests/bcmod_error3.phpt]
php-bcmath> FAIL bcmod() function with large numbers [tests/bcmod_large_numbers.phpt]
php-bcmath> FAIL bcmod() function with number zero [tests/bcmod_zero.phpt]
php-bcmath> FAIL bcmul() function [tests/bcmul.phpt]
php-bcmath> FAIL bcmul() checking overflow [tests/bcmul_check_overflow.phpt]
php-bcmath> FAIL bcmul() requires well-formed values [tests/bcmul_error.phpt]
php-bcmath> FAIL bcmul() function with large numbers [tests/bcmul_large_numbers.phpt]
php-bcmath> FAIL bcmul() function with number zero [tests/bcmul_zero.phpt]
php-bcmath> FAIL bcpow() function [tests/bcpow.phpt]
php-bcmath> FAIL bcpow() does not support non-integral exponents [tests/bcpow_error1.phpt]
php-bcmath> FAIL bcpow() does not support exponents >= 2**63 [tests/bcpow_error2.phpt]
php-bcmath> FAIL bcpow() requires well-formed values [tests/bcpow_error3.phpt]
php-bcmath> FAIL bcpow() function with large numbers [tests/bcpow_large_numbers.phpt]
php-bcmath> FAIL bcpow() function with number zero [tests/bcpow_zero.phpt]
php-bcmath> FAIL bcpowmod() - Raise an arbitrary precision number to another, reduced by a specified modulus [tests/bcpowmod.phpt]
php-bcmath> FAIL bcpowmod() requires well-formed values [tests/bcpowmod_error.phpt]
php-bcmath> FAIL bc_raisemod's expo can't be negative [tests/bcpowmod_negative_exponent.phpt]
php-bcmath> FAIL bcpowmod() must return 0 when mod is +1 or -1 [tests/bcpowmod_with_mod_1.phpt]
php-bcmath> FAIL bc_raisemod's mod can't be zero [tests/bcpowmod_zero_modulus.phpt]
php-bcmath> FAIL bcround() function all modes [tests/bcround_all.phpt]
php-bcmath> FAIL bcround() function AwayFromZero [tests/bcround_away_from_zero.phpt]
php-bcmath> FAIL bcround() function PositiveInfinity [tests/bcround_ceiling.phpt]
php-bcmath> FAIL bcround() function with early return [tests/bcround_early_return.phpt]
php-bcmath> FAIL bcround() function with error [tests/bcround_error.phpt]
php-bcmath> FAIL bcround() function NegativeInfinity [tests/bcround_floor.phpt]
php-bcmath> FAIL bcround() function HalfTowardsZero [tests/bcround_half_down.phpt]
php-bcmath> FAIL bcround() function HalfEven [tests/bcround_half_even.phpt]
php-bcmath> FAIL bcround() function HalfOdd [tests/bcround_half_odd.phpt]
php-bcmath> FAIL bcround() function HalfAwayFromZero [tests/bcround_half_up.phpt]
php-bcmath> FAIL bcround() function TowardsZero [tests/bcround_toward_zero.phpt]
php-bcmath> FAIL bcscale() function [tests/bcscale.phpt]
php-bcmath> FAIL bcscale() fails with negative argument [tests/bcscale_variation001.phpt]
php-bcmath> FAIL bcadd() incorrect argument count [tests/bcscale_variation002.phpt]
php-bcmath> FAIL bcscale() return value [tests/bcscale_variation003.phpt]
php-bcmath> FAIL bcsqrt() function [tests/bcsqrt.phpt]
php-bcmath> FAIL bcsqrt — Get the square root of an arbitrary precision number [tests/bcsqrt_error1.phpt]
php-bcmath> FAIL bcsqrt() requires a well-formed value [tests/bcsqrt_error2.phpt]
php-bcmath> FAIL bcsub() function [tests/bcsub.phpt]
php-bcmath> FAIL bcsub() requires well-formed values [tests/bcsub_error.phpt]
php-bcmath> FAIL bcsub() function with large numbers [tests/bcsub_large_numbers.phpt]
php-bcmath> FAIL bcsub() function with number zero [tests/bcsub_zero.phpt]
php-bcmath> FAIL Bug #44995 (bcpowmod() fails if scale != 0) [tests/bug44995.phpt]
php-bcmath> FAIL Bug #46781 (BC math handles minus zero incorrectly) [tests/bug46781.phpt]
php-bcmath> FAIL Bug #54598 (bcpowmod() may return 1 if modulus is 1) [tests/bug54598.phpt]
php-bcmath> FAIL bcscale related problem on 64bits platforms [tests/bug60377.phpt]
php-bcmath> FAIL Bug #66364 (BCMath bcmul ignores scale parameter) [tests/bug66364.phpt]
php-bcmath> FAIL Bug 72093: bcpowmod fails on negative scale and corrupts _one_ definition [tests/bug72093.phpt]
php-bcmath> FAIL Bug #75178 (bcpowmod() misbehaves for non-integer base or modulus) [tests/bug75178.phpt]
php-bcmath> FAIL Bug #78238 (BCMath returns "-0") [tests/bug78238.phpt]
php-bcmath> FAIL Bug #78878 (Buffer underflow in bc_shift_addsub) [tests/bug78878.phpt]
php-bcmath> FAIL Bug #80545 (bcadd('a', 'a') and bcadd('1', 'a') doesn't throw an exception) [tests/bug80545.phpt]
php-bcmath> FAIL all errors on negative scale [tests/negative_scale.phpt]
php-bcmath> FAIL BCMath functions return result with requested scale [tests/scale.phpt]
php-bcmath> FAIL BCMath functions return result with default scale [tests/scale_ini.phpt]
php-bcmath> FAIL bcmath lib arguments formatting [tests/str2num_formatting.phpt]
php-bcmath> =====================================================================
php-bcmath> TIME END 2024-07-28 15:30:18
php-bcmath> =====================================================================
php-bcmath> TEST RESULT SUMMARY
php-bcmath> ---------------------------------------------------------------------
php-bcmath> Exts skipped    :     0
php-bcmath> Exts tested     :    13
php-bcmath> ---------------------------------------------------------------------
php-bcmath> Number of tests :    75                75
php-bcmath> Tests skipped   :     0 (  0.0%) --------
php-bcmath> Tests warned    :     0 (  0.0%) (  0.0%)
php-bcmath> Tests failed    :    75 (100.0%) (100.0%)
php-bcmath> Tests passed    :     0 (  0.0%) (  0.0%)
php-bcmath> ---------------------------------------------------------------------
php-bcmath> Time taken      : 0.409 seconds
php-bcmath> =====================================================================
php-bcmath> =====================================================================
php-bcmath> FAILED TEST SUMMARY
php-bcmath> ---------------------------------------------------------------------
php-bcmath> bcadd() function [tests/bcadd.phpt]
php-bcmath> bcadd() requires well-formed values [tests/bcadd_error.phpt]
php-bcmath> bcadd() function with large numbers [tests/bcadd_large_numbers.phpt]
php-bcmath> bcadd() function with number zero [tests/bcadd_zero.phpt]
php-bcmath> bcceil() function [tests/bcceil.phpt]
php-bcmath> bcceil() function with error [tests/bcceil_error.phpt]
php-bcmath> bccomp() function [tests/bccomp.phpt]
php-bcmath> bccomp() requires well-formed values [tests/bccomp_error.phpt]
php-bcmath> bccomp() with non-integers [tests/bccomp_variation001.phpt]
php-bcmath> bccomp() with negative value [tests/bccomp_variation002.phpt]
php-bcmath> bcdiv() function [tests/bcdiv.phpt]
php-bcmath> bcdiv() function with numbers pow 10 [tests/bcdiv_by_pow_10.phpt]
php-bcmath> bcdiv — Divide two arbitrary precision numbers [tests/bcdiv_error1.phpt]
php-bcmath> bcdiv() requires well-formed values [tests/bcdiv_error2.phpt]
php-bcmath> bcdiv() function with large numbers [tests/bcdiv_large_numbers.phpt]
php-bcmath> bcdiv() function with number zero [tests/bcdiv_zero.phpt]
php-bcmath> bcfloor() function [tests/bcfloor.phpt]
php-bcmath> bcfloor() function with error [tests/bcfloor_error.phpt]
php-bcmath> bcmod() function [tests/bcmod.phpt]
php-bcmath> bcmod() - mod by 0 [tests/bcmod_error2.phpt]
php-bcmath> bcmod() requires well-formed values [tests/bcmod_error3.phpt]
php-bcmath> bcmod() function with large numbers [tests/bcmod_large_numbers.phpt]
php-bcmath> bcmod() function with number zero [tests/bcmod_zero.phpt]
php-bcmath> bcmul() function [tests/bcmul.phpt]
php-bcmath> bcmul() checking overflow [tests/bcmul_check_overflow.phpt]
php-bcmath> bcmul() requires well-formed values [tests/bcmul_error.phpt]
php-bcmath> bcmul() function with large numbers [tests/bcmul_large_numbers.phpt]
php-bcmath> bcmul() function with number zero [tests/bcmul_zero.phpt]
php-bcmath> bcpow() function [tests/bcpow.phpt]
php-bcmath> bcpow() does not support non-integral exponents [tests/bcpow_error1.phpt]
php-bcmath> bcpow() does not support exponents >= 2**63 [tests/bcpow_error2.phpt]
php-bcmath> bcpow() requires well-formed values [tests/bcpow_error3.phpt]
php-bcmath> bcpow() function with large numbers [tests/bcpow_large_numbers.phpt]
php-bcmath> bcpow() function with number zero [tests/bcpow_zero.phpt]
php-bcmath> bcpowmod() - Raise an arbitrary precision number to another, reduced by a specified modulus [tests/bcpowmod.phpt]
php-bcmath> bcpowmod() requires well-formed values [tests/bcpowmod_error.phpt]
php-bcmath> bc_raisemod's expo can't be negative [tests/bcpowmod_negative_exponent.phpt]
php-bcmath> bcpowmod() must return 0 when mod is +1 or -1 [tests/bcpowmod_with_mod_1.phpt]
php-bcmath> bc_raisemod's mod can't be zero [tests/bcpowmod_zero_modulus.phpt]
php-bcmath> bcround() function all modes [tests/bcround_all.phpt]
php-bcmath> bcround() function AwayFromZero [tests/bcround_away_from_zero.phpt]
php-bcmath> bcround() function PositiveInfinity [tests/bcround_ceiling.phpt]
php-bcmath> bcround() function with early return [tests/bcround_early_return.phpt]
php-bcmath> bcround() function with error [tests/bcround_error.phpt]
php-bcmath> bcround() function NegativeInfinity [tests/bcround_floor.phpt]
php-bcmath> bcround() function HalfTowardsZero [tests/bcround_half_down.phpt]
php-bcmath> bcround() function HalfEven [tests/bcround_half_even.phpt]
php-bcmath> bcround() function HalfOdd [tests/bcround_half_odd.phpt]
php-bcmath> bcround() function HalfAwayFromZero [tests/bcround_half_up.phpt]
php-bcmath> bcround() function TowardsZero [tests/bcround_toward_zero.phpt]
php-bcmath> bcscale() function [tests/bcscale.phpt]
php-bcmath> bcscale() fails with negative argument [tests/bcscale_variation001.phpt]
php-bcmath> bcadd() incorrect argument count [tests/bcscale_variation002.phpt]
php-bcmath> bcscale() return value [tests/bcscale_variation003.phpt]
php-bcmath> bcsqrt() function [tests/bcsqrt.phpt]
php-bcmath> bcsqrt — Get the square root of an arbitrary precision number [tests/bcsqrt_error1.phpt]
php-bcmath> bcsqrt() requires a well-formed value [tests/bcsqrt_error2.phpt]
php-bcmath> bcsub() function [tests/bcsub.phpt]
php-bcmath> bcsub() requires well-formed values [tests/bcsub_error.phpt]
php-bcmath> bcsub() function with large numbers [tests/bcsub_large_numbers.phpt]
php-bcmath> bcsub() function with number zero [tests/bcsub_zero.phpt]
php-bcmath> Bug #44995 (bcpowmod() fails if scale != 0) [tests/bug44995.phpt]
php-bcmath> Bug #46781 (BC math handles minus zero incorrectly) [tests/bug46781.phpt]
php-bcmath> Bug #54598 (bcpowmod() may return 1 if modulus is 1) [tests/bug54598.phpt]
php-bcmath> bcscale related problem on 64bits platforms [tests/bug60377.phpt]
php-bcmath> Bug #66364 (BCMath bcmul ignores scale parameter) [tests/bug66364.phpt]
php-bcmath> Bug 72093: bcpowmod fails on negative scale and corrupts _one_ definition [tests/bug72093.phpt]
php-bcmath> Bug #75178 (bcpowmod() misbehaves for non-integer base or modulus) [tests/bug75178.phpt]
php-bcmath> Bug #78238 (BCMath returns "-0") [tests/bug78238.phpt]
php-bcmath> Bug #78878 (Buffer underflow in bc_shift_addsub) [tests/bug78878.phpt]
php-bcmath> Bug #80545 (bcadd('a', 'a') and bcadd('1', 'a') doesn't throw an exception) [tests/bug80545.phpt]
php-bcmath> all errors on negative scale [tests/negative_scale.phpt]
php-bcmath> BCMath functions return result with requested scale [tests/scale.phpt]
php-bcmath> BCMath functions return result with default scale [tests/scale_ini.phpt]
php-bcmath> bcmath lib arguments formatting [tests/str2num_formatting.phpt]
php-bcmath> =====================================================================
php-bcmath> make: *** [Makefile:129: test] Error 1

It looks like it cannot find the bcmath.so lib ((tried: /build/source/ext/bcmath/modules/bcmath.so (/build/source/ext/bcmath/modules/bcmath.so: undefined symbol: php_math_round_mode_from_enum),).

The issue has been discovered thanks to loophp/php-src-nix a project building all the existing PHP tags every night, including branch snapshots.

Find the last successful build at: https://github.com/loophp/php-src-nix/actions/runs/9925576082
Find the first failing build at: https://github.com/loophp/php-src-nix/actions/runs/10002990150/job/27649239736

@Girgias
Copy link
Member

Girgias commented Jul 28, 2024

@petk is this related to some recent build script changes?

@petk
Copy link
Member

petk commented Jul 28, 2024

@petk is this related to some recent build script changes?

I'm not sure I understand... This PR?

@drupol
Copy link
Contributor

drupol commented Jul 28, 2024

Bisected to this commit: 5905857

@petk
Copy link
Member

petk commented Jul 28, 2024

Ah, sorry, I didn't see the comment above. I'll check.

@petk
Copy link
Member

petk commented Jul 28, 2024

@Girgias, @drupol, @TimWolla, I think this should be the issue (there is missing PHPAPI). Is this it?

--- a/ext/standard/php_math_round_mode.h
+++ b/ext/standard/php_math_round_mode.h
@@ -52,4 +52,4 @@
 
 extern PHPAPI zend_class_entry *rounding_mode_ce;
 
-int php_math_round_mode_from_enum(zend_object *mode);
+PHPAPI int php_math_round_mode_from_enum(zend_object *mode);

Issue can be also reproduced like this:

./configure --enable-bcmath=shared
make
./sapi/cli/php run-tests.php -d extension_dir=modules ext/bcmath

@drupol
Copy link
Contributor

drupol commented Jul 28, 2024

Let me patch and retry.

@drupol drupol mentioned this pull request Jul 28, 2024
@drupol
Copy link
Contributor

drupol commented Jul 28, 2024

Yes, that fixed the issue immediately. I created the PR. Let me know if it's OK.

nielsdos pushed a commit that referenced this pull request Jul 28, 2024
Issue introduced in commit 5905857 from PR #14833
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.

6 participants