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

Generic with "unmanaged" constraint crashes runtime #10144

Closed
joncham opened this issue Aug 16, 2018 · 0 comments

Comments

@joncham
Copy link
Contributor

@joncham joncham commented Aug 16, 2018

Steps to Reproduce

  1. Compile test project below with -langversion:7.3
using System;
  
unsafe class Program
{
        public static int Main(string[] args)
        {
                return (int)(IntPtr)Generic<int>.GetPtr();
        }
}

unsafe class Generic<T> where T : unmanaged
{
        public static T* GetPtr()
        {
                return (T*)null;
        }
}

Current Behavior

Native stacktrace:

	0   mono                                0x000000010886a3f8 mono_dump_native_crash_info + 744
	1   mono                                0x0000000108810423 mono_handle_native_crash + 195
	2   libsystem_platform.dylib            0x00007fff56af3f5a _sigtramp + 26
	3   ???                                 0x0000000114722608 0x0 + 4637992456
	4   libsystem_c.dylib                   0x00007fff568911ae abort + 127
	5   mono                                0x0000000108a41eb0 mono_log_close_logfile + 0
	6   mono                                0x0000000108a5dc42 monoeg_assertion_message + 194
	7   mono                                0x00000001087a3eff mono_method_to_ir + 175695
	8   mono                                0x0000000108771e86 inline_method + 1126
	9   mono                                0x0000000108799c0b mono_method_to_ir + 133979
	10  mono                                0x000000010875fbe0 mini_method_compile + 816
	11  mono                                0x000000010876363c mono_jit_compile_method_inner + 76
	12  mono                                0x0000000108766fb1 mono_jit_compile_method_with_opt + 2577
	13  mono                                0x000000010876aecc mono_jit_runtime_invoke + 572
	14  mono                                0x000000010895ea38 mono_runtime_invoke_checked + 136
	15  mono                                0x000000010896606e mono_runtime_exec_main_checked + 110
	16  mono                                0x00000001087ceefd mono_jit_exec + 349
	17  mono                                0x00000001087d215c mono_main + 11724
	18  mono                                0x000000010875af2a main + 282
	19  libdyld.dylib                       0x00007fff567e5015 start + 1
	20  ???                                 0x0000000000000004 0x0 + 4

Expected Behavior

Not crash

On which platforms did you notice this

[x ] macOS
[ ] Linux
[ x] Windows

Version Used:

mono --version
Mono JIT compiler version 5.19.0 (master/f892f95843c Wed Aug 15 23:15:05 EDT 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	Interpreter:   yes
	LLVM:          supported, not enabled.
	Suspend:       hybrid
	GC:            sgen (concurrent by default)
monojenkins added a commit that referenced this issue Aug 20, 2018
…er types are encountered with 'unmanaged' constraint. (#10145)

Properly inflate pointer types in inflate_generic_type. 

Generic pointer types are encountered with 'unmanaged' constraint.

Fixes #10144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.