Page 1 of 1
invalid memory access on closewindow (not every time) ?
Posted: Sun Dec 04, 2016 11:48 am
by sartic
code is simple
procedure that downloads file http asynchronous to disk
it shows progress in bar and when download is finished it close window
i am using finishhttp on http success and aborted before closing window
what can be reason? tried 5.43 and 5.44b4 32 bit on win10 64bit
compiled exe doesn't crush. i have error in with IDE compile/run example:
[12:06:49] [ERROR] Invalid memory access. (read error at address 4294967295)
Re: invalid memory access on closewindow (not every time) ?
Posted: Sun Dec 04, 2016 12:20 pm
by Mistrel
Are you using with threads without enabling the thread safety compiler option?
Re: invalid memory access on closewindow (not every time) ?
Posted: Sun Dec 04, 2016 12:56 pm
by sartic
Mistrel wrote:Are you using with threads without enabling the thread safety compiler option?
no threads. code is in procedure.
Re: invalid memory access on closewindow (not every time) ?
Posted: Sun Dec 04, 2016 1:21 pm
by nco2k
how do you expect anyone to help you, without providing any code? there could be a billion reasons for an invalid memory access.
c ya,
nco2k
Re: invalid memory access on closewindow (not every time) ?
Posted: Sun Dec 04, 2016 2:34 pm
by sartic
nco2k wrote:how do you expect anyone to help you, without providing any code? there could be a billion reasons for an invalid memory access.
c ya,
nco2k
Code: Select all
Procedure.q ReceiveHTTPFile_(p_url.s,p_file.s)
p_download.q=0
p_width=512
p_height=30
p_progress=0
p_f.f=0
p_size.q=0
p_window=0
If p_size<=0
Header$ = GetHTTPHeader(p_url)
Index=0
Repeat
Index+1
Line$ = LTrim(StringField(Header$, Index, #LF$))
If Left(LCase(Line$),Len("Content-Length:"))="content-length:"
p_size=Val(Mid(Line$,Len("Content-Length:")+1))
EndIf
Until Line$ = ""
EndIf
p_kb=p_size/1024
p_window=OpenWindow(#PB_Any,10,10,p_width,p_height,"",#PB_Window_ScreenCentered)
ProgressBarGadget(1,1,1,p_width,p_height,1,p_width,#PB_ProgressBar_Smooth)
SetActiveWindow(p_window)
p_ms.q=ElapsedMilliseconds()-1
p_ms2.q=ElapsedMilliseconds()
p_download=ReceiveHTTPFile(p_url,p_file,#PB_HTTP_Asynchronous)
Repeat
p_progress=HTTPProgress(p_download)
Select p_progress
Case #PB_Http_Success
FinishHTTP(p_download)
p_download=FileSize(p_file)
Break
Case #PB_Http_Failed
p_download=0
Break
Case #PB_Http_Aborted
FinishHTTP(p_download)
p_download=0
Break
Default
p_f=p_progress/p_size*p_width
SetGadgetState(1,p_f)
p_f=(p_progress/1024)/((ElapsedMilliseconds()-p_ms)/1000)
SetWindowTitle(p_window,"Download: "+p_file+" ["+Str(p_kb)+"KB] = "+Str(p_f)+"KB/s") ; bytes: "+Str(p_progress)+"/"+Str(p_size))
If (ElapsedMilliseconds()-p_ms2)>1800
Delay(200)
p_ms2=ElapsedMilliseconds()
; WaitWindowEvent()
EndIf
EndSelect
ForEver
CloseWindow(p_window)
If p_download=0
DeleteFile(p_file)
EndIf
ProcedureReturn p_download
EndProcedure
web_dl.s="http://bios-ict.hr/dl/"
prog_tv.s="TeamViewerQS_hr.exe"
file1.s=""
hr_desktop.s=GetHomeDirectory()+"Radna Površina\"
desktop.s=GetHomeDirectory()+"Desktop\"
If FileSize(desktop)<>-2
desktop=hr_desktop
EndIf
InitNetwork()
file1=prog_tv
If FileSize(file1)=-1 And FileSize(desktop+file1)=-1
If ReceiveHTTPFile_(web_dl+prog_tv,prog_tv)
Delay(500)
EndIf
EndIf
If FileSize(desktop+file1)=-1
If RenameFile(file1,desktop+file1)
Delay(500)
RunProgram(desktop+file1)
EndIf
EndIf
End 0
__________________________________________________
Code tags added
05.12.2016
RSBasic
Re: invalid memory access on closewindow (not every time) ?
Posted: Mon Dec 05, 2016 8:05 am
by netmaestro
You have to process window events. Even if you're not going to act on them, there has to be at least a WindowEvent() in there or it'll eventually crash.
Re: invalid memory access on closewindow (not every time) ?
Posted: Mon Dec 05, 2016 11:46 am
by sartic
netmaestro wrote:You have to process window events. Even if you're not going to act on them, there has to be at least a WindowEvent() in there or it'll eventually crash.
thx
Re: invalid memory access on closewindow (not every time) ?
Posted: Tue Dec 06, 2016 9:01 am
by sartic
netmaestro wrote:You have to process window events. Even if you're not going to act on them, there has to be at least a WindowEvent() in there or it'll eventually crash.
no luck, crush on closewindow(again not every time):
[08:55:53] [ERROR] Invalid memory access. (read error at address 4294967295)
Re: invalid memory access on closewindow (not every time) ?
Posted: Fri Dec 16, 2016 12:20 pm
by firace
Try to add this as the first line of your program:
Re: invalid memory access on closewindow (not every time) ?
Posted: Sun Dec 18, 2016 7:18 am
by sartic
i solved it (i hope

only when i add delay before finishhttp error is gone in compile/run and in compiled exe