Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112808 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33848 invoked from network); 8 Jan 2021 03:09:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jan 2021 03:09:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D47251804DD for ; Thu, 7 Jan 2021 18:46:36 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11olkn2025.outbound.protection.outlook.com [40.92.18.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 7 Jan 2021 18:46:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bG7HoxoeJ7d/kzO+H11hGV9mqQu7OrmV3S8Z7vJ/bex9HSizs2VBJHhZDz9HCI0Gk4bgQO611RYwlPBLPYQ2c4PDjxtS0c2qRsdXOcvwx/VHMJ7uiIl109/LMGfqIB4H4GU4++A8gBLW43FwI8b2G2SQHW/bzRBfExNAGWlYssPrC5Ov8sZhhvtNFMI93q742v+dQhknzRGXKHQ6wGFesSl0yQHUkGetOtBFV9pViZYu6B9vHh6SzvxF1LkueIWQgJPrLHJott1xJ/QTmN6jhahr/6wN8xIS9gj99AVxg6U3K+Mdc5BTBG6yLmdtpmQwA8X3TgUX8Q2LzHts2henvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X/WQ5y2jPOXcG1Lmi3ta5hXnhLVtlzCLvnfKfcCol0s=; b=mQxVJLVCsU1YUO5zN+lpdCTghptrmdSkyqVVrhOetkuEtnJvYkv3XqxVjQfr4lg9grDHQ4o6vJf5H3kvsEVeN8mdJcP4gmsqGxhriT/ORiAhzg51hfzaHwtkgFxsgx2mol9nnpLH/pgGDffg2/Ofk/pZ9Y/SNpmv2VQmnAHm4YC8QXadwXKiM7vGtbuTodKHEwikH+dn7RKCQ8rZ+Bma+8dnSmkPBxCeQp/VKVXKHqWTOw+kDC/gcYyWfq98NFehO4JqojbBUE2Atc/7Elqv2BtN5LPt5yk8fllfyWwhPqEKRUCe6od1k2Ga/++JddUxxZVfHRNHiE+ypHBlLzFV8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X/WQ5y2jPOXcG1Lmi3ta5hXnhLVtlzCLvnfKfcCol0s=; b=GxIFmQBGPAZ8jS1AhUjYp9/REcptNQtvf9Emx7Licrgs5OlSAmkcdS6In5w9gbxN15A1wYnA3g6mqOHeUcELaPGOz7BuFZtfz4hbSZL9QtBVndR4I+4gIeVp2v8Os228SitB4um+a13kbIqyhK7GAAQjyLdBBM353XPgR0APDPRNli4vqyVfTAkL8oW9qpxyKAgLZouxjGD0AHE9NJHgvNp/9rgzlPzbtUIzy6YbGU3FXsShB+yFJwqV8NAGMCNbcGAewkmChMmfGw94nz8SRiXsZnTpocvJu8KqiSYcQUBFcSwA24/1jm3koESJTk67Bq5VIH2PcBgoy2a69APiLA== Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::51) by CO1NAM11HT091.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::412) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Fri, 8 Jan 2021 02:46:34 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:3861::4e) by CO1NAM11FT033.mail.protection.outlook.com (2a01:111:e400:3861::247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Fri, 8 Jan 2021 02:46:34 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d%4]) with mapi id 15.20.3721.024; Fri, 8 Jan 2021 02:46:34 +0000 To: "internals@lists.php.net" Thread-Topic: Are there plans for ending support for 32-bit php? (year 2038 problem) Thread-Index: AQHW5QQBTX/TWSRVNESaGhAznNvRyQ== Date: Fri, 8 Jan 2021 02:46:34 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:1D3EB2624AB684133645FDD4DA1286D2318D4728F6773DB3A29672B444ACCE9B;UpperCasedChecksum:618F810FD172E2E138FE88D7A5A2BB46C9C478D7593A20B6AD94E80898AA76D1;SizeAsReceived:6858;Count:41 x-tmn: [bqpvQvL4HDclmj9wVesdS7AhaXN+2u8tbbAEKcizojOsbHgmy8bEpspx5XwN7W+c] x-ms-publictraffictype: Email x-incomingheadercount: 41 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: acf3164a-e19a-4270-e3cf-08d8b37f9ca1 x-ms-traffictypediagnostic: CO1NAM11HT091: x-ms-exchange-minimumurldomainage: externals.io#1650 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: slbo8RvnkpNiUx4C5ZaGw/35no6MAWD3yrSBC8kyBGPhLKlstyxmqxsS27mdCv+DryNa49GSeedSuV7dNBCoDlU+Bvt6BwDAV/l2y3B4kXfGH7+C6NfL2Bpyq90yKmfo6iPUdw0qq3Fc9imaMhLUQy4VTciD1cIhfr0zWgpzcSzooC7hwPO0FuvuzjtypRA39Y+9gg/IROiCw6dEW5YROEiziI/wg6kvqEMYWJUlFfNS38IfkC2mT93mLM0dxqPL5XeafN/r7vPXUAVKyP+M1CB2ZsqC5N6RnH7Jz+7QO4Q= x-ms-exchange-antispam-messagedata: 40Ay5PRGUTknMBIUtt1vGjCTgSfnyrE416hX6Diah/NoUVBf9tknuD0LPgjySU2XMICJqIwW1PCueLFr+7ednHa7oBdH8C8SxB5iqxd5vYo1GpAirILgyuT94ZqQ9HWL+WNxXiBZJBngm72Aiwy304SVq+MDirS5wS+vNHWRMFQW1+wNBlwavnXF8RyBP7qIOHZZcj6xIPQMvTrrCO5ikw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: acf3164a-e19a-4270-e3cf-08d8b37f9ca1 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2021 02:46:34.2079 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM11HT091 Subject: Are there plans for ending support for 32-bit php? (year 2038 problem) From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= 1. In 2038, `(new DateTime())->getTimestamp()` and other time apis such as = strtotime will start throwing "ValueError: Epoch doesn't fit in a PHP integ= er"=0A= on 32-bit php builds, where PHP's `int` type is 32-bits.=0A= (other APIs will return negative 32-bit integers)=0A= See https://en.wikipedia.org/wiki/Year_2038_problem=0A= 2. Because PHP provides security support for 3 years, and many `*nix` OS LT= S releases extend it even longer, we should decide on what to do about=0A= 32-bit support well before 2038 (drop it or implement alternatives, and = alternatives seem unlikely to support a small fraction of hardware).=0A= 3. Needing to support 32-bit PHP builds limits the APIs that can be include= d in PHP, and slightly slows down development of PHP, PECLs, and composer p= ackages.=0A= 4. I think PHP's documentation and tools should start discouraging deployin= g new 32-bit builds, and give advance notice that it would be removed (if i= t seems likely 32-bit support will be dropped.)=0A= =0A= Repeating the above points in more detail,=0A= =0A= 1) In the year 2038, many of 32-bit php builds' APIs dealing with unix time= stamps will stop working.=0A= E.g. in 2038 on a 32-bit build of php, `(new DateTime())->getTimestamp()` w= ould throw "ValueError: Epoch doesn't fit in a PHP integer" instead of retu= rning an int,=0A= when the time passes 0x7FFFFFFF. See=A0https://bugs.php.net/bug.php?id=3D52= 062 for details.=0A= I'd consider throwing in getTimestamp to be the most reasonable solution, g= iven the return type of those methods is `int`, existing code may pass the = return value=0A= to a function/property with real type int, etc.=0A= =0A= - https://www.drupal.org/docs/system-requirements/limitations-of-32-bit-php= =0A= =0A= 2) Although php's security support for a minor release lasts for only 3 yea= rs,=0A= some `*nix` OSes will make a best effort at unofficially backporting patche= s to php for the lifetime of that OS's LTS release,=0A= so we could potentially see 32-bit builds for ~10 years (not sure what 32-b= it distros there will be in 2028. This number is a guess.)=0A= - on **desktop** oses, the main use of 32-bit packages on 64-bit hardware s= eems to be for supporting code released for only one architecture,=0A= e.g. https://ubuntu.com/blog/statement-on-32-bit-i386-packages-for-ubuntu= -19-10-and-20-04-lts=0A= - Many WordPress servers still run php 5.x.=0A= - If applications running on an OS with 10 years of php support computed da= tes that are a year in the future,=0A= it'd be useful to prepare 11 years in advance.=0A= There are 17 years until 2038.=0A= =0A= Hardware that only has 32-bit support is still running on a small fraction = of machines being sold (e.g. cheap laptops),=0A= and 32-bit hardware may last decades after they were manufactured,=0A= but is hopefully a tiny fraction of server/consumer hardware still being ma= nufactured in 2021.=0A= I don't know of 32-bit php running in embedded systems or IoT devices, but = haven't looked.=0A= - Aside: It is possible to install a 32-bit only OS on hardware supporting = 64-bit architectures, https://www.backblaze.com/blog/64-bit-os-vs-32-bit-os= /=0A= =0A= If PHP's maintainers decide to drop support for 32-bit builds in a future m= ajor/minor release, it would be useful to give users advance notice,=0A= so that they can factor this into decisions on hardware and OSes to use for= deploying php in servers or developing locally.=0A= =0A= 3) Needing to support 32-bit PHP builds limits what can be done in the lang= uage, and slightly slows down development of PHP, PECLs, and composer packa= ges.=0A= =0A= Additionally, continuing to provide 32-bit support constrains what APIs can= be provided by the language.=0A= In most cases this isn't an issue, but this came up with `PRNG->next64BitIn= t()` being impractical practical in a recent proposal: https://externals.io= /message/112525#112722=0A= =0A= - 32-bit installations do reduce the memory usage and installation size of = php slightly,=0A= but those installations would have problems with the 2038 problem and sup= porting use cases that require more than 2-4GB of free memory.=0A= - PECLs and composer packages are generally not tested as thoroughly on 32-= bit builds.=0A= Maintainers may be less responsive if they're personally unaffected, or d= on't already have 32-bit builds installed, or don't know from the bug repor= t that 32-bit php was used.=0A= - The PHP interpreter (Zend/zend_vm_def.h, etc.) and JIT have different imp= lementations for 32-bit builds, complicating development of php itself.=0A= Hypothetically that could lead to bugs getting released and contributing = to the VM being harder to do, but in practice it doesn't seem to be a large= issue.=0A= =0A= In comparison, other languages I've used would have an easier time continui= ng to support 32-bit builds past 2038.=0A= =0A= - Python and Ruby have arbitrary-precision numbers.=0A= - In Java, `int` is 32-bit, and `long` is 64-bit.=0A= - Golang and C and rust have `int64_t` and `int32_t` equivalents, but also = support a separate `int` for the native word size.=0A= - Javascript only has a `Number` type that is equivalent to 64-bit floats. = JS also has a distinct BigInt object type for arbitrary precision numbers.= =0A= =0A= I'd considered some alternatives, but they didn't seem viable:=0A= a. Changing the signature of getTimestamp(etc.) to `int|float` would cause = different issues once the floats were used and make static analysis harder = - applications may see obvious TypeErrors,=0A= or functions returning early for non-integers, or subtler issues with se= rializing data as an unexpected type=0A= b. Using 64-bit integers for PHP's int type (`zend_long`) (but continuing t= o use 32-bit pointers, etc.) for PHP's `int` didn't seem worth the effort a= nd bugs it may cause.=0A= A lot of php internals or PECL code would implicitly assume that `sizeof= (zend_long) <=3D sizeof(size_t), sizeof(void*)` (etc.) and I'd expect chang= ing that to lead to too many bugs to be worth it.=0A= =0A= 4) I have some modest proposals for discouraging the deployment of 32-bit P= HP builds before they are removed (if 32 bit builds do get removed):=0A= =0A= If the PHP project's leaders or core developers don't have objections to dr= opping 32-bit support:=0A= =0A= a. Decide whether to postpone making a decision, or decide on an approximat= e year or release to announce that the php project would drop 32-bit suppor= t and document that.=0A= to give users and package maintainers advance time to prepare. (e.g. for= developers to choose their next computer purchase, avoid hypothetically se= lling embedded 32-bit hardware with 32-bit php installed, or setting up new= servers or shared hosting on 32-bit hardware)=0A= b. Optionally, visually emphasize 64-bit downloads of PHP on the windows do= wnload page to make the recommended version obvious to users unfamiliar wit= h the difference between x64 and x86 builds,=0A= similar to how https://golang.org/dl/ highlights 64-bit builds in bold.= =0A= (e.g. on https://windows.php.net/download/ , use fainter text color, men= tion that most use cases use x64, and optionally mention how to check if th= e OS is 32-bit Windows)=0A= c. In parts of php that would not affect typical PHP applications or server= s, mention (when run under 32-bit builds) that 32-bit builds of php may bre= ak in 2038 and that users should migrate before then=0A= (e.g., `php -a`, `php --version`, `php --help`, `./configure`, `pecl`, = near the top of `phpinfo()`)=0A= =0A= The last time I saw the year 2038 problem mentioned on php-internals was ta= ngentially, in 2014: https://marc.info/?l=3Dphp-internals&m=3D1405581532133= 32&w=3D2=0A= =0A= Thanks,=0A= - Tyson=0A=