It is currently Sat Oct 19, 2019 6:58 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Repeatedly aborted async HTTPRequest() will crash
PostPosted: Wed Aug 21, 2019 11:11 am 
Offline
User
User

Joined: Tue Feb 14, 2006 2:00 pm
Posts: 63
Hi,

when I will run this code then it works few times (+- 10 loops) and then it will crash at a random line.

Code:
Repeat
  HttpRequest = HTTPRequest(#PB_HTTP_Post, "https://www.google.com", "", #PB_HTTP_Asynchronous)
  If HttpRequest
    Debug "started"
    AbortHTTP(HttpRequest)
    FinishHTTP(HttpRequest)
    Debug "aborted"
  EndIf
ForEver


Result:
[12:08:35] Waiting for executable to start...
[12:08:35] Executable type: Windows - x86 (32bit, Unicode)
[12:08:35] Executable started.
[12:08:35] [ERROR] Line: 2
[12:08:35] [ERROR] Invalid memory access. (read error at address 74608671)
[12:08:35] [ERROR] Line: 2
[12:08:35] [ERROR] Invalid memory access. (write error at address 74047512)
[12:08:35] The Program execution has finished.

After this crash any further execution of Purebasic code can start crashig on random lines (opening windows for example) and it needs a restart.

Happens on:
PureBasic 5.71 beta 3 LTS (Windows - x86)


Top
 Profile  
Reply with quote  
 Post subject: Re: Repeatedly aborted async HTTPRequest() will crash
PostPosted: Thu Aug 22, 2019 8:45 am 
Offline
User
User

Joined: Sun Dec 28, 2014 1:12 pm
Posts: 11
Code:
InitNetwork()

Repeat
   HttpRequest = HTTPRequest(#PB_HTTP_Post, "https://www.google.com", "", #PB_HTTP_Asynchronous)
   If HttpRequest
      Debug "started"
      AbortHTTP(HttpRequest)
      Repeat
         Progress = HTTPProgress(HttpRequest)
         Select Progress
            Case #PB_HTTP_Aborted
               Debug "aborted"
               FinishHTTP(HttpRequest)
               Break
         EndSelect
         Delay(300) ; Don't stole the whole CPU
      ForEver
   EndIf
ForEver


Top
 Profile  
Reply with quote  
 Post subject: Re: Repeatedly aborted async HTTPRequest() will crash
PostPosted: Fri Aug 23, 2019 2:11 pm 
Offline
User
User

Joined: Sun Dec 28, 2014 1:12 pm
Posts: 11
Code:
InitNetwork()

Debug "#PB_HTTP_Success: "+#PB_HTTP_Success
Debug "#PB_HTTP_Failed: "   +#PB_HTTP_Failed
Debug "#PB_HTTP_Aborted: "+#PB_HTTP_Aborted   

Repeat
   HttpRequest = HTTPRequest(#PB_HTTP_Post, "https://www.google.com", "", #PB_HTTP_Asynchronous)
   If HttpRequest
      Debug "started"
      AbortHTTP(HttpRequest)
      Repeat
         Progress = HTTPProgress(HttpRequest)
         Select Progress
            Case #PB_HTTP_Aborted
               Debug "aborted"
               FinishHTTP(HttpRequest)
               Break
            Default
               Debug "status: "+Progress
         EndSelect
         Delay(300) ; Don't stole the whole CPU
      ForEver
   EndIf
ForEver

Code:
[16:02:40] Waiting for executable to start...
[16:02:40] Executable type: Windows - x86  (32bit, Unicode)
[16:02:40] Executable started.
[16:02:40] [Debug] #PB_HTTP_Success: -2
[16:02:40] [Debug] #PB_HTTP_Failed: -3
[16:02:40] [Debug] #PB_HTTP_Aborted: -4
[16:02:40] [Debug] started
[16:02:40] [Debug] status: -5
[16:02:40] [Debug] aborted
[16:02:40] [Debug] started
[16:02:40] [Debug] status: -5
[16:02:40] [Debug] aborted


Hello!
Does anyone know what HTTPProgress status=-5 means?


Last edited by tester on Fri Aug 23, 2019 9:15 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Repeatedly aborted async HTTPRequest() will crash
PostPosted: Fri Aug 23, 2019 3:02 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3083
Location: Boston, MA
No crash with PB v571 LTS x64.
I rarely use x86 except for dll's to talk with legacy x86 app's.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Repeatedly aborted async HTTPRequest() will crash
PostPosted: Sat Aug 24, 2019 4:38 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 333
Crashes here for me with the code as posted, but only when the #PB_HTTP_Asynchronous flag is used. So it seems the code is getting its "HttpRequest" variable value overwritten too quickly. Adding a short delay (250 ms or so) seems to fix it:

Code:
InitNetwork()
Repeat
  HttpRequest= HTTPRequest(#PB_HTTP_Post, "https://www.google.com", "", #PB_HTTP_Asynchronous)
  If HttpRequest
    Debug "started"
    AbortHTTP(HttpRequest)
    FinishHTTP(HttpRequest)
    Debug "aborted"
    Delay(250) ; Quarter-second delay so "HttpRequest" var isn't overwritten with the next request.
  EndIf
ForEver


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye