Skip to content

Issues with twinBASIC enumeration implementation #34

@WaynePhillipsEA

Description

@WaynePhillipsEA

When enumerating the dictionary content with For-Each, the twinBASIC hacks are causing mem corruption, leading to crashes.

For example, with just this simple enumerator I can see that a Collection enumerator vtable is replaced (as expected, OK), but also the adjacent field member which is used internally to maintain a linked list of live enumerators for the collection is also getting overwritten with something:

        For Each v In d
        Next v

The offending code in VBA-FastDictionary is this:

        With Mem.Common(0)
            #If TWINBASIC Then
                .saP.pvData = ObjPtr(DictEnum) + ptrSize
            #Else
                .saP.pvData = ObjPtr(DictEnum) + nextItemOffset
            #End If
            Mem.RPtr(0) = VarPtr(Vars.Keys(i))                               ' --> tB internal linked list gets overwritten here
            .saP.pvData = .dPtr
        End With

This causes crashes, particularly when stepping through the code, since at that point there are multiple open enumerators against the collection (since the debugger breifly enumerates it for display in the IDE), and the clobbered linked list gets manipulated/corrupted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions