Bug 56567

Summary: Passing large struct into exception filter method crashes runtime with SIGSEGV
Product: [Mono] Runtime Reporter: daniil <dydaniil>
Component: DebuggerAssignee: Zoltan Varga <vargaz>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono, mono-bugs+runtime
Priority: ---    
Version: 5.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: SIGSERV demo

Description daniil 2017-05-17 14:39:41 UTC
Created attachment 22233 [details]
SIGSERV demo

Hi, this is probably any problem with exception filtering support in desctop version of mono runtime.
#Here is simple code repro:

class Program
{
    static void Main( string[] args ) => Process();
 
    public static void Process()
    {
        try
        {
            throw new Exception();
        }
        catch ( Exception ) when ( ExceptionFilter( default( byte ), default( Foo ) ) )
        {
        }
    }

    [MethodImpl( MethodImplOptions.NoInlining )]
    private static bool ExceptionFilter( byte x, Foo item ) => true;

    public struct Foo
    {
        public long Part1 { get; }
        public long Part2 { get; }

        public byte Part3 { get; }
    }
}


#application falls only of sizeof( Foo ) > 16b

# bash for windows:
Ubuntu 14.04.5 LTS
Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014

# ubuntu:
Ubuntu 16.04.2 LTS
Linux version 4.8.0-52-generic (buildd@lgw01-59) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #55~16.04.1-Ubuntu SMP Fri Apr 28 14:36:29 UTC 2017

#mono version:
Mono JIT compiler version 5.0.0 (Stable 5.0.0.100/9667aa6 Thu May 11 14:48:10 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen (concurrent by default)

#built with ms build 15.1.548.43366
Comment 1 Zoltan Varga 2017-05-19 00:46:21 UTC
https://github.com/mono/mono/pull/4903
Comment 2 Zoltan Varga 2017-05-19 15:40:01 UTC
Fixed in mono master afffab3b5c718a9241233a8c6747a3471b2171fc.
Comment 3 daniil 2017-05-23 09:05:33 UTC
thx