Jump to content
Vandrovnik

Firemonkey app for Android - segmantation fault in TIdThreadSafe.Lock

Recommended Posts

Hello,

 

I am trying to make a FMX application for Android. When I close the application, I get:

Debugger Exception Notification: Project PlantisReaderPro.apk raised exception class Segmentation fault (11).

 

When I choose Break, IDE positions cursor here in file IdThreadSafe.pas:

 

procedure TIdThreadSafe.Lock;
begin
  FCriticalSection.Enter;        <---------------
end;

 

But in my project, I am not using any Indy components. I have used GExpert, MMX and DUDS to scan used units, they do not show anything starting "Id". I do use IBX and ZXing.

Please do you have any idea how to get rid of it? I am including image of the call stack.

 

Kind regards,

 

Karel

 

 

id.png

Share this post


Link to post
10 hours ago, Vandrovnik said:

But in my project, I am not using any Indy components.

Yes, you are. Easiest way to track down where is to check the units compiled units (.dcu files)

Share this post


Link to post
14 minutes ago, Dave Nottage said:

Yes, you are. Easiest way to track down where is to check the units compiled units (.dcu files)

This was the very first thing I have checked - there is no Idxxx among them.

Share this post


Link to post
16 minutes ago, Dave Nottage said:

Yes, you are. Easiest way to track down where is to check the units compiled units (.dcu files)

(But I would not see Idxxx.dcu even in projects where I do use Indy, because there I am using the Indy which came with Delphi, so it is not recompiled with the project.)

Share this post


Link to post
2 hours ago, Vandrovnik said:

(But I would not see Idxxx.dcu even in projects where I do use Indy, because there I am using the Indy which came with Delphi, so it is not recompiled with the project.)

You would if you included the Indy source path. If the callstack says it's being used, you're using it.

 

Does your app use any tethering functionality? That ultimately includes Indy units.

  • Thanks 1

Share this post


Link to post

Based on the stack trace in the error message, there is a TIdThread object being destroyed during the finalization of the System.Classes unit.  Somewhere in your project, there is a TDictionary holding TThread pointers to TIdThread objects, and that dictionary is being destroyed during unit finalization, freeing the threads that it contains.

 

Inside the TIdThread destructor, there is a global TIdThreadSafeInteger object named GThreadCount in Indy's IdThread unit that is being decremented.  The TIdThreadSafe... classes have a TCriticalSection object inside of them.

 

So, based on this error, it is fairly clear that *something* in your project is using Indy, even if *you* are not using Indy in your code, and that Indy's IdThread unit is likely being finalized early, freeing the GThreadCount object while there are still 1 or more TIdThread objects running.  Whoever is maintaining a dictionary of threads is likely not terminating their threads before your program exits.

 

Note: the GThreadCount object is marked as deprecated in the latest version of Indy on GitHub, so it will be removed eventually, so this won't be a problem anymore.  But that does not help you right now.

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×