flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fasmg on Windows 7 bug: display fails on long output

Author
Thread Post new topic Reply to topic
Grom PE



Joined: 13 Mar 2008
Posts: 114
Location: i@grompe.org.ru
Grom PE 20 Sep 2016, 20:51
Code:
bug = 0
;bug = 1 ; <== Uncomment this to see the bug:
;fasmg display command becomes silent when there's more data than this

head:
repeat 15682+bug
  dd '.'
end repeat
tail:

p = head
while p < tail
  load x dword from p
  display x
  p = p + 4
end while
display 'hello'    


Last edited by Grom PE on 21 Sep 2016, 10:29; edited 1 time in total
Post 20 Sep 2016, 20:51
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 21 Sep 2016, 06:33
I tested on Windows and Linux and with either "bug = 0" and "bug = 1", and I see the "hello" message every time. Perhaps there is some additional condition to reproduce the bug? What version of fasmg have you tested?
Post 21 Sep 2016, 06:33
View user's profile Send private message Visit poster's website Reply with quote
Grom PE



Joined: 13 Mar 2008
Posts: 114
Location: i@grompe.org.ru
Grom PE 21 Sep 2016, 07:48
To reproduce this bug, I used
fasmg 0.96.1449399753
fasmg 0.98.1474441044
on Windows 7, 64-bit

fasmg 0.98.1474441044
on Windows XP 32-bit, Windows 2000: fine with 13303 repeats, triggers with 13304 repeats
Post 21 Sep 2016, 07:48
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 21 Sep 2016, 07:57
On Windows 10 I went up to 1000000 and still saw nothing suspicious. Perhaps this is a problem of the console? If you redirect the output to the file (like "fasm test.asm nul > test.out") is the display in file cut off too?
Post 21 Sep 2016, 07:57
View user's profile Send private message Visit poster's website Reply with quote
Grom PE



Joined: 13 Mar 2008
Posts: 114
Location: i@grompe.org.ru
Grom PE 21 Sep 2016, 08:10
You're right, redirected output is fine.
Still, quite surprising behavior while fasm worked as expected...

Edit: clarified the topic, also see a similar bug report in Python.
Post 21 Sep 2016, 08:10
View user's profile Send private message Visit poster's website Reply with quote
Grom PE



Joined: 13 Mar 2008
Posts: 114
Location: i@grompe.org.ru
Grom PE 21 Sep 2016, 11:42
I fixed it by changing source/windows/system.inc, the end of the display_string function:
Code:
   write_string_to_stdout:
        cmp     ecx, 51200
        jg      write_long_string_to_stdout
        invoke  WriteFile,[stdout],esi,ecx,bytes_count,0
        retn
   write_long_string_to_stdout: 
        push    esi
        push    ebx
        mov     edi, ecx
        mov     ebx, 51200
   next_write_to_stdout:
        invoke  WriteFile,[stdout],esi,ebx,bytes_count,0
        add     esi, ebx
        sub     edi, ebx
        cmp     edi, ebx
        jg      next_write_to_stdout
        invoke  WriteFile,[stdout],esi,edi,bytes_count,0
        pop     ebx
        pop     esi
        retn    

Tested on Windows 2000 and 7, works fine. Attached diff file for convenience.


Description: Patch for fasmg that fixes WriteFile bug with long strings on earlier Windows versions
Download
Filename: writefile.diff.txt
Filesize: 585 Bytes
Downloaded: 786 Time(s)

Post 21 Sep 2016, 11:42
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.