Skip to content

Conversation

samding01
Copy link
Contributor

This PR fixes the 75863

Note type (StateCheckNumType) is defined as "short" (ext/mbstring/oniguruma/src/regint.h),
while "mem" is int,

191 #define PLATFORM_GET_INC(val,p,type) do{\
192   val  = *(type* )p;\
193   (p) += sizeof(type);\
194 } while(0)
...
553 #define GET_STATE_CHECK_NUM_INC(num,p)  PLATFORM_GET_INC(num, p, StateCheckNumType)

which causes the issue on Big_Endian platforms.

The solution: change StateCheckNumType as int on s390x,
and ifdef for safe on other platforms.

@cmb69
Copy link
Member

cmb69 commented Feb 23, 2018

Hmm, shouldn't that be fixed upstream?

@samding01
Copy link
Contributor Author

samding01 commented Feb 26, 2018

@cmb69 when you refer kkos/oniguruma code, did you just copy/paste?
Do not know how to fix on kkos/oniguruma side?
By the way, kkos/oniguruma just defined StateCheckNumType like:

 fgrep -R StateCheckNumType *
src/regint.h:typedef short int StateCheckNumType;
src/regexec.c:  StateCheckNumType scn;

But does not use as in the macro and pointer operations that causes the problem on big_endian platform

@cmb69
Copy link
Member

cmb69 commented Apr 5, 2018

But does not use as in the macro and pointer operations that causes the problem on big_endian platform

Indeed, see kkos/oniguruma#86.

Anyhow, it seems we need a slightly more general solution here, since the PR only caters to s390x, but
other big-endian platforms are affected as well. I wonder whether we could simply use typedef int StateCheckNumType everywhere.

Also, it is unclear whether the fix has to be applied to PHP-7.1, too.

@samding01
Copy link
Contributor Author

@cmb69 It is fine to simply use typedef int StateCheckNumType if you think it is safe not to limit to only s390x.
Created a PR on PHP-7.1 (#3277)
Please review

@samding01
Copy link
Contributor Author

@cmb69 , please see the reviews on #3277. What is the suggested solution?

@cmb69
Copy link
Member

cmb69 commented Jun 8, 2018

What is the suggested solution?

For master, we don't need a fix, since StateCheckNumType is unused as of Oniguruma 6.8.2.

If the issue will not be fixed for PHP-7.1 for ABI compatibility reasons, it should not be fixed for PHP-7.2 for the same reasons.

@nikic
Copy link
Member

nikic commented Jun 8, 2018

@cmb69 I'd say we can merge this into 7.1, because

  • There is an upstream fix in master, so it's fine to apply a custom patch on lower branches.
  • S390X is not a mainstream platform, so any impact will be niche. Given that oniguruma currently doesn't work there due to this issue, I'd say the question of ABI compatibility is somewhat moot.

@cmb69
Copy link
Member

cmb69 commented Jun 8, 2018

S390X is not a mainstream platform, so any impact will be niche.

If we take this PR literally, yes. However, other big endian platforms are likely affected as well, and a more general solution (PR #3277) has been rejected by Joe for being an ABI break. I do not agree with that, though.

PS: see the related https://bugs.php.net/76183.

@smalyshev smalyshev added the Bug label Jun 20, 2018
@samding01
Copy link
Contributor Author

Can you let me know if this PR will be merged or not?
Thanks,

@cmb69
Copy link
Member

cmb69 commented Jul 10, 2018

@sgolemon Since this PR targets PHP-7.2, what do you think?

@samding01 samding01 closed this Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants