-
Notifications
You must be signed in to change notification settings - Fork 4
Remove signal handler alt-stack to provide a stable runtime #5
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
Changes from all commits
825a3b6
57bbfa2
8806624
64ffd0c
a94b9b1
40901ab
825a318
3ea9c35
33d1f2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,6 +145,10 @@ pub fn launch_app_binary(runtime_dir: Option<&Path>, app_info: &AppInfo) -> Resu | |
| let args: Vec<PdCString> = env::args_os().map(PdCString::from_os_str).collect::<Result<_, _>>()?; | ||
| let app_path = PdCString::from_os_str(app_info.app_path.as_os_str())?; | ||
|
|
||
| //Apply required fixes | ||
| #[cfg(unix)] | ||
| unix::fixup_signal_handling(); | ||
|
|
||
| let res = unsafe { | ||
| let args = args.iter().map(|s| s.as_ptr()).collect::<Vec<_>>(); | ||
|
|
||
|
|
@@ -163,4 +167,26 @@ pub fn launch_app_binary(runtime_dir: Option<&Path>, app_info: &AppInfo) -> Resu | |
| Ok(err) => Err(Box::new(err)), | ||
| Err(_) => Ok(res) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(unix)] | ||
| mod unix { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This module could use a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applied all changes that |
||
| use libc::{sigaction, sigaltstack, stack_t, SIGSEGV, SIG_DFL, SS_DISABLE}; | ||
| use std::{mem, ptr}; | ||
|
|
||
| //On Unix it is required for us to manually remove the registered signal handler altstack in order to have a stable runtime. | ||
| //This is due to rust registering a tiny altstack and then the runtime rolling with it, which causes it to overflow it when allocating a large structure. | ||
| //See https://github.com/dotnet/runtime/issues/115438 for more details. | ||
| pub fn fixup_signal_handling() { | ||
| //Removing the SIGSEGV handler is not strictly required, but since we are messing with the altstack we also reset it to the default, for safety | ||
|
|
||
| let mut action: sigaction = unsafe { mem::zeroed() }; | ||
| action.sa_sigaction = SIG_DFL; | ||
| unsafe { sigaction(SIGSEGV, &action, ptr::null_mut()) }; | ||
|
|
||
| let mut altstack: stack_t = unsafe { mem::zeroed() }; | ||
| altstack.ss_flags = SS_DISABLE; | ||
| unsafe { sigaltstack(&altstack, ptr::null_mut()) }; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| piton-runtime | ||
| piton-runtime | ||
| *.deps.json | ||
| *.dll | ||
| *.pdb | ||
| *.runtimeconfig.json | ||
| obj/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| Console.WriteLine("Hello, World!"); | ||
| #pragma warning disable CS8600 // Intentional NRE for testing purposes | ||
| #pragma warning disable CS8602 // See above | ||
| // Test if NREs work properly since by default rust uses a signal handler altstack which can | ||
| // be too small for the runtime to work with, see https://github.com/dotnet/runtime/issues/115438 | ||
| // for the full details | ||
|
|
||
| // Piton currently includes a hacky fix to work around that | ||
|
|
||
| try { | ||
| ((object)null).GetType(); | ||
| } catch (NullReferenceException) { | ||
| Console.WriteLine("NRE caught!"); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <CheckEolTargetFramework>false</CheckEolTargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <UseAppHost>false</UseAppHost> | ||
| <OutputPath>.</OutputPath> | ||
| <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
| </PropertyGroup> | ||
| </Project> |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,24 @@ | ||
| # Latest LTS as of April 19th 2025 | ||
| windows-x86: | ||
| version: 7.0.12 | ||
| download: https://download.visualstudio.microsoft.com/download/pr/e6be672b-53a9-4050-9b55-53f74a55523c/b59ab5af9be85681cf415865a159624f/dotnet-runtime-7.0.12-win-x86.zip | ||
| download-sha512: 760f4483b9848c2165be30ad4623de4099529fdcbf61c4e6c1738dfe22e3d776ca7ced89e4d7485dc0337c988b1c3bf1c5757a01e97d156df4ad0cf848226244 | ||
| version: 8.0.15 | ||
| download: https://builds.dotnet.microsoft.com/dotnet/Runtime/8.0.15/dotnet-runtime-8.0.15-win-x86.zip | ||
| download-sha512: b9980345c84443381b92d8d3c56a90244ec90e6f7edfbf09dd665b29a807705592606997e7e85bb7f6357f49feb5aa41506ec1426a4208352a326736bda6c441 | ||
| download-format: zip | ||
|
|
||
| windows-x86_64: | ||
| version: 7.0.12 | ||
| download: https://download.visualstudio.microsoft.com/download/pr/6d97a102-c4f3-4183-91d7-d810e96e73a1/272349ea2adf0145d9364e2c12bd23a4/dotnet-runtime-7.0.12-win-x64.zip | ||
| download-sha512: fada96dfe5c0ff99799032b21323b0c75764df8c7991e67c0f2757a0f4d9946c68dee07831a0bda7e884713749150121d618973d14bdcc915d389799b36848bb | ||
| version: 8.0.15 | ||
| download: https://builds.dotnet.microsoft.com/dotnet/Runtime/8.0.15/dotnet-runtime-8.0.15-win-x64.zip | ||
| download-sha512: 1d486895ecc1c99586a8dd221a1a21c507ce42eaf4262345f93f0a2cae7e23733360b742f2d5b803c56a1199cb00ca20a5ee5c911d63118e1930e07068a7cccb | ||
| download-format: zip | ||
|
|
||
| linux-x86_64: | ||
| version: 7.0.12 | ||
| download: https://download.visualstudio.microsoft.com/download/pr/47a663ab-0c5f-4502-9ea1-93c27df8f9ed/5ee65ca13eb40220631dab82a27972d8/dotnet-runtime-7.0.12-linux-x64.tar.gz | ||
| download-sha512: 74bea25e88bd917a733a6899a3b3c9ac40c85a64f82dc0f36840714669621716afbb8fec6c3c398b1ffb522c0ed11958862cff5a4be0bf6268188cdb276bc109 | ||
| version: 8.0.15 | ||
| download: https://builds.dotnet.microsoft.com/dotnet/Runtime/8.0.15/dotnet-runtime-8.0.15-linux-x64.tar.gz | ||
| download-sha512: 833a848541ba6f71c8792168914856e16de6f71cf0a481c5990f3622b0e3f83123e6024bcabf6b955a7c92e8e904181d40d3bd612595a0d8c47a421267a91ca6 | ||
| download-format: targz | ||
|
|
||
| macos-x86_64: | ||
| version: 7.0.12 | ||
| download: https://download.visualstudio.microsoft.com/download/pr/5a3eed2a-4c5f-4c05-9ef5-4b59de889a9e/4a577fd9e4b278dfebc16d901691b90f/dotnet-runtime-7.0.12-osx-x64.tar.gz | ||
| download-sha512: 3cfa807b64eb345ff104f33d7120d7d973443d40aedfe5fb49c0b67adb69f743c18a6e762a8463f59ee29b4a291970e8af48f97f841a94ed220809b56258b0e0 | ||
| download-format: targz | ||
| version: 8.0.15 | ||
| download: https://builds.dotnet.microsoft.com/dotnet/Runtime/8.0.15/dotnet-runtime-8.0.15-osx-x64.tar.gz | ||
| download-sha512: e488b4dca3cb08a144b50d4428e4185b7a8cf7486886acfee8fc00c1145bd82d7bc7e66acea76a575869f16578babc6708fe1045839deca6ca848188ca59a51c | ||
| download-format: targz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this places the output DLL in the right place (I would expect it to be somewhere in a
bin/directory); additionally, those outputbin/objdirs should probably be .gitignored.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The csproj contains
<OutputPath>.</OutputPath>as well as<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>to make sureTest.dlllands in the correct folder, paths in the csproj are relative to that file. Consequently nobindirectory is generated.Added all other dotnet artifacts to
.gitignorethough.