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

date_sun_info() fails for non-finite values #14732

Open
YuanchengJiang opened this issue Jun 30, 2024 · 0 comments · May be fixed by #16497
Open

date_sun_info() fails for non-finite values #14732

YuanchengJiang opened this issue Jun 30, 2024 · 0 comments · May be fixed by #16497

Comments

@YuanchengJiang
Copy link

YuanchengJiang commented Jun 30, 2024

Description

The following code:

<?php
$nan = NAN;
date_sun_info(1, $nan, 1);

Resulted in this output:

/php-src/ext/date/lib/astro.c:268:17: runtime error: -nan is outside the range of representable values of type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/date/lib/astro.c:268:17

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

cmb69 added a commit to cmb69/php-src that referenced this issue Oct 18, 2024
`timelib_astro_rise_set_altitude()` is not prepared to deal with non-
finite values (`nan`, `inf` and `-inf`) for `lon` and `lat`; instead
these trigger undefined behavior.  Thus we catch non-finite values
before even calling that timelib function; for `date_sun_info()` we
trigger `ValueError`s; for `date_sunrise()` and `date_sunset()` we
silently return `false`, since these functions will be sunsetted
anyway.
@cmb69 cmb69 changed the title Unexpected -nan value in ext/date/lib/astro.c date_sun_info() fails for non-finite values Oct 18, 2024
@cmb69 cmb69 linked a pull request Oct 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants