[Xamarin.Android.Build.Tasks] Avoid stack overflow in ResolveAssemblies. (#284)
Fixes a stack overflow:
Adding assembly reference for Xamarin.AsyncTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3bd78831b6502434, recursively...
Adding assembly reference for System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively...
Adding assembly reference for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, recursively...
...
Adding assembly reference for System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, recursively...
Adding assembly reference for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, recursively...
We never should have hit the second
`Adding assembly reference for System.Runtime` message, as we'd
already processed the dependencies for `System.Runtime`; seeing
`mscorlib` listed more than once is a bug.
The cause of the overflow was that
`ResolveAssemblies.AddAssemblyReferences()` was using two different
values to check for whether an assembly had been previously
processed: `assembly.MainModule.FullyQualifiedName` and
`Path.GetFullPath(assembly.MainModule.FullyQualifiedName)`,
*which may differ* (see e2dfa9f2
).
Use the same `Path.GetFullPath()` in `.Contains()` and `.Add()` to
fix the stack overflow.
This commit is contained in:
Родитель
a569cfc5e9
Коммит
f77ad02eb8
|
@ -113,9 +113,10 @@ namespace Xamarin.Android.Tasks
|
|||
void AddAssemblyReferences (DirectoryAssemblyResolver resolver, ICollection<string> assemblies, AssemblyDefinition assembly, bool topLevel)
|
||||
{
|
||||
var fqname = assembly.MainModule.FullyQualifiedName;
|
||||
var fullPath = Path.GetFullPath (fqname);
|
||||
|
||||
// Don't repeat assemblies we've already done
|
||||
if (!topLevel && assemblies.Contains (fqname))
|
||||
if (!topLevel && assemblies.Contains (fullPath))
|
||||
return;
|
||||
|
||||
foreach (var att in assembly.CustomAttributes.Where (a => a.AttributeType.FullName == "Java.Interop.DoNotPackageAttribute")) {
|
||||
|
@ -129,7 +130,7 @@ namespace Xamarin.Android.Tasks
|
|||
indent += 2;
|
||||
// Add this assembly
|
||||
if (!topLevel && assemblies.All (a => new AssemblyNameDefinition (a, null).Name != assembly.Name.Name))
|
||||
assemblies.Add (Path.GetFullPath (fqname));
|
||||
assemblies.Add (fullPath);
|
||||
|
||||
// Recurse into each referenced assembly
|
||||
foreach (AssemblyNameReference reference in assembly.MainModule.AssemblyReferences) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче