Struggling with PB HTTP library

Mac OSX specific forum
User avatar
deseven
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Struggling with PB HTTP library

Post by deseven »

I've been having problems with random crashes for the last couple of months. I've put a lot of effort into debugging it and at this point i'm so pissed off that it drives me mad. I wrote about it here and even reported a couple of things that look like bugs to me (see the macos bugs section), but several people told me that they never had any problems and i must be doing something wrong or i just don't understand how it works.

Well, long story short, today i managed to strip everything down to this:

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.

The debugger isn't catching anything, but on the system level i get various errors, starting from "segmentation fault" and "illegal instruction" to "alarm" (whatever the last one means).

Can please anyone confirm this? Am i doing something wrong again? If so, what exactly?
User avatar
skywalk
Addict
Addict
Posts: 3529
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Struggling with PB HTTP library

Post by skywalk »

Please post all compilation settings.
ThreadSafe?, Etc.
Which target os?
Does it crash without debugger?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
deseven
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Struggling with PB HTTP library

Post by deseven »

I'm, like, 99% sure you can get it by reading my post and looking at section it was posted in, but alright :)
1. Compiler flags don't matter.
2. MacOS.
3. Debugger doesn't matter.
Wolfram
Enthusiast
Enthusiast
Posts: 526
Joined: Thu May 30, 2013 4:39 pm

Re: Struggling with PB HTTP library

Post by Wolfram »

it is a problem of port 81. https://www.google.com:81 in safari will also not open.
You should try If requests() <> 0 instead of If requests() > 0.
User avatar
deseven
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Struggling with PB HTTP library

Post by deseven »

Wolfram wrote: Sat Jun 05, 2021 8:05 pm it is a problem of port 81. https://www.google.com:81 in safari will also not open.
As it should, it's stated right above this request in a comment.
Anyway, even if that's the case - why should a non-working website crash your app?
Wolfram wrote: Sat Jun 05, 2021 8:05 pm You should try If requests() <> 0 instead of If requests() > 0.
I don't think HTTPRequest() can return negative values, but anyway - this changes nothing, it still crashes.
User avatar
deseven
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Struggling with PB HTTP library

Post by deseven »

So can anyone confirm that?

I tried it on a clean VM (Catalina, PB 5.73 LTS), just in case there's something wrong with my current system and got exactly the same result - it crashes after a while. I also asked a friend with macbook to test the compiled app and it crashed for him as well.
User avatar
mk-soft
Addict
Addict
Posts: 3110
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Struggling with PB HTTP library

Post by mk-soft »

I ran it under macOS Big Sur (v11.1) and PB v5.73. With debugger and as APP.

Mac Mini 2018, Intel Core I7

No crash. Maybe it's because of Catalina ?
[18:15:32] Finished #6, http code: 0, error: Failed to connect to www.google.com port 81: Operation timed out
[18:14:48] Finished #4, http code: 200
[18:14:19] Finished #3, http code: 200
[18:14:18] Finished #2, http code: 200
[18:14:18] Finished #1, http code: 200
[18:14:17] Finished #5, http code: 0, error: Couldn't resolve host 'nodomain.d7.wtf'
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace
User avatar
deseven
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Struggling with PB HTTP library

Post by deseven »

Have you tried waiting 3-7 minutes after all requests were completed?
mrbungle
User
User
Posts: 16
Joined: Wed Dec 30, 2020 3:18 am

Re: Struggling with PB HTTP library

Post by mrbungle »

didn't crash for me either
User avatar
mk-soft
Addict
Addict
Posts: 3110
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Struggling with PB HTTP library

Post by mk-soft »

Confirm crash on VM High Sierra
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]
Confirm crash on Big Sur
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
Time to create macOS Bug report
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace
User avatar
deseven
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Struggling with PB HTTP library

Post by deseven »

mk-soft wrote: Sat Jun 12, 2021 10:57 am Confirm crash on VM High Sierra
Confirm crash on Big Sur
Thank you! I created a bug report here.
Post Reply