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

Check loaded in dac values to avoid SIGSEGV on null pointers #110303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eterekhin
Copy link
Contributor

@eterekhin eterekhin commented Dec 2, 2024

Hey, folks!
I've encountered a debugger crash on mac os arm with the attached stack trace.
Looks like we tried to access some field on a null instance.
I went through the code path and added null checks for objects we marshal from the left side.
My change is similar to #104128, but I tried to fix it for the whole Object::ValidateObjectWithPossibleAV method

Code Type: ARM-64 (Native)
OS Version: macOS 14.5 (23F79)

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000028
Exception Codes: 0x0000000000000001, 0x0000000000000028

Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [90060]

External Modification Warnings: Process used task_for_pid().

Thread 10 Crashed: 
0   libmscordaccore.dylib                   0x121352b9c MethodTable:: ValidateWithPossibleAV() + 20
1   libmscordaccore.dylib                   0x121381574 DacDbiInterfaceImpl:: FastSanityCheckObject(__DPtr<Object>) + 84
2   libmscordaccore.dylib                   0x121381df0 DacDbiInterfaceImpl:: GetBasicObjectInfo(unsigned long long, CorElementType, VMPTR_Base<AppDomain, __VPtr<AppDomain>>, DebuggerIPCE_ObjectData*) + 104
3   libmscordbi.dylib                       0x120f3a020 CordbReferenceValue:: InitRef(MemoryRange) + 476
4   libmscordbi.dylib                       0x120f3a368 CordbReferenceValue::Dereference(ICorDebugValue**) + 368

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Dec 2, 2024
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@huoyaoyuan
Copy link
Member

The names of the functions are WithPossibleAV, implies that access violation (SIGSEGV) is a desired behavior.

@eterekhin
Copy link
Contributor Author

@huoyaoyuan, I've got your point about naming, I understand the naming like we may read at wrong address within the method (the reading happens in DacInstantiateTypeByAddress method), an error will be thrown via EX_THROW macros, mind handling it. But when real AV happens in the program it crashes

@eterekhin eterekhin marked this pull request as ready for review December 3, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants