Jump to content
Sign in to follow this  
Rollo62

[Android, 32-Bit, Debug] Projekt raised exception class Bus error (10)

Recommended Posts

Posted (edited)

Hi there,

 

I've got a strange exception, only with Android 32-Bit during Debugging, other platforms including IOS work well.
With iOS 64 I had no issue seen, but wouldn't count on it right now.

 

I use a TDateTime variable,  and want to compare against NULL..

Since TDateTime is a Double with 8 Bytes, a simple cast to Double( Self ) should make not any harm.

Maybe there are special conditions on Android, as Extended is reduced to Double, and maybe there are some conversion side effects with Double as well ?

 

image.thumb.png.4bbdab4d7ba7ba975829e8a0c0715100.png

 

I use a class helper for adding such functionality, which is used in a million other places too.

function  TDateTime_Helper.ToDouble : Double;
begin
    Result := Double( Self );  // Here it crashes, see images enclosed, they only have 2 ARM assembler lines
end;

and I already extended my conversion routing to separated local variables:

// global variable for storage, only reading
var
    LUNull     : TDateTime = TDateTime( 0.0 );  


class function TDateTime_Helper.Create_Null : TDateTime;
begin
    Result := LUNull;  // Could the global variable cause issues in a Thread ?  Buts its readonly.
end;


function TDateTime_Helper.IsNull : Boolean;
var
    LSelf : Double;
    LNull : Double;
begin
    LSelf := Self.ToDouble;         //11.03.20 added local variables, to check Android crash
    LNull := Create_Null.ToDouble;

    if SameValue( LSelf, LNull ) then
        Result := True
    else
        Result := False;
end;

I check a variable, which is called in a thread

if FLastUpdate.IsNull then  // called like this
begin
   ....
end

 

I must confess that I use above scheme in many thousands of places, also heavily within threads (even higher loded),  without an error before.

  • The caller can be debugged very reliable, and the error is very reproducable
  • When the caller comes in first, second, third time, with zero, all is fine
  • When the caller comes in with a real Double value, I can debug and see a valid double value in the watch (e.g. FLastUpdate = 43901.1603147338 )
  • Inside the conversion ToDouble it crashes

 

When entering with Zero, it looks like the images img. 1 and 2  (see the registers changing)

When entering with Date, it looks like img. 3, and immediately it crashes at img. 4

 

What could cause such error, it sounds a little like failure of JNI Bus, but maybe I'M totally on the wrong track ?

Probably there is some genius with a good hint how to fix this nasty bug.

 

 

 

 

 

 

 

Clipboard06_Zero_1.jpg

Clipboard07_Zero_2.jpg

Clipboard08_Date_1.jpg

Clipboard10_Date_2_Crashed.jpg

Edited by Rollo62

Share this post


Link to post
Posted (edited)

I just tired a brute-force approach to get this solved.

I replaced this

function  TDateTime_Helper.ToDouble  : Double;
begin
    Result := Double( Self );
end;

by that

function  TDateTime_Helper.ToDouble  : Double;
var
    LDbl : Double;

begin
    Move( Self, LDbl, Sizeof( LDbl) );

    Result := LDbl;
end;

And believe it or not, I have a crash-less app now.

 

Any ideas or explanations ?

I still would like to get back to the original approach, which should be more effective (untested).

 

 

 

 

 

Edited by Rollo62

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
Sign in to follow this  

×