[Mono-list] System.DivideByZeroException in HashTable?

Bernardo 2belikeme at gmail.com
Tue Jul 26 01:50:46 EDT 2011


Is the instance variable 'this.loadFactor' by any chance of integer type?

Regards,
Bernardo van der Wal
On Jul 26, 2011 5:01 AM, "Ben Pryor" <salexwhisp at gmail.com> wrote:
> I sometimes get this exception (mono 2.8) - running fully bundled (exe +
> deps). It happens very rarely. 64 bit suse system.
>
> How is this exception possible?
>
> Stack Trace:
> at System.Collections.Hashtable..ctor (Int32 capacity, Single
> loadFactor, IHashCodeProvider hcp, IComparer comparer) [0x00000] in
> <filename unknown>:0
> at System.Collections.Hashtable..ctor (Int32 capacity, Single
> loadFactor) [0x00000] in <filename unknown>:0
> at System.Collections.Hashtable..ctor (Int32 capacity) [0x00000] in
> <filename unknown>:0
> at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider
> obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename
> unknown>:0
> at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider
> obj, Boolean inherit) [0x00000] in <filename unknown>:0
> at System.Reflection.MonoField.GetCustomAttributes (Boolean inherit)
> [0x00000] in <filename unknown>:0
>
>
> Code from hashtable:
>
> public Hashtable (int capacity, float loadFactor, IHashCodeProvider hcp,
> IComparer comparer) {
> if (capacity<0)
> throw new ArgumentOutOfRangeException
> ("capacity", "negative capacity");
> if (loadFactor < 0.1f || loadFactor > 1.0f ||
> Single.IsNaN (loadFactor))
> throw new ArgumentOutOfRangeException
> ("loadFactor", "load factor");
> if (capacity == 0) ++capacity;
> this.loadFactor = 0.75f*loadFactor;
> double tableSize = capacity / this.loadFactor;
> if (tableSize > Int32.MaxValue)
> throw new ArgumentException ("Size is too
> big");
> int size = (int) tableSize;
> size = ToPrime (size);
> this.SetTable (new Slot [size], new int [size]);
> this.hcp = hcp;
> this.comparer = comparer;
> this.inUse = 0;
> this.modificationCount = 0;
> }
> The only divide in there is is a float divide. It wouldn't try to convert
> 'this.loadFactor' to an int and then do int divide would it?
>
> Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110726/d3f74cbc/attachment-0001.html 


More information about the Mono-list mailing list