-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
mono_thread_platform_create_thread crashing with pthread_attr_setstacksize invalid argument error #105490
Comments
I think this is because we're not aligning the requested stakc size to a multiple of the page size compare Mono runtime/src/mono/mono/utils/mono-threads-posix.c Lines 60 to 80 in 1d27457
to coreCLR PAL runtime/src/coreclr/pal/src/thread/thread.cpp Lines 550 to 565 in 1d27457
|
/cc @steveisok |
@lambdageek I am not sure if that is related, but we also bumped default thread stack size on macOS for CoreCLR, from 512kb (which is fairly low) to 1 or 2 mb. Since mac has 8mb for mainthread and 512kb for all secondary threads by default (on system level) |
#if defined(__arm__) || defined(__arm64__)
#define PTHREAD_STACK_MIN 16384
#else
#define PTHREAD_STACK_MIN 8192
#endif So requesting something smaller than the default ought to work. Mono does have a check that we ask for at least PTHREAD_STACK_MIN even if the user specified something smaller. |
Not a recent regression, btw. The following fails on mono going back to net6.0 at least (and probably older) using System.Threading;
public class Program
{
public static void Main()
{
var t = new Thread(() => {
Console.WriteLine ("from a new thread");
}, 16384 + 1);
t.Start();
t.Join();
}
} |
|
Mono does not round up the argument to
pthread_attr_setstacksize
to the platform virtual page size which results in an EINVAL which will causenew Thread(ThreadStart, Int32)
to fail#105445 (comment)
The osx-x64 Debug Mono_MiniJIT_LibrariesTests leg crashed with:
when trying to set a maxStackSize on a new thread to 100_000.
The text was updated successfully, but these errors were encountered: