CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    15

    SIGBUS error when porting from X86 to ARM

    Hello,

    I came with a SIGBUS error when importing a C++ code from X86 to ARM. Below is the code snippet where problem occurs, and appreciate your suggestions.

    <code>
    class clsMatrix {
    protected:
    double *pM;
    int m;
    int n;

    BOOL m_bAutoDelete;
    //m_bAutoDeletenewbAutoDeleteTRUEbAutoDeleteFALSE

    public:
    clsMatrix();
    clsMatrix(int m, int n, double *p = NULL, BOOL bAssign = FALSE);

    ~clsMatrix();

    void Reset();
    void Reset(int i, int j, double *p = NULL, BOOL bAssign = FALSE);

    // Attributes
    int GetM() { return m; }
    int GetN() { return n; }
    double *GetP() { return pM; }

    BOOL EqualSize(clsMatrix &M) { return ((m == M.m) && (n == M.n)); }

    public:
    // Operators
    double * operator [] (int i) { return pM+i*n; }

    clsMatrix & operator = (clsMatrix &M);
    clsMatrix & operator = (double *p);
    clsMatrix & operator = (double x);
    clsMatrix & operator += (clsMatrix &M);
    clsMatrix & operator += (double *p);
    clsMatrix & operator -= (clsMatrix &M);
    clsMatrix & operator -= (double *p);
    clsMatrix & operator *= (clsMatrix &mtrx); //
    clsMatrix & operator *= (double *p);
    clsMatrix & operator *= (double a);
    clsMatrix & operator /= (double a);

    static void X(clsMatrix &mtrx1, clsMatrix &mtrx2, clsMatrix &mtrx); //multiple
    static void X(clsMatrix &mtrx1, clsVector &vctr2, clsVector &vctr);
    static void X(clsVector &vctr1, clsMatrix &mtrx2, clsVector &vctr);
    static void T(clsMatrix &mtrx1, clsMatrix &mtrx); //transpose
    static void R(clsMatrix &mtrx1, clsMatrix &mtrx); //inverse
    static void S(clsMatrix &mtrx1, int m0, int m1, int n0, int n1, clsMatrix &mtrx, int m = 0, int n = 0);
    static void S(clsVector &vctr1, int m0, int m1, clsVector &vctr, int m = 0);

    double e();
    double e2();
    double ei();

    public:
    BOOL LoadT(char *pszFile);
    BOOL SaveT(char *pszFile);

    friend class clsVector;
    };

    clsMatrix::clsMatrix()
    {
    m = n = 0;
    pM = NULL;
    m_bAutoDelete = FALSE;
    }
    </code>

    the problem happens in the clsMatrix constructor, whenever a clsMatrix object is declared, the SIGBUS error occurs, unless the contructor is empty with all statements being commented out.

    Regards,
    Eric

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: SIGBUS error when porting from X86 to ARM

    Quote Originally Posted by Ericxx View Post
    Hello,

    I came with a SIGBUS error when importing a C++ code from X86 to ARM.
    SIGBUS? That is not a term used by developers using Visual C++ when a crash occurs. Are you using gcc? If so, this forum is specifically for Visual C++ issues. The forum you want is the non-Visual C++ forum.
    Below is the code snippet where problem occurs, and appreciate your suggestions.
    1) Please use proper code tags when posting code. A code tag on this forum is

    [code]
    Your code goes here:
    [/code]

    2) Please post a main() program that demonstrates the error, not just the class.

    3) Just on sight, your class is dangerous to use since it has no user-defined copy constructor or assignment operator that takes care of the pointer member variable.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: SIGBUS error when porting from X86 to ARM

    Without being an ARM expert... I think that a SIGBUS error is caused by a write to an odd address on processors incapable of doing so, check the addresses of the pointers used.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  4. #4
    Join Date
    Jun 2008
    Posts
    15

    Re: SIGBUS error when porting from X86 to ARM

    Thanks. I have reposted this thread in the non-Visual C++ programming and provided the address of each class member for reference.

    To S_M_A, all the member addresses are 4byte apart tho on the target.
    here is the reposted thread: http://www.codeguru.com/forum/showthread.php?t=502146

    Eric
    Last edited by Ericxx; August 31st, 2010 at 10:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured