Php8-cli timezone database segfault at 34

Hi,
I saw that this problem has already been mentioned twice, both with php7 and php8.
In both cases it was considered resolved by editing the php.ini.

I tried this too and it didn't work.
When executing the phpinfo() function, the timezone corresponds to the one defined in the php.ini (date.timezone = Europe/Berlin).
But when executing the date() function, the Segmentation fault error occurs.
I wrote a program to test in which situations the error occurs:

<?php
//	Only for debugging TZ error
	f_time("CET");
	f_time("UTC");
	f_time("EST");
	f_time("Asia/Singapore");
	f_time("Europe/Berlin");
	echo(PHP_EOL.PHP_EOL.date("d/m/Y-H:i:s").PHP_EOL);

function f_time($zone) {
	echo("Time now in ".(date_default_timezone_set($zone) ? (date_default_timezone_get().": ".date("d/m/Y-H:i:s")) : 'TZ error: '.$zone." is invalid").PHP_EOL);
}
?>

The result of the execution with php-cli is:

Time now in CET: 21/02/2023-13:45:53
Time now in UTC: 21/02/2023-12:45:53
Time now in EST: 21/02/2023-07:45:53

Fatal error: Uncaught Error: Timezone database is corrupt. Please file a bug report as this should never happen in /overlay/reactphp/Foxbit6/timezoneError.php:11
Stack trace:
#0 /overlay/reactphp/Foxbit6/timezoneError.php(11): date_default_timezone_get()
#1 /overlay/reactphp/Foxbit6/timezoneError.php(6): f_time('Asia/Singapore')
#2 {main}
  thrown in /overlay/reactphp/Foxbit6/timezoneError.php on line 11

Comment: When commenting line with "Asia/Singapore", the same error occurs on line with "Europe/Berlin".

Another thing that caught my attention was that the result of the timezone_abbreviations_list() function does not contain many cities. But it contains for example "Asia/Singapore" which also gives the error. So this table returned by the timezone_abbreviations_list() function doesn't seem to be used.

This seems to be a Bug. Can anyone help me?

Best, and thanks in advance,
carliedu

I think this is a Bug in compilation.

Same issue here.

date_default_timezone_set('America/Los_Angeles');
echo ini_get('date.timezone');

Shows nothing! Meaning you cannot set it manually either. Probably the datetime class is missing or something.
Or probably the timezone database is missing -> https://www.php.net/manual/en/datetime.installation.php

Edit: I think somebody has reduced the database by purpose for smaller size of php core

You can use EET, EST, UTC and similar

Normally the full timeline database is not installed by default into OpenWrt, and you need to manually install those zoneinfo packages that you need.

1 Like

I have installed zoneinfo-southamerica and upgraded all packages of OpenWrt 22.03.3 r20028-43d71ad93e, without solution.
All php 8.1.18-1 are installed and upgraded.

I found the trick.
I downloaded https://downloads.openwrt.org/releases/22.03.3/packages/x86_64/packages/zoneinfo-southamerica_2023c-1_x86_64.ipk and unpacked it.
The timezone "America/Sao_Paulo" isn't included in zoneinfo-southamerica where are defined 4 zones, where Sao_Paulo belongs to "Brazil/East". I tested it on PHP8 as "Brazil/East" and it works.
Than I downloaded https://downloads.openwrt.org/releases/22.03.3/packages/x86_64/packages/zoneinfo-northamerica_2023c-1_x86_64.ipk and found Sao_Paulo there.

I think the problem is resolved.

but in zoneinfo-northamerica.

Looking at the zone listing in https://en.m.wikipedia.org/wiki/List_of_tz_database_time_zones , the Brazil zone is deprecated, offered for backward compatibility, and is actually a link to Sao_Paulo. See also https://en.m.wikipedia.org/wiki/Time_in_Brazil

Looking at the downloadable zoneinfo OpenWrt package sizes, the northamerica is large, while southamerica is really small, almost empty. I wonder if our local Makefile is outdated and does not take into account the structural changes in the last decade, when IANA timezones have been simplified to some extent.

Edit:
Yeah, the zoneinfo Makefile is structurally 9 years old, and apparently does not take into account the upstream structural changes since then.

1 Like

I made a PR to straighten the zoneinfo packages a bit (e.g. combine Americas),

but that PR does not touch php's internal database. See

1 Like