Skip to content

Conversation

@grendello
Copy link
Contributor

Context: #3759
Context: 6d85759#diff-e99739c16155208685952aa52870d4cdL33-L39

When switching from C-style xcalloc to C++-style new I failed to use the
proper type to allocate array which holds directories where Android placed the
APK files of the application. This mistake manifested itself only when using
AppBundles, which is where we allocate more than one entry of the array. The
resulting error was the following runtime exception:

11-04 12:27:55.722  3339  3339 E mono    : Unhandled Exception:
11-04 12:27:55.722  3339  3339 E mono    : System.DllNotFoundException: __Internal assembly:<unknown assembly> type:<unknown type> member:(null)
11-04 12:27:55.722  3339  3339 E mono    :   at (wrapper managed-to-native) Android.Runtime.JNIEnv.monodroid_timing_start(string)

Which occurred because Xamarin.Android runtime failed to load libmonodroid.so
from one of the directories that should have been stored in the array mentioned
above - usually found in the last entry of the array. When iterating over the
array, the XA runtime would end up with a null pointer after the end of the
array instead of a pointer to the last entry.

This commit uses the proper type when allocating the array.

Context: dotnet#3759
Context: dotnet@6d85759#diff-e99739c16155208685952aa52870d4cdL33-L39

When switching from C-style `xcalloc` to C++-style `new` I failed to use the
proper type to allocate array which holds directories where Android placed the
APK files of the application. This mistake manifested itself only when using
AppBundles, which is where we allocate more than one entry of the array. The
resulting error was the following runtime exception:

    11-04 12:27:55.722  3339  3339 E mono    : Unhandled Exception:
    11-04 12:27:55.722  3339  3339 E mono    : System.DllNotFoundException: __Internal assembly:<unknown assembly> type:<unknown type> member:(null)
    11-04 12:27:55.722  3339  3339 E mono    :   at (wrapper managed-to-native) Android.Runtime.JNIEnv.monodroid_timing_start(string)

Which occurred because Xamarin.Android runtime failed to load `libmonodroid.so`
from one of the directories that should have been stored in the array mentioned
above - usually found in the *last* entry of the array. When iterating over the
array, the XA runtime would end up with a null pointer after the end of the
array instead of a pointer to the last entry.

This commit uses the proper type when allocating the array.
@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello grendello added the full-mono-integration-build For PRs; run a full build (~6-10h for mono bumps), not the faster PR subset (~2h for mono bumps) label Nov 8, 2019
@grendello
Copy link
Contributor Author

build

@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jonpryor
Copy link
Contributor

jonpryor commented Nov 9, 2019

Considering all the grief we went through with PR #3796, is it possible to create a test case which triggers the scenario? Do we know why this only "randomly" failed instead of consistently failed?

@grendello
Copy link
Contributor Author

Considering all the grief we went through with PR #3796, is it possible to create a test case which triggers the scenario? Do we know why this only "randomly" failed instead of consistently failed?

I was thinking about it and I can't figure out why it failed intermittently. The AppBundle is, however, THE test case that triggered it so I think we are at least partially covered

@jonpryor jonpryor merged commit 13e67db into dotnet:master Nov 12, 2019
@grendello grendello deleted the correct-memalloc branch November 12, 2019 10:11
jonpryor pushed a commit that referenced this pull request Nov 12, 2019
Context: 6d85759
Context: #3796
Context: 6d85759#diff-e99739c16155208685952aa52870d4cdL33-L39

When switching from C-style `xcalloc()` to C++-style `new` I failed
to use the proper type to allocate the array which holds directories
where Android placed the `.apk` files of the application.  This
mistake manifested itself only when using AppBundles, which is where
we allocate more than one entry of the array.

The resulting error was the following runtime exception:

	Unhandled Exception:
	System.DllNotFoundException: __Internal assembly:<unknown assembly> type:<unknown type> member:(null)
	  at (wrapper managed-to-native) Android.Runtime.JNIEnv.monodroid_timing_start(string)

which occurred because the Xamarin.Android runtime failed to load
`libmonodroid.so` from one of the directories that should have been
stored in the array mentioned above - usually found in the *last*
entry of the array.  When iterating over the array, the XA runtime
would end up with a null pointer after the end of the array instead
of a pointer to the last entry.

This commit uses the proper type when allocating the array.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

full-mono-integration-build For PRs; run a full build (~6-10h for mono bumps), not the faster PR subset (~2h for mono bumps)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants