php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79494 The 64-bit YAML ext uses 32-bit signed integer arithmetics
Submitted: 2020-04-19 15:50 UTC Modified: 2020-04-22 15:40 UTC
From: anrdaemon at yandex dot ru Assigned:
Status: Closed Package: yaml (PECL)
PHP Version: 7.4.5 OS: Windows
Private report: No CVE-ID: None
 [2020-04-19 15:50 UTC] anrdaemon at yandex dot ru
Description:
------------
Aside from stated issue of using 32-bit signed int to process data, there's no way to get a clean document out of the extension. Both yaml_emit and yaml_emit_file add unwanted crap to the output.

Test script:
---------------
<?php

$data = array (
  'audio' =>
  array (
    'audioEnabled' =>
    array (
      0 => 132317787432502136,
      1 => 0,
    ),
    'eveampGain' =>
    array (
      0 => 132316833510704299,
      1 => 0.25,
    ),
  ),
);

var_dump($data);

print yaml_emit($data);


Expected result:
----------------
Either

audio:
  audioEnabled: [132317787432502136, 0]
  eveampGain: [132316833510704299, 0.25]


or

audio:
  audioEnabled:
  - 132317787432502136
  - 0
  eveampGain:
  - 132316833510704299
  - 0.25


Actual result:
--------------
---
audio:
  audioEnabled:
  - -1654570120
  - 0
  eveampGain:
  - -2093628245
  - 0.250000
...

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-19 17:44 UTC] carusogabriel@php.net
Which version of the yaml extension are you using?

I couldn't reproduce this error using the latest `2.0.4`?
 [2020-04-19 21:37 UTC] anrdaemon at yandex dot ru
yaml

LibYAML Support => enabled
Module Version => 2.0.4
LibYAML Version => 0.1.4 (PHP 7.0, 7.1), 0.1.7 (7.2+)

Directive => Local Value => Master Value
yaml.decode_binary => 1 => 1
yaml.decode_php => 0 => 0
yaml.decode_timestamp => 1 => 1
yaml.output_canonical => 0 => 0
yaml.output_indent => 2 => 2
yaml.output_width => -1 => -1


The results are the same for every PHP version starting from 7.0 (5.6 is different for obvious reasons, as PHP5/64 only supports 32-bit integers under Windows).

Full example output for phpinfo can be found at https://pastebin.com/9zmQXRr7
 [2020-04-19 21:48 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-04-19 21:48 UTC] cmb@php.net
This is a Windows (or more precisely LLP64) only issue.

> Both yaml_emit and yaml_emit_file add unwanted crap to the
> output.

Are you referring to the document separator/terminator?
 [2020-04-19 21:49 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #79494: The 64-bit YAML ext uses 32-bit signed integer arithmetics
On GitHub:  https://github.com/php/pecl-file_formats-yaml/pull/39
Patch:      https://github.com/php/pecl-file_formats-yaml/pull/39.patch
 [2020-04-20 12:55 UTC] anrdaemon at yandex dot ru
> This is a Windows (or more precisely LLP64) only issue.

Is this the same problem that caused PHP5/64 to only support 32-bit integers?
Seeing as it was resolved for PHP7, can this be resolved for extension as well?

> Are you referring to the document separator/terminator?

I'm well aware what they mean, but I did not ask for a multi-document output, therefore, the addition is unwanted.
 [2020-04-22 15:40 UTC] cmb@php.net
> Is this the same problem that caused PHP5/64 to only support
> 32-bit integers?

It is related.  On LP64 architectures, a long has 64 bits, on
LLP64 it has only 32 bits.  Since PHP integers have been stored as
long, 64 bit integers have not been supported on Windows.

> Seeing as it was resolved for PHP7, can this be resolved for
> extension as well?

If the extensions already use zend_long (or zend_ulong), that
should already be resolved, but sometimes there is still a long
involved (or in this case a printf format specifier for long), so
some bug fixes are still pending.
 [2020-04-22 19:03 UTC] bd808@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=pecl/file_formats/yaml.git;a=commit;h=8208159765171a5b05be069ae2c1b0ca04feb374
Log: Fix #79494: The 64-bit YAML ext uses 32-bit signed integer arithmetics
 [2020-04-22 19:03 UTC] bd808@php.net
-Status: Verified +Status: Closed
 [2020-04-22 20:52 UTC] anrdaemon at yandex dot ru
Thanks for the patch.
Now I could at least export the data…
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 07:03:33 2021 UTC