Skip to content

Segfault when using PTHREADS_INHERIT_NONE and calling global function #111

@dktapps

Description

@dktapps

In PHP 8.2, ZEND_INIT_FCALL assumes that the function exists: php/php-src@da684582d74

This is fine for normal code, but pthreads may copy classes without copying functions (even when PTHREADS_INHERIT_NONE is used), creating a problem - a mistake in code that would have previously caused a thrown Error will now crash the interpreter instead.

A few possible solutions:

  • Scan INIT_FCALL opcodes in copied op_arrays, and copy any functions found as dependent functions (similar to how we copy class hierarchies)
  • Use CG(compiler_options) |= ZEND_COMPILE_IGNORE_USER_FUNCTIONS - a quick and dirty fix, but this would cause minor performance degradation the first time a user function is called (probably OK for long-running applications?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions