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

Exception unwinding broken with Xcode 15 linker #92297

Closed
vcsjones opened this issue Sep 19, 2023 · 13 comments
Closed

Exception unwinding broken with Xcode 15 linker #92297

vcsjones opened this issue Sep 19, 2023 · 13 comments

Comments

@vcsjones
Copy link
Member

Recently I've started observing a strange behavior when attempting to run tests where first chance exceptions seem to be crashing the test runner.

For example, running: ./dotnet.sh test src/libraries/System.Formats.Cbor/tests

Produces:

The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.Formats.Cbor.CborContentException: The current CBOR map contains an incomplete key/value pair.
   at System.Formats.Cbor.CborReader.PeekStateCore() in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.PeekState.cs:line 82
   at System.Formats.Cbor.CborReader.SkipNextNode(Int32& depth) in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.SkipValue.cs:line 70
   at System.Formats.Cbor.CborReader.SkipToAncestor(Int32 depth, Boolean disableConformanceModeChecks) in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.SkipValue.cs:line 51

I don't see any reason this exception should crash the test runner.

It's not just in S.F.Cbor. For Tar:

 Skipped System.Formats.Tar.Tests.TarWriter_WriteEntry_File_Tests.CreateEntryFromFileOwnedByNonExistentUser [1 ms]
The active test run was aborted. Reason: Test host process crashed : Unhandled exception. Unhandled exception. System.IO.IOException: The file '/var/folders/gc/qfr6cnsj3p1fc1944dkn1t6h0000gn/T/33hxgrfd.1wv/file.tar' already exists.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) in /Users/vcsjones/Projects/runtime/src/libraries/Common/src/Interop/Unix/Interop.IOErrors.cs:line 16

I have my suspicion that the issue is due to upgrade Xcode to Xcode 15 (However I am on macOS 13 still).

Currently, I can't run any tests.

./dotnet.sh --info
.NET SDK:
 Version:   8.0.100-rc.1.23415.11
 Commit:    12f1505f6e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.5
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /Users/vcsjones/Projects/runtime/.dotnet/sdk/8.0.100-rc.1.23415.11/
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 19, 2023
@ghost
Copy link

ghost commented Sep 19, 2023

Tagging subscribers to this area: @dotnet/area-system-formats-cbor, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Recently I've started observing a strange behavior when attempting to run tests where first chance exceptions seem to be crashing the test runner.

For example, running: ./dotnet.sh test src/libraries/System.Formats.Cbor/tests

Produces:

The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.Formats.Cbor.CborContentException: The current CBOR map contains an incomplete key/value pair.
   at System.Formats.Cbor.CborReader.PeekStateCore() in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.PeekState.cs:line 82
   at System.Formats.Cbor.CborReader.SkipNextNode(Int32& depth) in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.SkipValue.cs:line 70
   at System.Formats.Cbor.CborReader.SkipToAncestor(Int32 depth, Boolean disableConformanceModeChecks) in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.SkipValue.cs:line 51

I don't see any reason this exception should crash the test runner.

It's not just in S.F.Cbor. For Tar:

 Skipped System.Formats.Tar.Tests.TarWriter_WriteEntry_File_Tests.CreateEntryFromFileOwnedByNonExistentUser [1 ms]
The active test run was aborted. Reason: Test host process crashed : Unhandled exception. Unhandled exception. System.IO.IOException: The file '/var/folders/gc/qfr6cnsj3p1fc1944dkn1t6h0000gn/T/33hxgrfd.1wv/file.tar' already exists.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) in /Users/vcsjones/Projects/runtime/src/libraries/Common/src/Interop/Unix/Interop.IOErrors.cs:line 16

I have my suspicion that the issue is due to upgrade Xcode to Xcode 15 (However I am on macOS 13 still).

Currently, I can't run any tests.

./dotnet.sh --info
.NET SDK:
 Version:   8.0.100-rc.1.23415.11
 Commit:    12f1505f6e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.5
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /Users/vcsjones/Projects/runtime/.dotnet/sdk/8.0.100-rc.1.23415.11/
Author: vcsjones
Assignees: -
Labels:

untriaged, area-System.Formats.Cbor

Milestone: -

@ghost
Copy link

ghost commented Sep 19, 2023

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Issue Details

Recently I've started observing a strange behavior when attempting to run tests where first chance exceptions seem to be crashing the test runner.

For example, running: ./dotnet.sh test src/libraries/System.Formats.Cbor/tests

Produces:

The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.Formats.Cbor.CborContentException: The current CBOR map contains an incomplete key/value pair.
   at System.Formats.Cbor.CborReader.PeekStateCore() in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.PeekState.cs:line 82
   at System.Formats.Cbor.CborReader.SkipNextNode(Int32& depth) in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.SkipValue.cs:line 70
   at System.Formats.Cbor.CborReader.SkipToAncestor(Int32 depth, Boolean disableConformanceModeChecks) in /Users/vcsjones/Projects/runtime/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.SkipValue.cs:line 51

