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

[x86/Linux] Support Simple Exception Catch #8887

Closed
parjong opened this Issue Jan 11, 2017 · 8 comments

Comments

Projects
None yet
1 participant
@parjong
Copy link
Contributor

parjong commented Jan 11, 2017

I attempted to execute the following program with x86/Linux port:

using System;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            Console.WriteLine("Hello World!");
            throw new ArgumentException();
        }
        catch (Exception e)
        {
            Console.WriteLine("Caught");
        }
    }
}

CoreCLR currently shows the following assert failure for the above example:

Assert failure(PID 19154 [0x00004ad2], Thread: 19154 [0x4ad2]): iUnwindInfo < GetNumberOfUnwindInfos()
    File: /home/parjong/projects/dotnet/coreclr/src/vm/codeman.h Line: 342
    Image: /root/dotnet-test/overlay/current/corerun
@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 11, 2017

@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 11, 2017

I could reach RtlVirtualUnwind (NYI) with #8889:

(gdb) r
...

Assert failure(PID 20461 [0x00004fed], Thread: 20461 [0x4fed]): false && "RtlVirtualUnwind"
    File: /home/parjong/projects/dotnet/coreclr/src/vm/i386/unixstubs.cpp Line: 112
    Image: /root/dotnet-test/overlay/current/corerun


Program received signal SIGABRT, Aborted.
0xf7fd9d80 in __kernel_vsyscall ()
(gdb) bt
#0  0xf7fd9d80 in __kernel_vsyscall ()
#1  0xf7ce2687 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2  0xf7ce5ab3 in __GI_abort () at abort.c:89
#3  0xf7911f96 in PROCEndProcess (hProcess=0xffffff01, uExitCode=123456789, bTerminateUnconditionally=1) at /home/parjong/projects/dotnet/coreclr/src/pal/src/thread/process.cpp:1385
#4  0xf7912111 in TerminateProcess (hProcess=0xffffff01, uExitCode=123456789) at /home/parjong/projects/dotnet/coreclr/src/pal/src/thread/process.cpp:1301
#5  0xf6c35138 in TerminateOnAssert () at /home/parjong/projects/dotnet/coreclr/src/utilcode/debug.cpp:183
#6  0xf6c36575 in _DbgBreakCheck (szFile=0xf79b8f4c "/home/parjong/projects/dotnet/coreclr/src/vm/i386/unixstubs.cpp", iLine=112, szExpr=0xf79b90c0 "false && \"RtlVirtualUnwind\"", fConstrained=0)
    at /home/parjong/projects/dotnet/coreclr/src/utilcode/debug.cpp:436
#7  0xf6c36d3a in _DbgBreakCheckNoThrow (szFile=0xf79b8f4c "/home/parjong/projects/dotnet/coreclr/src/vm/i386/unixstubs.cpp", iLine=112, szExpr=0xf79b90c0 "false && \"RtlVirtualUnwind\"", fConstrained=0)
    at /home/parjong/projects/dotnet/coreclr/src/utilcode/debug.cpp:548
#8  0xf6c373c2 in DbgAssertDialog (szFile=0xf79b8f4c "/home/parjong/projects/dotnet/coreclr/src/vm/i386/unixstubs.cpp", iLine=112, szExpr=0xf79b90c0 "false && \"RtlVirtualUnwind\"")
    at /home/parjong/projects/dotnet/coreclr/src/utilcode/debug.cpp:735
#9  0xf7122e81 in RtlVirtualUnwind (HandlerType=1, ImageBase=4066734096, ControlPc=4066754246, FunctionEntry=0xf24e929c, ContextRecord=0xffffbf78, HandlerData=0xffffbb9c, EstablisherFrame=0xffffbba0,
    ContextPointers=0x0) at /home/parjong/projects/dotnet/coreclr/src/vm/i386/unixstubs.cpp:112
#10 0xf711b323 in UnwindManagedExceptionPass1 (ex=..., frameContext=0xffffbf78) at /home/parjong/projects/dotnet/coreclr/src/vm/exceptionhandling.cpp:4497
#11 0xf711bf87 in DispatchManagedException (ex=..., isHardwareException=false) at /home/parjong/projects/dotnet/coreclr/src/vm/exceptionhandling.cpp:4640
#12 0xf6f9caf9 in IL_Throw (obj=0xf2f29e38) at /home/parjong/projects/dotnet/coreclr/src/vm/jithelpers.cpp:5451
#13 0xf265bec6 in ?? ()
#14 0xf2657470 in ?? ()

