Skip to content

UBSan: date_sun_info() triggers undefined behavior with PHP_INT_MAX arguments (NaN to long long cast) #20966

@arshidkv12

Description

@arshidkv12

Description

The following code:

<?php
var_dump(date_sun_info( 140, PHP_INT_MAX ,PHP_INT_MAX));

Resulted in this output:

var_dump(date_sun_info( 140, PHP_INT_MAX ,PHP_INT_MAX));

But I expected this output instead:

array(9) {
  'sunrise' =>
  int(0)
  'sunset' =>
  int(0)
  'transit' =>
  int(0)
  'civil_twilight_begin' =>
  int(0)
  'civil_twilight_end' =>
  int(0)
  'nautical_twilight_begin' =>
  int(0)
  'nautical_twilight_end' =>
  int(0)
  'astronomical_twilight_begin' =>
  int(0)
  'astronomical_twilight_end' =>
  int(0)
}

PHP Version

PHP 8.6.0-dev (cli) (built: Jan 18 2026 17:43:31) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions