The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice - Linux

This is a discussion on The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice - Linux ; Hi All, I am in process of porting Linux project to 64-bit systems. The project needs to support 64-bit as well as 32-bit platforms. I am facing some issues while porting my daemon, that acts as USB bulk device driver, ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice

  1. The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice

    Hi All,

    I am in process of porting Linux project to 64-bit systems. The project
    needs to support 64-bit as well as 32-bit platforms.

    I am facing some issues while porting my daemon, that acts as USB bulk
    device driver, (it uses libusb) and wanted your expert

    advice for the same.

    I have followed proper guidelines while making the code portable.

    Refered:http://www-128.ibm.com/developerwork..._64_linux.html

    I have adopted the following strategy:

    a) Machine details: Developing & compiling the daemon on 64-bit
    platform machine. Below are the machine details:

    Machine type: x86_64 GNU/Linux
    Red Hat Enterprise Linux Version 4 WorkStation
    Processor: Intel(R) Pentium(R) 4 CPU 3.00 GHz
    The gcc version: 4.0.2

    b) Developing 32-bit and 64-binary seperately on the above mentioned
    development machine

    For 32-bit binary, used following to compile:
    CC=gcc -m32 -O

    For 64-bit binary, used following to compile:
    CC=gcc -O



    c) Deploying:
    I am deploying the 32 bit binary on 32-bit machine and 64-bit binary
    on 64-bit machine.


    Outcome:

    The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit
    MACHINE!!!

    The details of 32-bit machine are:
    i386 GNU/Linux
    Fedora Core 6
    gcc (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)

    If I build the daemon on 32-bit machine with same code, it runs fine on
    32-bit machine.


    On debugging the daemon on 32-bit, it seemed like the stack has been
    corrupted. It throws a "segmentation fault". One of The

    function is throwing a segmentation fault on return.

    I know that there can be n number of reasons. But assuming the code is
    perfect, is there issue with the compilation flags ??

    Or incompatibilty of gcc version ? Am I missing something while
    compiling ??

    Please send your suggestions/comments for the same.

    Thanks and Regards,
    Rohit Dhamija


  2. Re: The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice

    On 2007-01-19, rohit wrote:
    > Hi All,
    >
    > I am in process of porting Linux project to 64-bit systems. The project
    > needs to support 64-bit as well as 32-bit platforms.
    >
    > I am facing some issues while porting my daemon, that acts as USB bulk
    > device driver, (it uses libusb) and wanted your expert
    >
    > advice for the same.
    >
    > I have followed proper guidelines while making the code portable.


    > For 32-bit binary, used following to compile:
    > CC=gcc -m32 -O
    >
    > For 64-bit binary, used following to compile:
    > CC=gcc -O


    > If I build the daemon on 32-bit machine with same code, it runs fine on
    > 32-bit machine.


    compile -E and apply diff to the output,

    Bye.
    Jasen

  3. Re: The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice

    Hello,

    > I am in process of porting Linux project to 64-bit systems. The project
    > needs to support 64-bit as well as 32-bit platforms.
    >
    > I am facing some issues while porting my daemon, that acts as USB bulk
    > device driver, (it uses libusb) and wanted your expert
    >
    > advice for the same.
    >
    > I have followed proper guidelines while making the code portable.
    >
    > Refered:http://www-128.ibm.com/developerwork..._64_linux.html
    >
    > I have adopted the following strategy:
    >
    > a) Machine details: Developing & compiling the daemon on 64-bit
    > platform machine. Below are the machine details:
    >
    > Machine type: x86_64 GNU/Linux
    > Red Hat Enterprise Linux Version 4 WorkStation
    > Processor: Intel(R) Pentium(R) 4 CPU 3.00 GHz
    > The gcc version: 4.0.2
    >
    > b) Developing 32-bit and 64-binary seperately on the above mentioned
    > development machine
    >
    > For 32-bit binary, used following to compile:
    > CC=gcc -m32 -O
    >
    > For 64-bit binary, used following to compile:
    > CC=gcc -O
    >
    >
    >
    > c) Deploying:
    > I am deploying the 32 bit binary on 32-bit machine and 64-bit binary
    > on 64-bit machine.
    >
    >
    > Outcome:
    >
    > The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit
    > MACHINE!!!
    >
    > The details of 32-bit machine are:
    > i386 GNU/Linux
    > Fedora Core 6
    > gcc (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)
    >
    > If I build the daemon on 32-bit machine with same code, it runs fine on
    > 32-bit machine.
    >
    >
    > On debugging the daemon on 32-bit, it seemed like the stack has been
    > corrupted. It throws a "segmentation fault". One of The
    >
    > function is throwing a segmentation fault on return.
    >
    > I know that there can be n number of reasons. But assuming the code is
    > perfect, is there issue with the compilation flags ??
    >
    > Or incompatibilty of gcc version ? Am I missing something while
    > compiling ??
    >
    > Please send your suggestions/comments for the same.


    "Assuming the code is perfect" is usually where the assumption doesn't
    hold...

    Anyway, you are building a binary compiled in a 32 bits mode on a 64
    bits processor that you execute on a 32 bits processor. To me, it's not
    evident that it should work... I would at least compile with the
    'march=i386' (or i686, or ... depending on your processor) flag for
    the binary that should be executed on the 32 bits machine.

    HTH,
    Loic.


  4. Re: The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit MACHINE!!! Please advice

    I think it is some bit alignment issue...
    loic-dev@gmx.net wrote:
    > Hello,
    >
    > > I am in process of porting Linux project to 64-bit systems. The project
    > > needs to support 64-bit as well as 32-bit platforms.
    > >
    > > I am facing some issues while porting my daemon, that acts as USB bulk
    > > device driver, (it uses libusb) and wanted your expert
    > >
    > > advice for the same.
    > >
    > > I have followed proper guidelines while making the code portable.
    > >
    > > Refered:http://www-128.ibm.com/developerwork..._64_linux.html
    > >
    > > I have adopted the following strategy:
    > >
    > > a) Machine details: Developing & compiling the daemon on 64-bit
    > > platform machine. Below are the machine details:
    > >
    > > Machine type: x86_64 GNU/Linux
    > > Red Hat Enterprise Linux Version 4 WorkStation
    > > Processor: Intel(R) Pentium(R) 4 CPU 3.00 GHz
    > > The gcc version: 4.0.2
    > >
    > > b) Developing 32-bit and 64-binary seperately on the above mentioned
    > > development machine
    > >
    > > For 32-bit binary, used following to compile:
    > > CC=gcc -m32 -O
    > >
    > > For 64-bit binary, used following to compile:
    > > CC=gcc -O
    > >
    > >
    > >
    > > c) Deploying:
    > > I am deploying the 32 bit binary on 32-bit machine and 64-bit binary
    > > on 64-bit machine.
    > >
    > >
    > > Outcome:
    > >
    > > The deamon runs fine on 64-bit machine, BUT CRASHES ON 32-bit
    > > MACHINE!!!
    > >
    > > The details of 32-bit machine are:
    > > i386 GNU/Linux
    > > Fedora Core 6
    > > gcc (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)
    > >
    > > If I build the daemon on 32-bit machine with same code, it runs fine on
    > > 32-bit machine.
    > >
    > >
    > > On debugging the daemon on 32-bit, it seemed like the stack has been
    > > corrupted. It throws a "segmentation fault". One of The
    > >
    > > function is throwing a segmentation fault on return.
    > >
    > > I know that there can be n number of reasons. But assuming the code is
    > > perfect, is there issue with the compilation flags ??
    > >
    > > Or incompatibilty of gcc version ? Am I missing something while
    > > compiling ??
    > >
    > > Please send your suggestions/comments for the same.

    >
    > "Assuming the code is perfect" is usually where the assumption doesn't
    > hold...
    >
    > Anyway, you are building a binary compiled in a 32 bits mode on a 64
    > bits processor that you execute on a 32 bits processor. To me, it's not
    > evident that it should work... I would at least compile with the
    > 'march=i386' (or i686, or ... depending on your processor) flag for
    > the binary that should be executed on the 32 bits machine.
    >
    > HTH,
    > Loic.



+ Reply to Thread