Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[XA] Probable bug with tarjan GC_BRIDGE - Handle must be valid. #14282

@pjcollins

Description

@pjcollins

Copied from dotnet/android#3035


Note: This seems like it is probably a duplicate of dotnet/android#2518 as it was his issue back on bugzilla that led me to the cause / workaround. It doesn't seem like he is getting any real response though so I have posted this, I hope that's ok. His repro may be easier to use, I haven't looked at it.

Steps to Reproduce

  1. Build the solution (you will need to do it twice as the first time it builds the F# / C# mapping layer).
  2. Click through to the map screen
  3. Click RECORD in the title bar
  4. Background the app, which makes the location recorder switch to a foreground service with accompanying permanent notification. This stops the app getting killed off easily.
  5. Do stuff to create memory pressure. Notice location is still being collected in the debug output.
  6. Foreground the app
  7. Crash - System.ArgumentException: Handle must be valid. Parameter name: instance
  8. Set environment.txt in the Android project to build action 'AndroidEnvironment', which will revert the GC bridge to 'new' rather than the default 'tarjan'.
  9. Clean, Repeat 1 -> 6
  10. Observe no crash

It seems that the GoogleMap java object is being collected whilst the C# object is remaining available. I have tested extensively and only ever see the crash when using tarjan.

The fragment hosting it is located at SurveyIt.Droid\Surveys\Zones\Fragments\ZoneMapFragment .cs and a partial nested inside it named .ui.cs

The crash happens as soon as the data updates and tries to re-render the map poly lines.

The app is at a very early stage and probably has other bugs if you push it around too much, but it has all the location permissions loop in place etc and it would be a right mission to try to strip it down to a simpler repro (but if it ends up being necessary I can try).

Example of GC Bridge bug.zip

Expected Behavior

The GoogleMap java object should still be available to the C# proxy.

Actual Behavior

System.ArgumentException: Handle must be valid. Parameter name: instance

Version Information

Microsoft Visual Studio Community 2019
Version 16.0.2
VisualStudio.16.Release/16.0.2+28803.202
Microsoft .NET Framework
Version 4.7.03190

Installed Version: Community

Visual C++ 2019 00435-60000-00000-AA103
Microsoft Visual C++ 2019

ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools

Application Insights Tools for Visual Studio Package 9.0.20307.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019 16.0.12311.10635
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.0.12311.10635
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.0.12311.10635
Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.3.8000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 16.0.12311.10635
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.3.8000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 3.0.0-beta4-19170-01+1deafee3682da88bf07d1c18521a99f47446cee8
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 16.0.19074.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Extensibility Message Bus 1.1.77 (master@24013d5)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events

File Nesting 2.6.85
Automatically nest files based on file name and enables developers to nest and unnest any file manually

Microsoft Azure HDInsight Azure Node 2.3.8000.0
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.3.8000.0
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 2.5
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.3.8000.0
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.0.0

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 16.0.300 (573eda3)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.0.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Python 16.0.19074.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - Conda support 16.0.19074.1
Conda support for Python projects.

Python - Django support 16.0.19074.1
Provides templates and integration for the Django web framework.

Python - IronPython support 16.0.19074.1
Provides templates and integration for IronPython-based projects.

Python - Profiling support 16.0.19074.1
Profiling support for Python projects.

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.61903.25110
Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript Tools 16.0.10306.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.0.0-beta4-19170-01+1deafee3682da88bf07d1c18521a99f47446cee8
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6 16.0.0.0. Commit Hash: 809f41207b74a1356208f11b8fa3a15233734050.
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

Visual Studio Tools for Kubernetes 1.0
Visual Studio Tools for Kubernetes

Visual Studio Tools for Unity 4.0.0.5
Visual Studio Tools for Unity

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 16.0.0.515 (d16-0@a3502d929)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 4.17.4.418 (remotes/origin/d16-0@3d086e814)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.1.47 (31f664d)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 9.2.0.5 (HEAD/292d27fa)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 5ad371dab1b
Java.Interop: xamarin/java.interop/d16-0@c987483
LibZipSharp: grendello/LibZipSharp/master@44de300
LibZip: nih-at/libzip@b95cf3f
MXE: xamarin/mxe@b9cbb535
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@325e91a
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-0@0a7edd6

Xamarin.iOS and Xamarin.Mac SDK 12.8.0.0 (0aa8452)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions