Skip to content

ext/gettext: dcgettext/dcngettext sigabrt on macOs. #13555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

devnexen
Copy link
Member

the man page states the locale facet is determined by the category argument, which should be one of the LC_xxx constants defined in the <locale.h> header, excluding LC_ALL,
since the 0.22.5 release, sanity checks had been strenghtened leading to an abort with the Zend/tests/arginfo_zpp_mismatch.phpt test setting the category to 0 which is LC_ALL on macOs.

@devnexen devnexen force-pushed the fix_gettext_0225_abort branch 4 times, most recently from a4d7f0d to f5215c9 Compare February 29, 2024 00:20
@devnexen devnexen marked this pull request as ready for review February 29, 2024 00:20
@SakiTakamachi
Copy link
Member

It looks like the test has been interrupted, so you might want to force push again.

@devnexen devnexen requested a review from kocsismate February 29, 2024 07:33
@devnexen devnexen force-pushed the fix_gettext_0225_abort branch from f5215c9 to c422d09 Compare February 29, 2024 07:35
the man page states `the locale facet is determined by the category argument,  which  should  be
 one of the LC_xxx constants defined in the <locale.h> header, excluding LC_ALL`,
since the 0.22.5 release, sanity checks had been strenghtened leading to
an abort with the Zend/tests/arginfo_zpp_mismatch.phpt test setting the
category to 0 which is LC_ALL on macOs.
@devnexen devnexen force-pushed the fix_gettext_0225_abort branch from c422d09 to 183f51d Compare February 29, 2024 16:12
Copy link
Member

@kocsismate kocsismate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally: LGTM, very nice catch!

However, adding a new exception in existing releases is an extremely rare situation... so I'm wondering if it would be worth to only add it for v0.22.5+ in case of PHP 8.3 and below. On the other hand, master could throw an exception for each gettext version of course. Inviting @Girgias and @bukka for discussion.

@iluuu1994
Copy link
Member

iluuu1994 commented Mar 4, 2024

Throwing in a particular gettext version would require an API to recognize the version at runtime, because the library is usually dynamically linked. Unfortunately I couldn't find such an API.

If BC breaks are a concern, we may merge this only for master. However, note that segfaults or undefined behavior are likely worse than an exception, which will happen once people update gettext.

Alternatively we may try to simulate the old behavior. I'm not really familiar with gettext, so I don't know if that's possible.

@devnexen
Copy link
Member Author

devnexen commented Mar 4, 2024

This change might not be too impactful ; ideally users already put those calls into a try/catch block since it can already throw for other reasons

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. In that case I'd say let's merge this. It's better to throw than to segfault.

@devnexen devnexen closed this in 9999a0c Mar 4, 2024
@bukka
Copy link
Member

bukka commented Mar 4, 2024

What was the previous behavior? I mean what happens in the previous version of gettext if LC_ALL provided?

@bukka
Copy link
Member

bukka commented Mar 4, 2024

Not really comfortable with this going to stable branches as RM...

@devnexen
Copy link
Member Author

devnexen commented Mar 4, 2024

What was the previous behavior? I mean what happens in the previous version of gettext if LC_ALL provided?

let's say the functions did not follow the contract, trying with 0.21 the call does return the msgid as no conversion occurs but does not trigger any error neither.

@bukka
Copy link
Member

bukka commented Mar 4, 2024

So what is being returned? I mean what is in msgstr? empty string?

@bukka
Copy link
Member

bukka commented Mar 4, 2024

I'm just on my mac and lazy to get older gettext version installed :)

@bukka
Copy link
Member

bukka commented Mar 4, 2024

Also what do we get on other platforms?

@bukka
Copy link
Member

bukka commented Mar 4, 2024

Basically I think we should keep the behavior as it was in stable versions. I'm fine with exception in master though

@devnexen
Copy link
Member Author

devnexen commented Mar 4, 2024

So what is being returned? I mean what is in msgstr? empty string?

in this case then yes empty string.

@devnexen
Copy link
Member Author

devnexen commented Mar 4, 2024

Basically I think we should keep the behavior as it was in stable versions. I'm fine with exception in master though

what do you suggest ? if LC_ALL return msgid (not calling the function at all) ?

@bukka
Copy link
Member

bukka commented Mar 4, 2024

yeah exactly, return empty string if LC_ALL without even calling the function and just do the exception in master with note in UPGRADING.

devnexen added a commit to devnexen/php-src that referenced this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants