bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error during program termination when cross-compiled to 32 bits (linker


From: Leo Meyer
Subject: Error during program termination when cross-compiled to 32 bits (linker error?)
Date: Thu, 22 Dec 2016 12:08:01 +0100

Hello,

I have an application that runs fine when natively compiled on both 64 and
32 bit Linux systems. When cross-compiling the program on 64 bit Linux to
32 bits (-m32 flag) I get this error when running it on both 32 and 64 bit
systems:

openhatd exited with code 31
*** Error in `./openhatd': double free or corruption (!prev): 0x0888fb58 ***
Received ABRT signal, generating stack trace
./openhatd[0x828d6b7]
[0xf7704d50]
[0xf7704d80]
/lib/i386-linux-gnu/libc.so.6(gsignal+0x47)[0xf7162687]
/lib/i386-linux-gnu/libc.so.6(abort+0x143)[0xf7165ab3]
/lib/i386-linux-gnu/libc.so.6(+0x68fd3)[0xf719cfd3]
/lib/i386-linux-gnu/libc.so.6(+0x734ba)[0xf71a74ba]
/lib/i386-linux-gnu/libc.so.6(+0x7412d)[0xf71a812d]
./openhatd(_ZdlPv+0x18)[0x829adc8]
./openhatd(_ZNSs4_Rep10_M_destroyERKSaIcE+0x18)[0x82ed458]

The code (simplified):

int main(int argc, char* argv[], char* envp[])
{
int exitcode = doSomething();

log("openhatd exited with code " + to_string(exitcode));

return exitcode;
}

It seems that the error occurs during program termination right after
outputting the log message.

I have tested this with gcc-4.9.4 and gcc-6.2 with the same effect. BTW,
compiling on Windows with a 32 bit target works fine.

The application consists of a host program that loads plugins dynamically.
Both host and plugin shared objects utilize the POCO libraries (
www.pocoproject.org).
The host program links to the POCO libraries dynamically. The error occurs
only if a loaded plugin has been statically linked to the POCO libraries.
If the plugin links to the POCO libraries dynamically as well the error
does not happen (this is why I believe this might be linker related).

Analysis with gdb:

Program received signal SIGABRT, Aborted.
0xf7fd9d80 in __kernel_vsyscall ()
(gdb) bt
#0  0xf7fd9d80 in __kernel_vsyscall ()
#1  0xf73ad687 in raise () from /lib/i386-linux-gnu/libc.so.6
#2  0xf73b0ab3 in abort () from /lib/i386-linux-gnu/libc.so.6
#3  0xf73e7fd3 in ?? () from /lib/i386-linux-gnu/libc.so.6
#4  0xf73f24ba in ?? () from /lib/i386-linux-gnu/libc.so.6
#5  0xf73f312d in ?? () from /lib/i386-linux-gnu/libc.so.6
#6  0x086cab38 in operator delete(void*) ()
#7  0x0871b363 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string() ()
#8  0xf7bc133b in __tcf_1 () at src/DateTimeFormat.cpp:46
#9  0xf73b25c3 in __cxa_finalize () from /lib/i386-linux-gnu/libc.so.6
#10 0xf7baf4f3 in __do_global_dtors_aux ()
   from
/home/leo/OpenHAT/openhatd/src/openhatd-linux-i386-0.1.0-current/bin/libPocoFoundationd.so.50
#11 0xf7feb33c in ?? () from /lib/ld-linux.so.2
#12 0xf73b2231 in ?? () from /lib/i386-linux-gnu/libc.so.6
#13 0xf73b228d in exit () from /lib/i386-linux-gnu/libc.so.6
#14 0xf7398afb in __libc_start_main () from /lib/i386-linux-gnu/libc.so.6
#15 0x080897d8 in _start ()

Frame #8 refers to a POCO source file (no code from my application is
involved in this path). The code at src/DateTimeFormat.cpp:46 is
(simplified):
const std::string DateTimeFormat::MONTH_NAMES[] =
{
"January", ..., "December"
};

I have spent two days trying to isolate the special circumstances under
which this error occurs but could not. Removing seemingly unrelated code
sometimes made the error vanish. Simple test cases that essentially emulate
the loading and releasing of plugins did not exhibit the problem at all, so
I reckon this is kind of a weird and elusive bug. Perhaps I'm making a
mistake with linker flags or whatever. Finally I gave up, as I found a
workaround (have plugins link to POCO dynamically).

Sorry if this description is unclear or something is missing. If somebody
likes to have a look at this issue I'll be happy to provide the details.

Kind regards and happy holidays
Leo


reply via email to

[Prev in Thread] Current Thread [Next in Thread]