@parjong parjong changed the title [x86/Linux] iUnwindInfo < GetNumberOfUnwindInfos() [x86/Linux] Cannot throw an exception Jan 12, 2017

@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 12, 2017

#8911 made some progress. Now, Core CLR shows the following assert failure:

TID 0572: creating new tracker object 0x08081B98, thread = 0x08083C60
TID 0572: StackTraceInfo::AllocateStackTrace (08081BC0)
TID 0572: CEHelper::SetupCorruptionSeverityForActiveException - Marked non-rethrow/non-nested exception as NotCorrupting.
TID 0572: CEHelper::SetupCorruptionSeverityForActiveException - Copied the corruption severity (2) to ThreadExceptionState.
TID 0572: ..ExceptionTracker::InitializeCurrentContextForCrawlFrame: DispatcherContext->ControlPC = F265BBE6; IP in DispatcherContext->ContextRecord = F2657470.

Assert failure(PID 1394 [0x00000572], Thread: 1394 [0x0572]): false && "ExceptionTracker::ProcessOSExceptionNotification"
    File: /home/parjong/projects/dotnet/coreclr/src/vm/exceptionhandling.cpp Line: 1625
    Image: /root/dotnet-test/overlay/current/corerun

@parjong parjong changed the title [x86/Linux] Cannot throw an exception [x86/Linux] Cannot throw exception Jan 12, 2017

@parjong parjong changed the title [x86/Linux] Cannot throw exception [x86/Linux] Cannot catch exception Jan 12, 2017

@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 12, 2017

#8912 made another progress:

TID 007f: FinishSecondPass complete, uResumePC = F1DB749B, current SP = FFDC861C
TID 007f: STACKWALK: [000] FILTER  : EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffdc9884  vtbl= f73c067c
TID 007f: STACKWALK: [001] CONSIDER: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffdc9884  vtbl= f73c067c
TID 007f: STACKWALK: [001] CALLBACK: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffdc9884  vtbl= f73c067c
TID 007f: STACKWALK: [002] CONSIDER: FRAMELESS: PC= f1db749a  SP= ffdc98f8  method=Main
TID 007f: STACKWALK: [002] CALLBACK: FRAMELESS: PC= f1db749a  SP= ffdc98f8  method=Main

Assert failure(PID 127 [0x0000007f], Thread: 127 [0x007f]): 0
    File: /home/parjong/projects/dotnet/coreclr/src/vm/eetwain.cpp Line: 619
    Image: /home/parjong/projects/dotnet/dotnet-overlay/Linux.x86.Debug.Debug/corerun
@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 12, 2017

With #8913, CLR shows the following message:

TID 0094: STACKWALK: [000] FILTER  : EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffb6de64  vtbl= f73c967c
TID 0094: STACKWALK: [001] CONSIDER: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffb6de64  vtbl= f73c967c
TID 0094: STACKWALK: [001] CALLBACK: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffb6de64  vtbl= f73c967c
TID 0094: STACKWALK: [002] CONSIDER: FRAMELESS: PC= f1cb949a  SP= ffb6ded8  method=Main
TID 0094: STACKWALK: [002] CALLBACK: FRAMELESS: PC= f1cb949a  SP= ffb6ded8  method=Main
TID 0094: STACKWALK: [003] FILTER  : NATIVE   : PC= f6899aa7  SP= ffb6def0
TID 0094: STACKWALK: [004] CONSIDER: EXPLICIT : PC= f6899aa7  SP= ffb6def0  Frame= ffb6e664  vtbl= f73c9618
TID 0094: STACKWALK: [004] CALLBACK: EXPLICIT : PC= f6899aa7  SP= ffb6def0  Frame= ffb6e664  vtbl= f73c9618
TID 0094: STACKWALK: [005] CONSIDER: EXPLICIT : PC= f6899aa7  SP= ffb6def0  Frame= ffb6ec3c  vtbl= f73c9618
TID 0094: STACKWALK: [005] CALLBACK: EXPLICIT : PC= f6899aa7  SP= ffb6def0  Frame= ffb6ec3c  vtbl= f73c9618
TID 0094: STACKWALK: SWA_DONE: reached the end of the stack

