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

fatal: morestack on g0 #12021

Open
leonardocustodio opened this issue Aug 22, 2023 · 6 comments
Open

fatal: morestack on g0 #12021

leonardocustodio opened this issue Aug 22, 2023 · 6 comments

Comments

@leonardocustodio
Copy link

Description

I'm getting this error when running a test that uses FFI to execute a go lib.
It is probably related to this issue: golang/go#62130
Not sure where the problem lies php or go

Resulted in this output:

fatal: morestack on g0

PHP Version

PHP 8.2.9

Operating System

macOS 13.4

@iluuu1994
Copy link
Member

Please provide some steps to reproduce the issue. It's hard to understand where the issue comes from without an example. From reading golang/go#62130 they seem to have a clear grasp of what's causing this.

golang/go#62130 (comment)

Currently the Go runtime assumes the C stack for each thread is contiguous and never change. It's stack bounds is recorded in the g0 of the thread. When the C (or PHP) code switches stacks, its SP will not be within the boundary of the original stack, therefore causing morestack on g0 error. This is not surprising.

I don't know exactly how FFI works under the hood, but it must allocate space for the stack somewhere for executing the given function. It sounds like Go assumes that the stack will never change. Thus different FFI calls with execution of morestack will break this assumption, as FFI likely allocates space for each FFI call independently. If that's the case, there's nothing we can do on our side.

@leonardocustodio
Copy link
Author

leonardocustodio commented Aug 23, 2023

Sure here are some steps to reproduce:

  1. Clone https://github.com/enjin/platform-core
  2. Have go installed
  3. composer install
  4. composer build-sr25519
  5. Then run all tests from phpunit

It will likely stop at "VerifyAccount" test with that error. Also if you just run that single test it will work, but running all of them it will not. Maybe related which what you said?

Btw this only happens on Apple Sillicon, I was not able to reproduce it on Ubuntu 22 (but maybe because my go version might be older? Let me update it on ubuntu to check if it will happen as well)

@leonardocustodio
Copy link
Author

Yep, I've updated go, rebuilt the lib, and could not reproduce it on Ubuntu 22 with PHP 8.2.9. I can only reproduce it on Apple Sillicon using the same PHP and GO versions

@leonardocustodio
Copy link
Author

I guess it is worth taking a look in this issue to get more clarification: dunglas/frankenphp#171 (comment)

@withinboredom
Copy link
Contributor

I can only reproduce it on Apple Sillicon using the same PHP and GO versions

Note that we cannot reproduce our issue on Apple Silicon, only AMD64. So they may be related, but in different ways.

@leonardocustodio
Copy link
Author

Note that we cannot reproduce our issue on Apple Silicon, only AMD64. So they may be related, but in different ways.

I guess it could really be as he said golang/go#62130 (comment)

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

No branches or pull requests

3 participants