Jump to content
Sign in to follow this  

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

Recommended Posts

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 ?




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

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

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

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

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

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

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

I check a variable, which is called in a thread

if FLastUpdate.IsNull then  // called like this


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.












Edited by Rollo62

Share this post

Link to post

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

I replaced this

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

by that

function  TDateTime_Helper.ToDouble  : Double;
    LDbl : Double;

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

    Result := LDbl;

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