[Mono-list] System.DivideByZeroException in HashTable?

Ben Pryor salexwhisp at gmail.com
Mon Jul 25 23:01:10 EDT 2011


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/20110725/989a271f/attachment.html 


More information about the Mono-list mailing list