Bug #42660 Falcon bug in SparseArray.h
Submitted: 6 Feb 2009 18:40 Modified: 15 May 2009 16:03
Reporter: Kevin Lewis Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S3 (Non-critical)
Version:6.0.9 OS:Any
Assigned to: Kevin Lewis CPU Architecture:Any
Tags: F_MISCELLANY, UNUSED CODE

[6 Feb 2009 18:40] Kevin Lewis
Description:
Jim Starkey reported this;

There's a bug in SparseArray.h.  The code

            if (!nextVector)
                {
                if (level == 1)
                    {
                    nextVector = (void**) new T [width];
                    memset(nextVector, 0, sizeof(T) * width);
                    }
                else
                    {
                    nextVector = new void* [width];
                    memset(nextVector, 0, sizeof(void*) * width);
                    }

                vector[n] = nextVector;
                }
should be:

            if (!nextVector)
                {
                if (lvl== 1)
                    {
                    nextVector = (void**) new T [width];
                    memset(nextVector, 0, sizeof(T) * width);
                    }
                else
                    {
                    nextVector = new void* [width];
                    memset(nextVector, 0, sizeof(void*) * width);
                    }

                vector[n] = nextVector;
                }

The effect of the bug is that leaf arrays after index 16,384 are allocated as vectors of pointer rather than vectors of the target object type.

I don't believe it has a manifestation in Falcon as all SparceArrays are either int or int32, each <= sizeof(void*). 

How to repeat:
Cannot repeat this bug since the current Falcon codebase does not use sparse array for anything larger than sizeof(void*).  But there has been talk of using it for larger objects.

Suggested fix:
See above.
[13 Feb 2009 7:24] Bugs System
Pushed into 6.0.10-alpha (revid:alik@sun.com-20090211182317-uagkyj01fk30p1f8) (version source revid:kevin.lewis@sun.com-20090206210857-y50fgaw03ntzec60) (merge vers: 6.0.10-alpha) (pib:6)
[14 Mar 2009 10:35] Kevin Lewis
This change was pushed back in February in a patch that did not get linked to this bug.
storage\falcon\SparseArray.h(125):
-		if (level == 1)
+		if (lvl == 1)
[15 May 2009 16:03] MC Brown
Internal/test fix. No changelog entry required.