}
static void
-altstack_handle_and_restore (MonoContext *ctx, MonoObject *obj, gboolean stack_ovf)
+altstack_handle_and_restore (MonoContext *ctx, MonoObject *obj, guint32 flags)
{
MonoContext mctx;
MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), MONO_CONTEXT_GET_IP (ctx), NULL);
+ gboolean stack_ovf = (flags & 1) != 0;
+ gboolean nullref = (flags & 2) != 0;
- if (!ji)
+ if (!ji || (!stack_ovf && !nullref))
mono_handle_native_crash ("SIGSEGV", ctx, NULL);
mctx = *ctx;
gpointer *sp;
int frame_size;
MonoContext *copied_ctx;
+ gboolean nullref = TRUE;
+
+ if (!mono_is_addr_implicit_null_check (fault_addr))
+ nullref = FALSE;
if (stack_ovf)
exc = mono_domain_get ()->stack_overflow_ex;
UCONTEXT_REG_RSP (sigctx) = (unsigned long)(sp - 1);
UCONTEXT_REG_RDI (sigctx) = (unsigned long)(copied_ctx);
UCONTEXT_REG_RSI (sigctx) = (guint64)exc;
- UCONTEXT_REG_RDX (sigctx) = stack_ovf;
+ UCONTEXT_REG_RDX (sigctx) = (stack_ovf ? 1 : 0) | (nullref ? 2 : 0);
#endif
}
#endif
-static gboolean
-is_addr_implicit_null_check (void *addr)
+gboolean
+mono_is_addr_implicit_null_check (void *addr)
{
/* implicit null checks are only expected to work on the first page. larger
* offsets are expected to have an explicit null check */
if (!ji && mono_chain_signal (MONO_SIG_HANDLER_PARAMS))
return;
- if (is_addr_implicit_null_check (info->si_addr)) {
+#ifdef TARGET_AMD64
+ /* exceptions-amd64.c handles the check itself */
+ mono_arch_handle_altstack_exception (ctx, info, info->si_addr, FALSE);
+#else
+ if (mono_is_addr_implicit_null_check (info->si_addr)) {
mono_arch_handle_altstack_exception (ctx, info, info->si_addr, FALSE);
} else {
+ // FIXME: This shouldn't run on the altstack
mono_handle_native_crash ("SIGSEGV", &mctx, info);
}
+#endif
}
#else
}
}
- if (is_addr_implicit_null_check (fault_addr)) {
+ if (mono_is_addr_implicit_null_check (fault_addr)) {
mono_arch_handle_exception (ctx, NULL);
} else {
mono_handle_native_crash ("SIGSEGV", &mctx, (MONO_SIG_HANDLER_INFO_TYPE*)info);
void
mono_post_native_crash_handler (const char *signal, MonoContext *mctx, MONO_SIG_HANDLER_INFO_TYPE *info, gboolean crash_chaining);
+gboolean
+mono_is_addr_implicit_null_check (void *addr);
+
/*
* Signal handling
*/