Skip to content

[HotReloadAgent] Handle unsupported platform for PosixSignalRegistration#52466

Merged
jonathanpeppers merged 1 commit intorelease/10.0.3xxfrom
dev/peppers/hotreload-signals
Jan 22, 2026
Merged

[HotReloadAgent] Handle unsupported platform for PosixSignalRegistration#52466
jonathanpeppers merged 1 commit intorelease/10.0.3xxfrom
dev/peppers/hotreload-signals

Conversation

@jonathanpeppers
Copy link
Member

If running on Android, for example, you can get the following exception:

01-14 10:46:37.635 28537 28537 F mono-rt : [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
01-14 10:46:37.635 28537 28537 F mono-rt :  ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Runtime.InteropServices.PosixSignalRegistration.Register(PosixSignal signal, Action`1 handler)
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Runtime.InteropServices.PosixSignalRegistration.Create(PosixSignal signal, Action`1 handler)
01-14 10:46:37.635 28537 28537 F mono-rt :    at StartupHook.RegisterSignalHandlers()
01-14 10:46:37.635 28537 28537 F mono-rt :    at StartupHook.InitializeWithHttp(String processDir)
01-14 10:46:37.635 28537 28537 F mono-rt :    at StartupHook.Initialize()
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
01-14 10:46:37.635 28537 28537 F mono-rt :    --- End of inner exception stack trace ---
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
01-14 10:46:37.635 28537 28537 F mono-rt :    at System.StartupHookProvider.ProcessStartupHooks(String diagnosticStartupHooks)

Just like in 79e5fa6, PosixSignalRegistration APIs are decorated with:

[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public static PosixSignalRegistration Create(PosixSignal signal, Action<PosixSignalContext> handler);

This is used for handling Ctrl+C, for example, which we'll likely implement a different way for mobile platforms.

For now, let's not run the PlatformNotSupportedException-throwing code on unsupported platforms.

@jonathanpeppers
Copy link
Member Author

Note that I'll send this to release/10.0.3xx instead, when that branch is available.

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Do not merge to 2xx though.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a PlatformNotSupportedException crash that occurs when running the HotReload agent on platforms where PosixSignalRegistration is not supported (Android, iOS, tvOS, and Browser). The fix adds a platform check before attempting to register POSIX signal handlers.

Changes:

  • Introduces a new s_supportsPosixSignals boolean field to track platform support
  • Adds a conditional check in RegisterSignalHandlers() to skip POSIX signal registration on unsupported platforms

@jonathanpeppers jonathanpeppers changed the base branch from release/10.0.2xx to release/10.0.3xx January 16, 2026 14:19
@jonathanpeppers
Copy link
Member Author

@tmat retargeted to release/10.0.3xx.

@mmitche mmitche deleted the branch release/10.0.3xx January 17, 2026 00:40
@mmitche mmitche closed this Jan 17, 2026
…tion`

If running on Android, for example, you can get the following exception:

    01-14 10:46:37.635 28537 28537 F mono-rt : [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
    01-14 10:46:37.635 28537 28537 F mono-rt :  ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Runtime.InteropServices.PosixSignalRegistration.Register(PosixSignal signal, Action`1 handler)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Runtime.InteropServices.PosixSignalRegistration.Create(PosixSignal signal, Action`1 handler)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at StartupHook.RegisterSignalHandlers()
    01-14 10:46:37.635 28537 28537 F mono-rt :    at StartupHook.InitializeWithHttp(String processDir)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at StartupHook.Initialize()
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
    01-14 10:46:37.635 28537 28537 F mono-rt :    --- End of inner exception stack trace ---
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
    01-14 10:46:37.635 28537 28537 F mono-rt :    at System.StartupHookProvider.ProcessStartupHooks(String diagnosticStartupHooks)

Just like in 79e5fa6, `PosixSignalRegistration` APIs are decorated
with:

    [UnsupportedOSPlatform("android")]
    [UnsupportedOSPlatform("browser")]
    [UnsupportedOSPlatform("ios")]
    [UnsupportedOSPlatform("tvos")]
    public static PosixSignalRegistration Create(PosixSignal signal, Action<PosixSignalContext> handler);

This is used for handling Ctrl+C, for example, which we'll likely
implement a different way for mobile platforms.

For now, let's not run the `PlatformNotSupportedException`-throwing
code on unsupported platforms.
@jonathanpeppers jonathanpeppers merged commit a2bbad7 into release/10.0.3xx Jan 22, 2026
26 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/peppers/hotreload-signals branch January 22, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants