`stdLambda` `stack` issue
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Área
- tooling
Línea de trabajo
Start by reading the evaluate path for iType.oAccess and the pushV and CopyVariant entry points shown in the issue. Reproduce the object-valued stack access case from the included minimal examples, then establish a replacement approach that avoids the reported array-locking error and preserves existing stack behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Currently in evaluate:
Case iType.oAccess
Select Case op.subType
Case ISubType.argument
Dim iArgIndex As Long: iArgIndex = val(mid(op.value, 2)) + LBound(vLastArgs) - 1
If iArgIndex <= UBound(vLastArgs) Then
Call pushV(stack, stackPtr, vLastArgs(iArgIndex))
Else
Call Throw("Argument " & iArgIndex & " not supplied to Lambda.")
End If
Case Else
Call pushV(stack, stackPtr, stack(stackPtr - op.value))
Call pushV(stack, stackPtr, stack(stackPtr - op.value)) can sometimes error when the variable at stack(stackPtr - op.value) is an object. See explanation for details. As a temporary work around we can do the following:
'@FIX bug where if stack(stackPtr-op.value) was an object, then array will become locked. Array locking occurs by compiler to try to protect
'instances when re-allocation would move the array, and thus corrupt the pointers. By copying the variant we redivert the compiler's efforts,
'but we might actually open ourselves to errors...
Dim vAccessVar: Call CopyVariant(vAccessVar, stack(stackPtr - op.value))
Call pushV(stack, stackPtr, vAccessVar)
This may still break so we need to consider a better solution. Our suggestion is to use a Collection (i.e. linked list) instead of a dynamic array. This should have fewer issues but might sacrifice on some performance.
Explanation:
Minimal examples where error occurs:
Sub Example()
'Initialize the array with 3 elements
Dim myArray() As string
ReDim myArray(0)
Set myArray(0) = "yop"
Call Push(myArray, myArray(0))
End Sub
Sub Push(ByRef myArray() As string, ByRef element As string)
'Lock the array to prevent deallocation of memory for the reference parameter
ReDim Preserve myArray(UBound(myArray) + 1)
If IsObject(element) Then
Set myArray(UBound(myArray)) = element
Else
myArray(UBound(myArray)) = element
End If
End Sub
The issue is that element, in this case is a reference to an element within myArray... The solution to above is change element to ByVal:
Sub Push(ByRef myArray() As string, ByVal element As string)
When extended to the variant case however:
Sub Push(ByRef myArray() As variant, ByVal element As variant)
Objects are also pointers... so
Sub Example()
'Initialize the array with 3 elements
Dim myArray() As Variant
ReDim myArray(0)
Set myArray(0) = CreateObject("scripting.dictionary")
Call Push(myArray, myArray(0))
End Sub
Sub Push(ByRef myArray() As Variant, ByVal element As Variant)
'Lock the array to prevent deallocation of memory for the reference parameter
ReDim Preserve myArray(UBound(myArray) + 1)
If IsObject(element) Then
Set myArray(UBound(myArray)) = element
Else
myArray(UBound(myArray)) = element
End If
End Sub
Also errors because we have a pointer directly to myArray(0) object. So the real work around is
Sub Example()
'Initialize the array with 3 elements
Dim myArray() As Variant
ReDim myArray(0)
Set myArray(0) = CreateObject("scripting.dictionary")
Dim v: CopyVariant(v, myArray(0))
Call Push(myArray, v)
End Sub
- Lenguaje dominante
- VBA
- Estrellas
- 412
- Forks
- 70
- Merge medio
- 16 h 10 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sancarn/stdVBA
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
-
Issues of stdRefArrayAbiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Todos los issues de sancarn/stdVBA
Issues similares
-
Add 'upm' tag on githubAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
🐛 tunnel diag: Docker log collection deadlocks when the container's stderr log exceeds 64 KiBAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
cloudflare/cloudflared#1783 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
leecade/caniuse_local#12 ·
-
b:minor bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
software-mansion/argent#1698 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
objectionary/jeo-maven-plugin#1933 ·
Los mantenedores suelen responder en 2 días