Skip to content
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

Shutdown hangs at "Stopping CommandReader thread" on some systems #25

Closed
dktapps opened this issue Oct 14, 2016 · 13 comments
Closed

Shutdown hangs at "Stopping CommandReader thread" on some systems #25

dktapps opened this issue Oct 14, 2016 · 13 comments
Labels

Comments

@dktapps
Copy link
Member

dktapps commented Oct 14, 2016

Issue description

On Windows, shutdown will hang at "Stopping CommandReader thread" until another input is received, such as hitting the Enter key.

Why this happens

stream_set_blocking() does not work on Windows. This results in the fgets() call to stdin to block the thread until another input is received. This issue does not occur on Linux as far as I can tell.

Possible solutions

This is a rather difficult problem to resolve cleanly. Since Thread::kill() was removed from pthreads in v3, the thread cannot be forcefully killed.
I have made a previous attempt to resolve this with an implementation using stream_select which also fails on Windows (returns 1 when no streams have changed >:-[)

Steps to reproduce the issue

  1. Shut down a PocketMine server on Windows using /stop

OS and versions

  • PocketMine-MP: 2fba107
  • PHP: 7.0+
  • OS: Any Windows version

References

PocketMine/PocketMine-MP#3990
https://bugs.php.net/bug.php?id=34972

@iPocket
Copy link
Contributor

iPocket commented Oct 14, 2016

I've already reported that to @PEMapModder before in Feb :P

On 14 October 2016 at 16:34, Dylan K. Taylor notifications@github.com
wrote:

Issue description

On Windows, shutdown will hang at "Stopping CommandReader thread" until
another input is received, such as hitting the Enter key.
Why this happens

stream_set_blocking() does not work on Windows. This results in the
fgets() call to stdin to block the thread until another input is
received. This issue does not occur on Linux as far as I can tell.
Possible solutions

This is a rather difficult problem to resolve cleanly. Since
Thread::kill() was removed from pthreads in v3, the thread cannot be
forcefully killed.
I have made a previous attempt to resolve this with an implementation
using stream_select which also fails on Windows (returns 1 when no
streams have changed >:-[)
Steps to reproduce the issue

  1. Shut down a PocketMine server on Windows using /stop

OS and versions

References

PocketMine/PocketMine-MP#3990
PocketMine/PocketMine-MP#3990
https://bugs.php.net/bug.php?id=34972


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#25, or mute the thread
https://github.com/notifications/unsubscribe-auth/ARVBWt38EMUe5YYFbN1EMg3O2NjUBwGbks5qz4TOgaJpZM4KXA5P
.

@SOF3 SOF3 added Category: Core Related to internal functionality Status: Debugged Cause of the bug has been found, but not fixed labels Oct 14, 2016
@PrimusLV
Copy link

Can't we just fake the input?

@dktapps
Copy link
Member Author

dktapps commented Oct 18, 2016

@PrimusLV I tried, it either fails or segfaults.

@TDMidkwhatisxd
Copy link

Confirmed on linux too

@robske110
Copy link
Contributor

robske110 commented Oct 23, 2016

I don't have this in macosx, can't believe this happening on Linux

@TDMidkwhatisxd
Copy link

It happens on centos! If i stop server , i need to write a letter and submit , to stop! Didnt try to simply press enter xd!

@legoboy0215
Copy link
Contributor

This strangely doesn't happen to me.

@robske110
Copy link
Contributor

robske110 commented Oct 24, 2016

And for all who have this issue on Linux/UNIX-based stuff try to update php. I don't think that this can happen in any Linux system

@pmmp pmmp locked and limited conversation to collaborators Oct 24, 2016
@dktapps
Copy link
Member Author

dktapps commented Oct 24, 2016

THIS IS NOT A FORUM. Continue to treat it as one and bans will start getting handed out.

@pmmp pmmp unlocked this conversation Nov 4, 2016
@dktapps
Copy link
Member Author

dktapps commented Nov 5, 2016

Reproduced on other platforms (circumstances unknown).

@SOF3 SOF3 changed the title Shutdown hangs at "Stopping CommandReader thread" on Windows Shutdown hangs at "Stopping CommandReader thread" on some systems Nov 8, 2016
@dktapps dktapps mentioned this issue Nov 19, 2016
@falkirks
Copy link
Contributor

stream_set_blocking() only works on Mac and maybe some Linux versions, but it is mainly a Mac thing. We had a discussion about this a while ago.

@dktapps
Copy link
Member Author

dktapps commented Dec 17, 2016

Found the cause of the stream_select issue, seems to be a MINTTY bug. Running in PowerShell or CMD it works perfectly.

@dktapps
Copy link
Member Author

dktapps commented Dec 17, 2016

Correction: not a MINTTY bug, just bad implementation. PHP CLI sees MINTTY as a pipe instead of an actual console. Reference: mintty/mintty#56. The same issue occurs on Travis using a blocking STDIN stream. The cause of this is that stream_select will always return 1 if the input is piped.

dktapps added a commit that referenced this issue Dec 19, 2016
Use stream_select to poll stdin status before reading
Add detection for FIFO pipes, rewrite half of the CommandReader (again)
Add timeout for CommandReader to prevent hang in Windows custom consoles (unknown reason)
@dktapps dktapps closed this as completed in 4ace4b9 Jan 7, 2017
@dktapps dktapps added Resolution: Fixed and removed Status: Debugged Cause of the bug has been found, but not fixed labels Jan 7, 2017
dktapps added a commit to iTXTech/Genisys that referenced this issue Jan 9, 2017
…mmp/PocketMine-MP#171)

Use stream_select to poll stdin status before reading
Add detection for FIFO pipes, rewrite half of the CommandReader (again)
Add timeout for CommandReader to prevent hang in Windows custom consoles (unknown reason)
This was referenced Jul 13, 2019
@supercrafter333 supercrafter333 mentioned this issue Jun 7, 2020
@Lycol50 Lycol50 mentioned this issue Jun 8, 2020
@ghost ghost mentioned this issue Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants