Why does a library compiled on two slightly different machines behave a little differently?

Here's the setting:

My colleague has a Fedora x64_86 machine with gcc 4.3.3 cross compiler (from buildroot). I have a Ubuntu 9.04 x64_86 machine with the same cross-compiler.

My colleague built a library + test application that runs on a test machine, I compiled the same library and testapp, and it worked on the same test machine.

As far as I can tell, gcc is built against buildroot-compiled ucLibc, so the same code, the same compiler. What kind of machine will affect crossbreeding?

Any insight was appreciated.

Update. To clarify, the compilers are identical. The source code for the library and testapp are identical. The only difference is that testapp + lib were compiled on different machines.

+3
source share
6 answers

If your code works (I assume you get sigsegv), there seems to be an error. Most likely, this is a kind of undefined behavior, for example, using a dangling pointer or writing along the border of the buffer.

The unfortunate point of undefined behavior is that it can work on some machines. I think you are experiencing such an event here. Try to find the error and you will find out what will happen :-)

+6
source

? , , .. printf()?

, , :

  • testapp ?

  • ?

  • , ld.so.conf?

  • - testapp?

  • testapps -? , ?

  • , , ?

+3

,, - .

objdump , -d, , .

, , binutils - . , . ld, as objdump.

- binutils . , GCC, , binutils , , x86_64 .

binutils ARM, - ARM. , .

, x86 Gentoo stage1, : Gentoo .

+3

- ( )?

? , gcc, , gentoo 20 , Fedora ubuntu . 100% , :-( .

gcc "vanilla", , .

+1

-, . , , . , , .

-.

, :

if(p == NULL) {
    p = f();
}

p , , , NULL, ... , p NULL , prof . , , p tp NULL, .

, . - undefined, : " - "

+1
source

Like a punch in the dark, I would look for uninitialized variables. Ensure that all local and global variables are assigned a value. Double check that constructors have initializers for ALL data members.

+1
source

Source: https://habr.com/ru/post/1715004/


All Articles