repetitive crash in RuntimeObjectIsa

HI Folks,

I have one user who is getting fairly reliable crashes while saving data in the app. This is the stack trace from the crash:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.xojo.XojoFramework 0x00ef5c33 RuntimeObjectIsa + 139
1 com.xojo.XojoFramework 0x00e7ea88 0xd9f000 + 916104
2 com.xojo.XojoFramework 0x00f28a61 VarType + 305
3 com.xojo.XojoFramework 0x00f23094 0xd9f000 + 1589396
4 com.xojo.XojoFramework 0x00f22d5a VariantCompare + 30
5 com.xojo.XojoFramework 0x00f22d2f VariantEqual + 24
6 com.xojo.XojoFramework 0x00e61b07 0xd9f000 + 797447
7 com.xojo.XojoFramework 0x00e620f9 0xd9f000 + 798969
8 com.xojo.XojoFramework 0x00e6257c dictionaryValueSetter + 91
9 com.myapp.thingy 0x0002bb66 Dictionary.=Value%%ovv + 54

What I’m doing at this point is updating a bunch of dictionary values before writing them out to a file. II’m just setting a dictionary value with a string as the key and a string as the value. The function takes the key as a string and the value as an integer, but converts the integer to a string before saving it in the dictionary. A little goofing around first to make sure the string has an encoding before trying to save it and I can see a potential problem there as I shouldn’t be converting encoding if the encoding is nil, I should be defining the encoding. But I’m not sure I can blame the crash in RuntimeObjectIsa on that? The last line “values” is a dictionary in scope for the object.

function setIntegerValue( key as string, value as integer)
dim ThisValue, ThisKey as string

if key.Encoding = nil or key.Encoding <> Encodings.utf8 then
ThisKey = ConvertEncoding( key, Encodings.UTF8)
else
ThisKey = key
end if

ThisValue = str( value)

values.Value( ThisKey) = ThisValue

Any ideas on why that might sometimes result in a crash?

RuntimeObjectIsa is the function called if someone uses isa operator.
Maybe a bug in reference counting as querying released objects crashes normally.

I do use the IsA function in several places in the app, but I can’t tell from the stack trace that I’m ever coming out of the dictionary.value= command? It looks like thats all internal to the management of the dictionary and it never comes out of that to my code again. But I’m not 100% certain how to read a stack trace :wink: The other instances are clear where it’s my code and where it’s xojo library functions calling each other.

Could it be as simple as my having converted a string with nil encoding to a string with UTF8 encoding and that makes it something so odd that the variant type handling in the dictionary key hashing blows up on it? I’m going to change that today but I hate sending builds and saying “well, I have no idea if this will fix your problem but go ahead and run this as I changed some random thing that looked fishy"

what is in the dictionary when it crashes?
any object inside which is touched by plugin so a plugin bug with reference count could cause it?

Since I later flatten the information to a sort of readable file I’m only storing strings, but also more embedded classes of the same xojo class thats doing this in the first place. It’s an old class for storing embedded dictionaries and flattening them to a file, I wrote it so long ago that the XML classes were still too buggy to use :wink: I might be doing plugin functions on the strings I pull out of the dictionary but I’m not directly accessing the dictionary from any or anything like that… Certainly nothing plugin triggered just by storing a string.