You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Two WITH statements: error at second WITH when first END WITH not executed.
Strange: Not always crashing but at loop count 65534 (internal stack overflow?)
To Reproduce
Steps to reproduce the behavior:
Add Code and button to Form
Click on button
Code to Debug:
Class Form1
Private Type HashTableEntry
Position1 As Long ' 2x32 bit position hash key
' Position2 As Long
' Depth As Integer ' not Byte, negative values possible for QSearch
' Generation As Byte
' IsChecking As Boolean
' MoveFrom As Byte
' MoveTarget As Byte
' MovePromoted As Byte
' EvalType As Byte
' Eval As Long
' StaticEval As Long
' PvHit As Byte
End Type
Private HashTable() As HashTableEntry
Private Sub Command1_Click()
ReDim HashTable(272004)
Test2
MsgBox "Ready"
End Sub
Private Sub Test2()
Dim i As Long, j As Long, x As Long
For i = 0 To 272004 - 1 ' <<<< error at 65534
' For i = 100000 To 272004 - 1 '<<< error at 165534 > Loop start + 65534
' For i = 65534 To 65534 '<<< OK
' For i = 64000 To 66000 '<<< OK
x = 1
' this works ok ("End With" follows "Next" when EXIT FOR)
' With HashTable(i)
' For j = 0 To 1
' .Position1 = 99
' Exit For <<<<<
' Next j
' End With
' this creates the error ("Exit For" jumps behind "End With")
For j = 0 To 1
With HashTable(i + j)
.Position1 = 99
Exit For ' <<<<< cause for error: jumps over "End With"
End With
Next j
With HashTable(x) '<<<< error here at i = 65534 ( x always 1)
.Position1 = 11
End With
Next i
End Sub
End Class
See error
Expected behavior
Jump over END WITH should close WITH range too
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Windows 10
twinBASIC compiler version 294
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Looking deeper in this problem I have no idea how VB6 is handling this problem of deleting the pointer to the first WITH object. But even für large loop numbers (10.000.000) I cannot see virtual memory going up in VB6.
My original WITH code was in a SUB that was called by the main loop. For this case an easy fix would be to remove the WITH references at END SUB.
This is being caused by the SAFEARRAY lock. When you enter the With block, the underlying SAFEARRAY lock count (cLocks) is increased using SafeArrayLock() API. On exiting the with block, the lock is automatically removed with the SafeArrayUnlock() API. In this case, the unlock is not occurring due to the jump outside of the block. Although the cLocks field is 32-bit wide, the SafeArrayLock API fails when the lock count reaches &HFFFF (65535).
I'll check, but I believe the behaviour described above is correct (i.e. the lock is correctly still enforced when jumping out of the block), and that the error is actually being caused by the re-entry of the With block not accommodating the already locked state.
Describe the bug
Two WITH statements: error at second WITH when first END WITH not executed.
Strange: Not always crashing but at loop count 65534 (internal stack overflow?)
To Reproduce
Steps to reproduce the behavior:
Class Form1
Private Type HashTableEntry
Position1 As Long ' 2x32 bit position hash key
' Position2 As Long
' Depth As Integer ' not Byte, negative values possible for QSearch
' Generation As Byte
' IsChecking As Boolean
' MoveFrom As Byte
' MoveTarget As Byte
' MovePromoted As Byte
' EvalType As Byte
' Eval As Long
' StaticEval As Long
' PvHit As Byte
End Type
Private HashTable() As HashTableEntry
End Class
Expected behavior
Jump over END WITH should close WITH range too
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: