Skip to content

Conversation

@VSadov
Copy link
Member

@VSadov VSadov commented Aug 22, 2022

BOOL is preferred in QCALL signatures since it has well defined size (int32) while c++ bool is implementation specific and is typically 1 byte.
It looks like we expect int32 (UnmanagedType.Bool) on the managed side as well.

This fixes #62145 for me.

I am not sure why this is not causing failures in non-singlefile case. It should though.
Perhaps some differences in initialization or how calls are bound have a mitigating effect on non-singlefile.

@ghost ghost added the area-VM-coreclr label Aug 22, 2022
@ghost ghost assigned VSadov Aug 22, 2022
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VSadov
Copy link
Member Author

VSadov commented Aug 23, 2022

Thanks!!

@VSadov VSadov merged commit 334cb5a into dotnet:main Aug 23, 2022
@VSadov VSadov deleted the pipeSF branch August 23, 2022 02:23
@VSadov
Copy link
Member Author

VSadov commented Aug 24, 2022

/backport to release/7.0

@github-actions
Copy link
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/2917168012

@nr-ahemsath
Copy link

Is there any chance this fix will be backported to .NET 6?

@AaronRobinsonMSFT
Copy link
Member

@nr-ahemsath We would need to do a bar check, but given the size of this change, I don't think it would get much pushback. Are you sure this is the same issue?

@nr-ahemsath
Copy link

nr-ahemsath commented Aug 26, 2022

@AaronRobinsonMSFT Thanks for responding so quickly! I'm not 100% sure the issue I'm seeing is the same as this, but it seems pretty likely, based on the following:

  1. The stack trace from the exception we get is very similar to the one in issue AccessViolationException with PublishSingleFile #62145:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Diagnostics.Tracing.EventPipePayloadDecoder.DecodePayload(EventMetadata ByRef, System.ReadOnlySpan`1<Byte>)
   at System.Diagnostics.Tracing.EventPipeEventDispatcher.DispatchEventsToEventListeners()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
  1. Our .NET APM agent does use custom EventListeners to get resource usage data from the CLR of the applications we are instrumenting, e.g.: https://github.com/newrelic/newrelic-dotnet-agent/blob/580657f772f75cad1c1ec78d62bf2db956b7da36/src/Agent/NewRelic/Agent/Core/Samplers/GCSamplerNetCore.cs#L137
  2. I am able to reproduce the exception 100% (3/3) when I try to use our agent to profile a .NET 6.0 application published with the PublishSingleFile option. It apparently can still occur without that option, just very sporadically.

Do you have any suggestions for how I can positively confirm that this is the same issue? Is there an overnight dev build of .NET 7.0 with this fix that I could grab (maybe in a docker image?), or would I have to build the runtime from source? Sorry, I should have taken 30 seconds to read the README.md at the top level of this repo. I'll test with the latest .NET 7 by following the instructions here: https://github.com/dotnet/runtime/blob/main/docs/project/dogfooding.md

@AaronRobinsonMSFT
Copy link
Member

@nr-ahemsath The "nightly" builds can be found at https://github.com/dotnet/installer/#table, but it seems this fixed hasn't made it into that build yet. Probably next week? If you can confirm this fixes the problem, please let me know and I can start the process.

@AaronRobinsonMSFT
Copy link
Member

Also, I'd recommend creating another issue and tagging this one if a port to .NET 6 is requested.

@nr-ahemsath
Copy link

@AaronRobinsonMSFT Okay, thanks. Yeah, I tested with the latest RC build and it still crashes, so thanks for confirming that the fix hasn't made it in yet. I will create another issue and tag this one if I can confirm that this PR fixes our issue.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 25, 2022
@VSadov
Copy link
Member Author

VSadov commented Jan 25, 2023

/backport to release/6.0

@github-actions github-actions bot unlocked this conversation Jan 25, 2023
@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/4009666237

@github-actions
Copy link
Contributor

@VSadov backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Use BOOL (vs. bool) in event pipe qcall signatures
Using index info to reconstruct a base tree...
M	src/coreclr/vm/eventpipeinternal.cpp
M	src/coreclr/vm/eventpipeinternal.h
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/vm/eventpipeinternal.h
CONFLICT (content): Merge conflict in src/coreclr/vm/eventpipeinternal.h
Auto-merging src/coreclr/vm/eventpipeinternal.cpp
CONFLICT (content): Merge conflict in src/coreclr/vm/eventpipeinternal.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Use BOOL (vs. bool) in event pipe qcall signatures
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@VSadov an error occurred while backporting to release/6.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AccessViolationException with PublishSingleFile

5 participants