Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Stack overflow exception when starting new threads #797

Closed
dktapps opened this issue Jan 12, 2018 · 6 comments
Closed

Stack overflow exception when starting new threads #797

dktapps opened this issue Jan 12, 2018 · 6 comments

Comments

@dktapps
Copy link
Contributor

dktapps commented Jan 12, 2018

Environment

  • PHP: 7.2.1
  • pthreads: 43ffd00
  • OS: Windows 10 x64

Summary

Running the below test case on Windows with latest pthreads yields a stack overflow exception in pthreads_store_create().

This bug appears to occur when an interface constant is accessed via a class which implements the interface, and then a thread is started. Crucially, in the test case:

var_dump(MyClass::PIG);
var_dump(MyClass::COW);

produces the stack overflow, while:

var_dump(TestInterface::PIG);
var_dump(TestInterface::COW);

does not.

It is necessary to have the TestInterface class loaded by an autoloader, or the bug does not occur.

Reproducing Code

Test case: https://github.com/dktapps/pthreads-stack-overflow-test
Usage:

composer install
php run.php

Expected Output

int(1)
int(2)

and correct shutdown

Actual Output

int(1)
int(2)

followed by stackoverflow exception (debugged with Visual Studio).

Visual Studio debugging

Unhandled exception at 0x00007FFE5694FAE7 (php_pthreads.dll) in php.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x00000037BDE03FF8). occurred

Gigantic stack trace (be warned, it's about 6000 lines long): https://gist.github.com/dktapps/2cf08ea2b2fa93e01f9656fe303995fb

@dktapps
Copy link
Contributor Author

dktapps commented Jan 12, 2018

Additional note: I'm currently using 1c9787e for production and this test case works fine there.

@sirsnyder
Copy link
Collaborator

Can you reproduce this bug on unix or is it windows only?

@dktapps
Copy link
Contributor Author

dktapps commented Jan 12, 2018

@sirsnyder I quickly tested and it also crashes on linux, yes. Haven't done any debugging on linux but one would assume the cause is the same.

@sirsnyder
Copy link
Collaborator

At a first sight, the offending commit is 4c978ec.

@sirsnyder sirsnyder reopened this Jan 13, 2018
@sirsnyder
Copy link
Collaborator

sirsnyder commented Jan 13, 2018

Could you please test this fix?

@dktapps
Copy link
Contributor Author

dktapps commented Jan 13, 2018

looks like it's fixed, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants