Skip to content

Replaced wrong type of "addr" in pcntl_signal callback arg #9832

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Cobalt-Inferno
Copy link

@Cobalt-Inferno Cobalt-Inferno commented Oct 26, 2022

Inside ext/pcntl/pcntl.c there was usage of add_assoc_double_ex() whilst also casting to (zend_long)
I replaced it with add_assoc_long_ex()

Closes GH-9815

@Girgias Girgias requested a review from TysonAndre October 27, 2022 13:47
@TysonAndre TysonAndre changed the title Replaced wrong type Replaced wrong type of "addr" in pcntl_signal callback arg Oct 30, 2022
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.

Thank you! This sounds reasonable. This does justify a mention in UPGRADING (since it oculd break === comparison). This can be done by whoever merges this.

@cmb69
Copy link
Member

cmb69 commented Nov 2, 2022

Maybe @arnaud-lb remembers why a double was used in the first place (cf. c58e2b9).

@arnaud-lb
Copy link
Member

Unfortunately I can't remember. Apparently I exposed the int fields of siginfo_t with add_assoc_long and larger ones with add_assoc_double, so it may have been a (wrong) way to support systems with sizeof(void*) > sizeof(long).

The change looks good to me.

We could also expose addr as a string for the following reasons:

  • It would avoid high values of addr being represented as negative values
  • Although unlikely, sizeof(void*) > sizeof(zend_long) is theoretically possible

@cmb69
Copy link
Member

cmb69 commented Nov 2, 2022

We could also expose addr as a string for the following reasons:

That might indeed be even more reasonable.

@cmb69
Copy link
Member

cmb69 commented Dec 1, 2022

This does justify a mention in UPGRADING (since it oculd break === comparison).

This is an important point! If we introduce a small BC break (I doubt, though, that anybody compares addresses), we should probably have a string right away.

@haq0
Copy link

haq0 commented Apr 3, 2023

Will this still be useful or should it not be merged?

@iluuu1994
Copy link
Member

We could also expose addr as a string for the following reasons:

  • It would avoid high values of addr being represented as negative values
  • Although unlikely, sizeof(void*) > sizeof(zend_long) is theoretically possible

This is an important point! If we introduce a small BC break (I doubt, though, that anybody compares addresses), we should probably have a string right away.

I think that was the main takeaway. Using a string representation for the pointer might make more sense.

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.

pcntl_signal for SIGILL/SIGFPE/SIGSEGV/SIGBUS should add addr as int or string, not double
6 participants