flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [FIXED] Mixing 'virtual' with 'if' corrupts structure store

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20617
Location: In your JS exploiting you and your system
revolution 26 Apr 2010, 13:11
Here are two situations that expose the bug:

1) The first virtual block has the restore state corrupted by the 'end if'
Code:
VAR = 0

org '0'
display $             ;<--- '0'

if VAR = VAR
  virtual at '1'
    display $       ;<--- '1'
      virtual at '2'
    display $       ;<--- '2'
end if                        ;return state of first virtual is corrupted here
if VAR = VAR
    display $       ;<--- '2'
      end virtual
 display $       ;<--- '1'
      end virtual     ;wrong state is restored here
end if

display $                ;<--- '1'    
2) The IF state is corrupted by the 'end virtual'
Code:
VAR = 0

org '0'
virtual at '1'
display $               ;<--- '1'

if VAR = VAR
    if VAR <> VAR
    else
   display $       ;<--- '1'
      end virtual     ;state of first 'if' block is corrupted here
      display $       ;<--- '0'
    end if
else                    ;<--- error: unexpected instruction.
end if    
This can be fixed by the addition of four instruction to do a top-down memory copy. In ASSEMBLE.INC around line 980:
Code:
      remove_structure_data:
    push    esi edi
     mov     esi,[structures_buffer]
     mov     ecx,ebx
     sub     ecx,esi
     lea     edi,[esi+20h]
       mov     [structures_buffer],edi
     shr     ecx,2
                       lea esi,[esi+ecx*4-4]   ;<--- add
                        lea edi,[edi+ecx*4-4]   ;<--- add
                        std                     ;<--- add
        rep     movs dword [edi],[esi]
                      cld                     ;<--- add
        pop     edi esi
     ret    


Last edited by revolution on 27 Apr 2010, 01:58; edited 3 times in total
Post 26 Apr 2010, 13:11
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 26 Apr 2010, 13:36
Nice catch; thanks for the report.
Post 26 Apr 2010, 13:36
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20617
Location: In your JS exploiting you and your system
revolution 27 Apr 2010, 01:58
This bug is now fixed in version 1.69.14
Post 27 Apr 2010, 01:58
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.