Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-10

InitThread/DoneThread

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

In the latest version of MacOS calls to InitThread starting crashing so I removed the InitThread/DoneThread pair and surprisingly nothing broke. I was instructed some years ago to include these in my threads to support the FPC runtime but what are they really for? I wasn’t able to get any support as to why their crashing but if they’re needed I’d like to omit them obviously.

Regards,
Ryan Joseph

Michael Van Canneyt
to Ryan Joseph
Ryan Joseph wrote 6 lines
In the latest version of MacOS calls to InitThread starting crashing so I removed the InitThread/DoneThread pair and surprisingly nothing broke. I was instructed some years ago to include these in my threads to support the FPC runtime but what are they really for? I wasn’t able to get any support as to why their crashing but if they’re needed I’d like to omit them obviously.

Normally they are called internally when needed.

Why you were advised to include these calls explicitly ?

The only reason I can think of is when your code runs in a DLL, called by an application that creates threads externally, or when you have callbacks from a DLL which can be called from a thread created by the DLL.

Michael.

Ryan Joseph
to Michael Van Canneyt
Show quoted text 7 lines
On Oct 27, 2017, at 4:02 PM, Michael Van Canneyt wrote: Why you were advised to include these calls explicitly ? The only reason I can think of is when your code runs in a DLL, called by an application that creates threads externally, or when you have callbacks from a DLL which can be called from a thread created by the DLL.

I don’t remember because it was years ago. I believe Jonas advised this but it may have been related to Objective Pascal and some bugs that existed back then. The threads I’m creating are coming from Apple's Cocoa framework (which were crashing) but I was also using it in the SDL library for platform independent threads (which isn’t crashing).

Maybe just old obsolete information so I’ll remove them since they weren’t doing anything anyways as far as I can tell. Thanks.

Regards,
Ryan Joseph

Sven Barth
"Ryan Joseph" wrote
On Oct 27, 2017, at 4:02 PM, Michael Van Canneyt
Why you were advised to include these calls explicitly ? The only reason I can think of is when your code runs in a DLL, called by

an

application that creates threads externally, or when you have callbacks

from

a DLL which can be called from a thread created by the DLL.

I don’t remember because it was years ago. I believe Jonas advised this but it may have been related to Objective Pascal and some bugs that existed back then. The threads I’m creating are coming from Apple's Cocoa framework (which were crashing) but I was also using it in the SDL library for platform independent threads (which isn’t crashing).

Maybe just old obsolete information so I’ll remove them since they weren’t doing anything anyways as far as I can tell. Thanks.

I'd guess that this was before lazy initialization of threadvars for pthreads was implemented (in 2.4 or 2.6 I think). Nowadays that should indeed not be necessary anymore.

Regards,
Sven