Silver: Overriding by _ value: [Any] causes corrupted .dex and app installation failure

IDE: Fire
Version: 9.0.97.2071, 9.1.100.2076 (was originally discovered in 8.4 beta 2 month ago)
Target: Java
Description:

When writing a set of functions that are overloaded by parameter type in the following way:

func `set`(_ value: SomeType, forKey key: String) {}

everything works, however when the value becomes of the type [Any], it will build correctly, but will likely cause corrupted .dex that will further mess up something very fundamental and installation will fail with:

~> Installing lakestonecore.tests
~> Calling adb -s FA31LPN00609 install -r "/Users/hurden/Developer/Lakestone/LakestoneCore/Silver/LakestoneCore.Tests/./bin/Debug/LakestoneCore.Tests.apk"
~> The process failed to start with the following error: Failed to install, output:
~> [ 13%] /data/local/tmp/LakestoneCore.Tests.apk
~> [ 27%] /data/local/tmp/LakestoneCore.Tests.apk
~> [ 41%] /data/local/tmp/LakestoneCore.Tests.apk
~> [ 55%] /data/local/tmp/LakestoneCore.Tests.apk
~> [ 68%] /data/local/tmp/LakestoneCore.Tests.apk
~> [ 82%] /data/local/tmp/LakestoneCore.Tests.apk
~> [ 96%] /data/local/tmp/LakestoneCore.Tests.apk
~> [100%] /data/local/tmp/LakestoneCore.Tests.apk
~>         pkg: /data/local/tmp/LakestoneCore.Tests.apk
~> Failure [INSTALL_FAILED_UID_CHANGED]

What’s extremely interesting, that even if you remove the method, rebuild/clean/reinstall Fire/delete app from the device/try on other device -> it will never be able to install again, unless you will create a new project that will have a different package name.

You can the reproduce this issue by clone the repo and adding a method with a following signature:

public func `set`(_ value: [Any], forKey key: String){}

to https://github.com/GeoThings/LakestoneCore/blob/master/Source/PersistentPropertyList.swift#L233

Also while Fire 9.0.97.2071 will report it failed to install, Fire 9.1 beta (9.1.100.2076) will always crash instead.
Crash log is attached next.

crash_log.txt (69.5 KB)

Thanks, logged as bugs://76941

Hi,

I was trying your project, however it doesn’t seem to compile at all:

Severity	Code	Description	Project	File	Line	Suppression State
Error		(E181) Property "lastModificationDateÂÂș: Date?" getter not implemented as required for interface "AnyFileOrDirectory"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\Directory.swift	32	
Error		(E181) Property "parentDirectoryÂÂș: Directory?" getter not implemented as required for interface "AnyFileOrDirectory"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\Directory.swift	32	
Error		(E62) Type mismatch, cannot assign "<error>" to "String"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	512	
Error		(E44) No member "utf8EncodedStringRepresentationÂș" on type "java.nio.ByteBuffer!"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	512	
Error		(E62) Type mismatch, cannot assign "<error>" to "String"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	514	
Error		(E44) No member "utf8EncodedStringRepresentationÂș" on type "java.nio.ByteBuffer!"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	514	
Error		(E62) Type mismatch, cannot assign "<error>" to "String"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	516	
Error		(E44) No member "utf8EncodedStringRepresentationÂș" on type "java.nio.ByteBuffer!"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	516	
Error		(E62) Type mismatch, cannot assign "<error>" to "String"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	529	
Error		(E44) No member "utf8EncodedStringRepresentationÂș" on type "Data!"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\extension_String.swift	529	
Error		(E265) Static duck typing failed because of missing methods	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\File.swift	46	
Error		(E44) No member "utf8EncodedStringRepresentationÂș" on type "java.nio.ByteBuffer!"	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\File.swift	124	
Warning		(N3) Original type "AnyFileOrDirectory" was declared here	LakestoneCore.Android	\Silver\LakestoneCore.Shared\..\..\Source\AnyFileOrDirectory.swift	27	

bugs://76941 got closed with status cannotrepro.

weird, everything compiles ok for me on 9.0.97.2071.

any chance you can extract this problem in a smaller testcase?

sure, let me do this in these few days

1 Like