[5.73] HTTPRequest() in async mode lead to a crash

Post bugreports for the Mac OSX version here
User avatar
deseven
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

[5.73] HTTPRequest() in async mode lead to a crash

Post by deseven »

As discussed here.

Code: Select all

EnableExplicit

InitNetwork()

OpenWindow(0,0,0,400,300,"HTTPRequest test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
EditorGadget(0,0,0,400,300,#PB_Editor_WordWrap|#PB_Editor_ReadOnly)

; spawn various async HTTP requests
NewList requests.i()

; #1 a simple get request
AddElement(requests())
requests() = HTTPRequest(#PB_HTTP_Get,"https://httpbin.org/get?var=value","",#PB_HTTP_Asynchronous)

; #2 a simple post request
AddElement(requests())
requests() = HTTPRequest(#PB_HTTP_Post,"https://httpbin.org/post","var=value",#PB_HTTP_Asynchronous)

; #3 a request with redirect
AddElement(requests())
requests() = HTTPRequest(#PB_HTTP_Get,"http://httpstat.us/301","",#PB_HTTP_Asynchronous)

; #4 a request which will be completed after 30 seconds
AddElement(requests())
requests() = HTTPRequest(#PB_HTTP_Get,"http://httpstat.us/200?sleep=30000","",#PB_HTTP_Asynchronous)

; #5 a request to a non-existent domain
AddElement(requests())
requests() = HTTPRequest(#PB_HTTP_Get,"https://nodomain.d7.wtf","",#PB_HTTP_Asynchronous)

; #6 a request which will timeout
AddElement(requests())
requests() = HTTPRequest(#PB_HTTP_Get,"http://www.google.com:81/","",#PB_HTTP_Asynchronous)

Define ev,log.s

Repeat
  ev = WaitWindowEvent(100)
  ForEach requests()
    If requests() <> 0
      Select HTTPProgress(requests())
        Case #PB_HTTP_Success,#PB_HTTP_Failed,#PB_HTTP_Aborted
          log = "[" + FormatDate("%hh:%ii:%ss",Date()) + "] Finished #" + Str(ListIndex(requests()) + 1)
          If HTTPInfo(requests(),#PB_HTTP_StatusCode)
            log + ", http code: " + HTTPInfo(requests(),#PB_HTTP_StatusCode)
          EndIf
          If HTTPInfo(requests(),#PB_HTTP_ErrorMessage)
            log + ", error: " + HTTPInfo(requests(),#PB_HTTP_ErrorMessage)
          EndIf
          AddGadgetItem(0,0,log)
          FinishHTTP(requests())
          requests() = 0
      EndSelect
    EndIf
  Next
Until ev = #PB_Event_CloseWindow
1. Compile it (compiler params or debugger state don't matter).
2. Run and wait for it to finish the requests (in about 100 seconds).
3. Let it sit there doing completely nothing for the next several minutes, just leave the window active or switch to something else.
4. It will crash.

Compiler/debugger params don't matter.

Videos showing the crash on various macOS versions:
https://d7.wtf/s/pb573-highsierra-crash.mp4
https://d7.wtf/s/pb573-mojave-crash.mp4
https://d7.wtf/s/pb573-catalina-crash.mp4

Crash reports from High Sierra and Big Sur (by mk-soft):

Code: Select all

Process: Http-Test [561]
Path: /Volumes/*/Http-Test.app/Contents/MacOS/Http-Test
Identifier: Http-Test
Version: 0.1
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Http-Test [561]
User ID: 501

Date/Time: 2021-06-12 11:53:58.247 +0200
OS Version: Mac OS X 10.13.6 (17G14033)
Report Version: 12
Anonymous UUID: 3FE244D9-6BE0-03E2-6CEA-4C3E0015D107


Time Awake Since Boot: 360 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00007000073938a8
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

Code: Select all

Process: Http-Test [3801]
Path: /Users/USER/*/Http-Test.app/Contents/MacOS/Http-Test
Identifier: Http-Test
Version: 0.1
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Http-Test [3801]
User ID: 501

Date/Time: 2021-06-12 12:02:40.031 +0200
OS Version: macOS 11.1 (20C69)
Report Version: 12
Bridge OS Version: 5.1 (18P3030)
Anonymous UUID: 6BC53F77-49C4-871A-4014-89D0CCC3D0C5

Sleep/Wake UUID: 5DDE25BF-8628-43DC-A662-D487021778A3

Time Awake Since Boot: 42000 seconds
Time Since Wake: 9700 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000070000b61d960
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [3801]

VM Regions Near 0x70000b61d960:
Stack 70000b60b000-70000b60d000 [ 8K] rw-/rwx SM=PRV
-->
Stack 70000b61e000-70000b620000 [ 8K] rw-/rwx SM=PRV

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_platform.dylib 0x00007fff203a84d8 _longjmp + 44
1 Http-Test 0x000000010001cd85 0x100000000 + 118149