Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class segmentation fault (11)

Please follow the steps below:

  1. Create New Firemonkey Moblie Application
  2. Add TGeustureManager component to the Form
  3. Add 2 TButton components to the Form

    • Button1.Text: "Button1: Do something..."
    • Button2.Text: "Button2: Exit Application..."

    The application should appear like this

  4. Double click on Button2 Component and write the following code for OnClick Event:

    procedure TForm1.Button2Click(Sender: TObject);
    begin
      if MessageDlg('Are you sure you want to Exit?', TMsgDlgType.mtWarning,
              [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
        SharedActivity.finish;
    end;
    
  5. Run the application in debug mode.
  6. on the device, click the button 2, then click yes to the popped up message. An exception will appear:

    enter image description here

Why is this exception raised?

I thought it is related to unused TGeustureManager component. but NO it is NOT:

  1. If you open the Location Demo project that comes with Delphi xe5.
  2. Add TButton component to Location Label as shown in the image below: enter image description here
  3. Add the same code as above to OnClick Event.
  4. Run the application, and click on Button5, you will get the same exception.

Is this a bug should I report? or am I doing something wrong?

like image 372
Oussama Al Rifai Avatar asked Nov 09 '13 10:11

Oussama Al Rifai


People also ask

What is segmentation fault error in C?

A common run-time error for C programs by beginners is a "segmentation violation" or "segmentation fault." When you run your program and the system reports a "segmentation violation," it means your program has attempted to access an area of memory that it is not allowed to access.

What is zsh segmentation fault?

A segmentation fault (aka segfault) is a common condition that causes programs to crash; they are often associated with a file named core . Segfaults are caused by a program trying to read or write an illegal memory location.


2 Answers

Possibly that you are killing the activity that is running, before its execution flow has been exhausted, thereby causing problems. Much like freeing a form in a form method....

What happens if you replace:

SharedActivity.finish

with:

uses
  FMX.Helpers.Android;
...
CallOnUIThread(procedure begin SharedActivity.finish end);

[ Typed from memory, so may need some tweaking ]

like image 147
blong Avatar answered Sep 21 '22 04:09

blong


I have contacted Embarcadero for this issue.

They said that it is because TApplication.Terminate is not yet implemented in FireMonkey platform for mobile.

They open a ticket to implement TApplication.Terminate in nex hot fix.

Let's hope that will not take ages.

like image 45
Oussama Al Rifai Avatar answered Sep 24 '22 04:09

Oussama Al Rifai