Unhandled StackOverflowException when connecting to a HTTPSecureSocket

Was doing some testing when I got an unhandled exception. Here is the session log:

[quote]2019-03-29, 14:15:43 unhandled exception!!!
2019-03-29, 14:15:43 Buffer:
2019-03-29, 14:15:43 --------------------------
2019-03-29, 14:15:43 An error happened:
2019-03-29, 14:15:43 Window/Class:
2019-03-29, 14:15:43 Method/Event:
2019-03-29, 14:15:43 Error Message: A really unexpected error occurred!
2019-03-29, 14:15:43 Time: Friday, 29. March 2019 14:15:43 15439641
2019-03-29, 14:15:43 Type of Error: StackOverflowException
2019-03-29, 14:15:43 --------------------------
2019-03-29, 14:15:43 Stack:
2019-03-29, 14:15:43
Sub HTTPSecureSocket.Event_Connected()
Sub SSLSocket._Poll()
2019-03-29, 14:15:43 Stack done
2019-03-29, 14:15:43 ErrorReportWindow.Constructor
2019-03-29, 14:16:12 ErrorReportWindow.Constructor done[/quote]

Checking my code I only have 2 sockets: I don’t think that the Kaju socket makes the error. The other socket is very simple:

Socket = new HTTPSecureSocket Socket.Secure = True Socket.ConnectionType = HTTPSecureSocket.TLSv12

and

Socket.SetFormData("some dictionary") Socket.Post(some url)

Does anyone have an idea how to trap the exception? Xojo 2018r3, Mojave latest version.

I don’t think you can trap a stack overflow… usually this is caused by an unitentional recursion of some type

function test
test()
end function

No recursion for the socket.

I have been able to get the problem a couple of times now on Mojave. Never for High Sierra. The socket doesn’t do very much.

A workaround instead of trapping the error also would be fine.

the point is… somewhere there is recursion… perhaps not obvious… and perhaps not even socket related… but something somewhere is calling a piece of code without ever providing a proper exit

the problem with a stack overflow, is by the time it has happened, there are no resources let to allow it to be reported by Xojo

Do you poll either one ?
And do you call DoEvents anywhere in your app ?

[quote=431067:@Dave S]the point is… somewhere there is recursion… perhaps not obvious… and perhaps not even socket related… but something somewhere is calling a piece of code without ever providing a proper exit

the problem with a stack overflow, is by the time it has happened, there are no resources let to allow it to be reported by Xojo[/quote]
The IDE should break if you are running in debug mode though. Looking at the stack should make the recursion very obvious.

There is no recursion. In debug mode the app doesn’t go into the debugger as it would for a normal StackOverflow. I get a sort of empty debugger. When I click on run then I get the usual stuff that my app does for unhandled exceptions.

There is no polling and neither is there any DoEvents.

I think I read somewhere else that someone else is having trouble with Sockets on the latest Mojave. Do you have another machine running a different version of the macOS to test with?

@Sam Rowlands: yes, no problems on High Sierra with my main development machine. I also don’t have reports from customers about the problem.

In my opinion I would go as far as to say that perhaps Apple have broken something or changed something in a way which might be causing Xojo’s socket implementation to now have issues.

Like a crazy person, I keep hoping that one of these days, Apple is going to focus on stability, but I still get dissappointed to see this kind of stuff.

Incidentally, this morning I received a report from a customer where an application is borked where the interface is in dark mode. It’s like some of the controls are correctly using the color constants; while others are not.

It worries me to no end; I am almost ready to ship a brand new application that’s been completely rebuilt in the hopes for maximum Mojave compatibility.

I haven’t had time to look at the issue again.

In the latest version my app can download external images for emails. The old socket was a no-go because HTTP/1.1. The newer Xojo.Core socket made hard crashes. And Curl from MBS also makes hard crashes. I wasn’t so eager to go for the URLConnection.

And don’t get me started on AppTranslocation and the stupid permissions on Mojave.

[quote]The other socket is very simple:

Socket = new HTTPSecureSocket Socket.Secure = True Socket.ConnectionType = HTTPSecureSocket.TLSv12
and

Socket.SetFormData("some dictionary") Socket.Post(some url)
[/quote]
Any chance you could make a copy of your this socket and any code that touches it into a sample project so we could look at it?

The code is available at https://www.mothsoftware.com/downloads/GoogleAnalytics.zip .

A simple

dim theLogger as new LogToAnalytics theLogger.AddPageView("Window1")

is enough for testing. Of course, this doesn’t make a StackOverflow. Putting the code into a thread doesn’t change anything.

Can another plugin bork the rest of Xojo?

I have some intense fun with the Valentina plugin in the last weeks. The Valentina people have done several tries at doing a database diagnosis without showing the beachball - it either didn’t work or made a crash. I have now reverted back to a stable version of Valentina on this machine and I don’t get a StackOverflow anymore.

As a sidenote, maybe related. Since latest Mojave update i had crashes related to SSL connection using HTTPSecureSocket, but only if the App was Sandboxed.
I had to replace those Sockets with the new URLConnection. Crashes then vanished and Apple approved my App.

@Beatrix Willius — That weird StackOverflowException which does not look like a real one reminds me of Cocoa callbacks in macosLib. We usually had to insert “#pragma stackOverflowChecking false” at the beginning of any method which would be invoked from Cocoa in order to avoid fake StackOverflowExceptions.

May be worth a try

@Stephane Mons: Thomas T. mentioned something like this, too. As soon as I get the error again I’ll try your suggestion.