Assert failure(PID 148 [0x00000094], Thread: 148 [0x0094]): Consistency check failed: FAILED: state.fFound
    File: /home/parjong/projects/dotnet/coreclr/src/vm/exceptionhandling.cpp Line: 360
    Image: /home/parjong/projects/dotnet/dotnet-overlay/Linux.x86.Debug.Debug/corerun

@parjong parjong changed the title [x86/Linux] Cannot catch exception [x86/Linux] Support Simple Exception Catch Jan 12, 2017

@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 12, 2017

Core CLR with #8914 shows the following assert failure:

TID 00ad: FinishSecondPass complete, uResumePC = F1CC949B, current SP = FF96734C
TID 00ad: STACKWALK: [000] FILTER  : EXPLICIT : PC= 00000000  SP= 00000000  Frame= ff9685b4  vtbl= f73da67c
TID 00ad: STACKWALK: [001] CONSIDER: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ff9685b4  vtbl= f73da67c
TID 00ad: STACKWALK: [001] CALLBACK: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ff9685b4  vtbl= f73da67c
TID 00ad: STACKWALK    HelperMethodFrame::UpdateRegDisplay cached ip:F1CC949A, sp:FF968628
TID 00ad: STACKWALK: [002] CONSIDER: FRAMELESS: PC= f1cc949a  SP= ff968628  method=Main
TID 00ad: STACKWALK: [002] CALLBACK: FRAMELESS: PC= f1cc949a  SP= ff968628  method=Main
TID 00ad: STACKWALK: SWA_ABORT: callback aborted the stackwalk

Assert failure(PID 173 [0x000000ad], Thread: 173 [0x00ad]): false && "ExceptionTracker::UpdateNonvolatileRegisters"
    File: /home/parjong/projects/dotnet/coreclr/src/vm/exceptionhandling.cpp Line: 454
    Image: /home/parjong/projects/dotnet/dotnet-overlay/Linux.x86.Debug.Debug/corerun
@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 12, 2017

#8915 now allows us to resume, but incurs segfault:

TID 00b9: STACKWALK: [000] FILTER  : EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffffc614  vtbl= f7c5e67c
TID 00b9: STACKWALK: [001] CONSIDER: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffffc614  vtbl= f7c5e67c
TID 00b9: STACKWALK: [001] CALLBACK: EXPLICIT : PC= 00000000  SP= 00000000  Frame= ffffc614  vtbl= f7c5e67c
TID 00b9: STACKWALK    HelperMethodFrame::UpdateRegDisplay cached ip:F265749A, sp:FFFFC688
TID 00b9: STACKWALK: [002] CONSIDER: FRAMELESS: PC= f265749a  SP= ffffc688  method=Main
TID 00b9: STACKWALK: [002] CALLBACK: FRAMELESS: PC= f265749a  SP= ffffc688  method=Main
TID 00b9: STACKWALK: SWA_ABORT: callback aborted the stackwalk
TID 00b9: Updating reg FFFFCD08 to FFFFCD08 from FFFFC67C
TID 00b9: Updating reg DB897F00 to DB897F00 from FFFFC674
TID 00b9: Updating reg F62C0A3C to F62C0A3C from FFFFC678
TID 00b9: Updating reg FFFFC698 to FFFFC698 from FFFFC680
TID 00b9: resuming execution at 0xF265749B
TID 00b9: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0xf2f2282c in ?? ()
#2  0xf712ede7 in CallDescrWorkerInternal () at /home/parjong/projects/dotnet/coreclr/src/vm/i386/asmhelpers.S:444
#3  0xf6eb3f6d in CallDescrWorker (pCallDescrData=0xffffcd08) at /home/parjong/projects/dotnet/coreclr/src/vm/callhelpers.cpp:146
@parjong

This comment has been minimized.

Copy link
Contributor Author

parjong commented Jan 12, 2017

#8916 finally allows us to execute the above example:

# ./corerun coreclr-analyze/catch.dll
Hello World!
Caught
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment