OSX HTTP Failure

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 446
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

OSX HTTP Failure

Post by raananb » Fri Feb 19, 2021 12:55 pm

The code below is an excerpt of a pretty large piece of code, which works with no problems under Windows and Linux but fails under OSX 10.15.7 (latest update check today 13h26), wxWidgets-3.1.4

It is designed to access (in async mode) the file 'PixNameLatestVersion' on 'www.pixname.com//pixname'

Code: Select all

int NewVersion::CheckNewVersion(...)
{ 
  wxInputStream*    in_streamLatestVersion = NULL;
	
  wxHTTP* http = new wxHTTP();

  http->SetTimeout( 5 ); // seconds

  if( http->Connect("www.pixname.com", 80 ))
  { 
    in_streamLatestVersion = http->GetInputStream("//PixName//PixNameLatestVersion");

    if (in_streamLatestVersion != NULL && http->GetError() == wxPROTO_NOERR)
    { // file present - process it
      
    }
    else
    { // file absent
      return wxNOT_FOUND;
    }    
  }
  
  return wxID_EXIT;
}
The code fails when executing http->GetInputStream(...); I tried to trace the bug in http.cpp using LLDB, but the results are difficult to analyze: sometimes everything goes through OK, sometimes the process stops while executing HTTP code:

(lldb) r
There is a running process, kill it and restart?: [Y/n] y
Process 13204 exited with status = 9 (0x00000009)
Process 13227 launched: '/Users/raananbarzel/ProjetsDB/Pixname4/OSXDebug/PixName4.app/Contents/MacOS/PixName4' (x86_64)
Process 13227 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 8.1
frame #0: 0x00000001001e3bd6 PixName4`wxHTTP::GetInputStream(this=0x00000001016e0e90, path=0x00007ffeefbfd2f8) at http.cpp:516:23
513 if (method.empty())
514 method = m_postBuffer.IsEmpty() ? wxS("GET"): wxS("POST");
515
-> 516 if (!BuildRequest(path, method))
517 return NULL;
518
519 inp_stream = new wxHTTPStream(this);
Target 0: (PixName4) stopped.
(lldb) n
Process 13227 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
frame #0: 0x00007fff736c35ad libsystem_pthread.dylib`pthread_mutex_lock
libsystem_pthread.dylib`pthread_mutex_lock:
-> 0x7fff736c35ad <+0>: cmpq $0x4d55545a, (%rdi) ; imm = 0x4D55545A
0x7fff736c35b4 <+7>: jne 0x7fff736c3625 ; <+120>
0x7fff736c35b6 <+9>: movl $0x1c0, %eax ; imm = 0x1C0
0x7fff736c35bb <+14>: andl 0xc(%rdi), %eax
Target 0: (PixName4) stopped.
(lldb)

I am not very knowledgeable about HTTP or about OSX/LLDB. Can anyone make anything out of this?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5156
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: OSX HTTP Failure

Post by ONEEYEMAN » Fri Feb 19, 2021 5:30 pm

Hi,
Can you run webview sample?

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 446
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: OSX HTTP Failure

Post by raananb » Fri Feb 19, 2021 11:04 pm

The webview sample works fine, but it does not contain GetInputStream()

Sorry.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5156
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: OSX HTTP Failure

Post by ONEEYEMAN » Fri Feb 19, 2021 11:28 pm

Hi,
Then why not drop this and use webview?
You already have a proof that it works...

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 16026
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: OSX HTTP Failure

Post by doublemax » Sat Feb 20, 2021 12:04 am

It is designed to access (in async mode)...
Does "async mode" mean this runs in a secondary thread? If yes, did you call wxSocketBase::Initialize()?

https://docs.wxwidgets.org/trunk/classw ... 0f3d17b29f
Use the source, Luke!

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 446
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: OSX HTTP Failure

Post by raananb » Sat Feb 20, 2021 4:30 pm

The async was an error on my part: the process is synchrone, so webview is not the right solution, and http is needed.

What bugs me is that the same identical code is used in 4 other applications which do not crash when http->GetInputStream() is executed.

I have tried to debug with LLDB, but could not reach a clear conclusion (yet).

I will keep investigating.

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 446
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: OSX HTTP Failure

Post by raananb » Mon Feb 22, 2021 3:51 pm

Problem went away after moving some code in the application (not the code relevant to http, though).

I cannot say the problem was solved, it just disappeared.

Thanks for looking into it.

Post Reply