flat assembler
Message board for the users of flat assembler.

Index > IDE Development > FASM write failed message

Author
Thread Post new topic Reply to topic
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 27 Nov 2011, 14:25
I have problems while compiling many times with error messages.
I get the error "write failed" after several compilations with errors and cleaning and new errors and new cleaning.
As I found this could be caused by an open file but also when there are problems with memory (compiled file sizes).

PS: This thread is continued from Compiler internals (did choose wrong section for problem)
Post 27 Nov 2011, 14:25
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 27 Nov 2011, 14:26
1. The problem is with FASMW (IDE version) - I will open a new thread there.
2. I thought that maybe stack would be restored in another way after stopping program but was not sure. I just found this while porting the code to Z80 instructions.

Quote:
shutdownall, upload your file.


I think this is not really a necessary step because it's an internal error of FASMW anc can not reproduced all the time. The maybe interesting point is that I compile a FASMW source file with modified components which has the same name FASMW but is in another directory. Only changed components are tables.inc and load a z80.inc instead of a x86_64.inc. Anyway this error should not happen regardless which software I compile because it's in the inside of FASMW and don not must happen at all.

It's not very stable, I can reproduce it when it happens till I close the FASMW compiling the other FASMW but can not reproduce stable. Sometimes it is working after restart, sometimes I have to kill FASMW in the task manager because after a new start of FASMW the error is still there. When stopped over task manager the Z80 version of FASMW is compiled without change of my source without error. So I would say there is not an error in my source.

Of course I close always the Z80 version of FASMW. So maybe FASMW is still thinking FASMW Z80 version is still running but is always closed via right mouse click "close" which should be similar to ALT-F4.

I thought it has to do with size of code but as I stripped many lines from x86_64.inc (which is about 143kB, z80.inc is about 99kB). I also changed memory in options => compiler setup => memory from 16kB to maximum 64kb but this does not affect the problem.

Maybe any more ideas ?
Post 27 Nov 2011, 14:26
View user's profile Send private message Send e-mail Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 27 Nov 2011, 17:35
FASMW source is available, so I would look at that source and try to figure out how that message can be issued. Once you see the logical path(s) of that message - maybe you'll see why it is happening.
Post 27 Nov 2011, 17:35
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 27 Nov 2011, 18:06

something like this,
Code:
;FASM.INC

create:     invoke  createFile,edx,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0
  cmp     eax,-1
      je      shutdownall
 mov     ebx,eax
     clc
 retn

write:  invoke  WriteFile,ebx,edx,ecx,bytes_count,0
 or      eax,eax
     jz      shutdownall
 clc
 retn

shutdownall: ;eax=-1/from CreateFile - eax=0/from WriteFile
 invoke  GetLastError
        int3    ;<--- debugger eax=?
     jmp     file_error
    
System Error Codes

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 27 Nov 2011, 18:06
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 27 Nov 2011, 20:38
Hmmm.
Now I had the same.
I just tried to delete the target FASMW.exe with Explorer to see if maybe object is blocked by some program.
Wasn't. After clicking on yes, system deleted it and after that I could compile in the other FASMW instance without closing/restarting it.

Normally file is deleted / overwritten automatically by FASMW.
I could live with that workaround too but still don't know why sometimes the file could not be overridden.
Anyway I did still not found a systematic when this happened. Shocked

Now I try to patch formats.inc to see where the message is coming from.
Has several "write_failed" calls. Rolling Eyes
Post 27 Nov 2011, 20:38
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 27 Nov 2011, 21:33
I tried to implement a kind of error code which is compiled correctly but when I used the changed FASMW.exe it hangs on "compiling" (CTRL-F9). Exactly program ends itself after compiling without any message. What's wrong ?

First I added a variable wfmcode to formats.inc and fill this before calling every write_failed function (there are 7 calls).

Code:
      calculate_code_size:
     mov     [current_offset],edi
        sub     edi,[code_start]
    mov     [code_size],edi
     mov     [written_size],0
    mov     edx,[output_file]
   call    create
      mov     [wfmcode],byte '0'
        jc      write_failed


... several codes of line, up to 7 times filled wfmcode ...

wfmcode: db      0
           db      0
    


In the file fasm.inc in IDE/FASMW directory I added a messagebox in exit_program function (which is called from fatal_error which is called from write_failed):

Code:
exit_program:
    invoke  MessageBox,[hwnd_compiler],wfmcode,wfmcode,MB_OK
    movzx   eax,al
      push    eax
 mov     eax,[allocated_memory]
      or      eax,eax
     jz      memory_ok
   invoke  VirtualFree,eax,0,MEM_RELEASE
       mov     [allocated_memory],0
      memory_ok:
        mov     eax,[hfile]
 or      eax,eax
     jz      handle_ok
   invoke  CloseHandle,eax
      handle_ok:
     invoke  PostMessage,[hwnd_compiler],WM_COMMAND,IDOK,0
       call    [ExitThread]
    


So why is there no MessageBox and program terminates itself after compiling ???

PS: I use WIN XP SP3 on my PC.


Last edited by shutdownall on 27 Nov 2011, 21:44; edited 3 times in total
Post 27 Nov 2011, 21:33
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 27 Nov 2011, 21:37
One additional hint regarding the main problem (write_failed):

I always press F9 which means I start the compiled version directly from FASMW.exe
Post 27 Nov 2011, 21:37
View user's profile Send private message Send e-mail 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.