I don't see any reason this exception should crash the test runner.

It's not just in S.F.Cbor. For Tar:

 Skipped System.Formats.Tar.Tests.TarWriter_WriteEntry_File_Tests.CreateEntryFromFileOwnedByNonExistentUser [1 ms]
The active test run was aborted. Reason: Test host process crashed : Unhandled exception. Unhandled exception. System.IO.IOException: The file '/var/folders/gc/qfr6cnsj3p1fc1944dkn1t6h0000gn/T/33hxgrfd.1wv/file.tar' already exists.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) in /Users/vcsjones/Projects/runtime/src/libraries/Common/src/Interop/Unix/Interop.IOErrors.cs:line 16

I have my suspicion that the issue is due to upgrade Xcode to Xcode 15 (However I am on macOS 13 still).

Currently, I can't run any tests.

./dotnet.sh --info
.NET SDK:
 Version:   8.0.100-rc.1.23415.11
 Commit:    12f1505f6e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.5
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /Users/vcsjones/Projects/runtime/.dotnet/sdk/8.0.100-rc.1.23415.11/
Author: vcsjones
Assignees: -
Labels:

os-mac-os-x, area-Infrastructure, untriaged

Milestone: -

@adamsitnik
Copy link
Member

cc @janvorli

@vitek-karas
Copy link
Member

@MarcoRossignoli FYI

@vcsjones
Copy link
Member Author

This is what I was able to gather with lldb.

frame #0: 0x00000001a14f4764 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001a152bc28 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x00000001a1439ae8 libsystem_c.dylib`abort + 180
    frame #3: 0x00000001030e84ec libcoreclr.dylib`PROCAbort(signal=6, siginfo=0x0000000000000000) at process.cpp:2558:5
    frame #4: 0x00000001030e8080 libcoreclr.dylib`PROCEndProcess(hProcess=0x00000000ffffff01, uExitCode=1, bTerminateUnconditionally=YES) at process.cpp:1352:13
    frame #5: 0x00000001030e818c libcoreclr.dylib`TerminateProcess(hProcess=0x00000000ffffff01, uExitCode=1) at process.cpp:1249:11
    frame #6: 0x00000001031f09a0 libcoreclr.dylib`CrashDumpAndTerminateProcess(exitCode=1) at excep.cpp:4220:5
    frame #7: 0x00000001035d3bd0 libcoreclr.dylib`UnwindManagedExceptionPass1(ex=0x0000000170558d18, frameContext=0x0000000170558820) at exceptionhandling.cpp:4877:17
    frame #8: 0x00000001035d40e8 libcoreclr.dylib`DispatchManagedException(ex=0x0000000170558d18, isHardwareException=false) at exceptionhandling.cpp:4956:17
    frame #9: 0x0000000103480908 libcoreclr.dylib`IL_Rethrow() at jithelpers.cpp:4365:5

Frame 7 looks interesting. If I switch to that controlPc is 0.

I'm not sure what to make of this, but I'm more or less at a point where the runtime repository is not functional on my Mac.

@MarcoRossignoli
Copy link
Member

@nohwnd do you recall if we did some update to the default policy? I'd say not but maybe I'm missing something.

@nohwnd
Copy link
Member

nohwnd commented Sep 22, 2023

I don't think so, unless this is another bug caused by migration to arcade, but I don't see how that would happen.

@vcsjones
Copy link
Member Author

I downgraded my local Xcode to 14 down from 15 and everything started working, so I don't think the issue is with the test host or test runner. It's something with how dotnet/runtime is getting built.

@filipnavara
Copy link
Member

The new Xcode 15 linker is going to be fun.

I already submitted a fix to make NativeAOT unwinding work. Turns out that the new linker mishandles object files without the MH_SUBSECTIONS_VIA_SYMBOLS flag (.subsections_via_symbols assembly code). It ends up treating the whole object file as one function and produces unwind info only for the first function in the file.

I don't think the C compiler can produce files without the flag but I didn't check what the assembly files do. I assumed that would not necessarily matter but perhaps it was a wrong assumption for CoreCLR.

@filipnavara
Copy link
Member

Can you try if filipnavara@aba0b02 helps? The CBOR tests still fail for me locally but in a different way (all the errors are related to DateTimeOffset).

@vcsjones vcsjones changed the title First-chance exceptions crashing test runner Exception unwinding broken with Xcode 15 linker Sep 23, 2023
@vcsjones
Copy link
Member Author

vcsjones commented Sep 23, 2023

I should have known better and thought "I bet @filipnavara knows what is going on and has probably started working on a fix already".

When I build your branch with the Xcode 15 toolchain, I get a green run of tests. The DateTimeOffset looks separate to me. I can look at that later. I have a hunch the tests fail if your timezone offset is positive.

@filipnavara
Copy link
Member

Thanks for external validation!

@vcsjones
Copy link
Member Author

Fixed by #92520.

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Sep 23, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants