tags:

views:

50

answers:

0

We have a daemon that is compiled using -m32 compiler option and in its execution time load /bin/sh of 64 bit application by forking to load a 64 ssh-agent. So the process goes in some loop from 32 bit mode to 64 bit mode. Recently we have seen that application throws error as mentioned in title. Below is the extract of strace that we captured:

31285 execve("/bin/sh", [0xfffffffff6bdcda2, 0xfffffffff6bdcd9a, "/usr/local/bin/ssh-agent"], [/* 50 vars */]) = 0
31285 brk(0)                            = 0x982e000
31285 open("/lib/libtermcap.so.2", O_RDONLY) = 7
31285 read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260\v\0\0004\0\0\0$*\0\0\0\0\0\0004\0 \0\5\0(\0\32\0\31\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\234'\0\0\234'\0\0\5\0\0\0\0\20\0\0\1\0\0\0\234'\0\0\2347\0\0\2347\0\0\220\1\0\0\f\2\0\0\6\0\0\0\0\20\0\0\2\0\0\0\270'\0\0\2707\0\0\2707\0\0\310\0\0\0\310\0\0\0\6\0\0\0\4\0\0\0P\345td\374$\0\0\374$\0\0\374$\0\0\214\0\0\0\214\0\0\0\4\0\0\0\4\0\0\0Q\345td\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\0\0\0\4\0\0\0\21\0\0\0-\0\0\0\4\0\0\0\f\0\0\0\"\4\214\30\240@\4\t\211\4\220\1\0N\200,-\0\0\0.\0\0\0000\0\0\0"..., 832) = 832
31285 close(7)                          = 0
31285 stat("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
31285 open("/etc/ld.so.cache", O_RDONLY) = 7
31285 fstat(7, {st_mode=S_IFREG|0644, st_size=60909, ...}) = 0
31285 mmap(NULL, 60909, PROT_READ, MAP_PRIVATE, 7, 0) = 0x2aafe17c5000
31285 close(7)                          = 0
31285 open("/lib64/libtermcap.so.2", O_RDONLY) = 7
31285 read(7, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\20\0\0\0\0\0\0@\0\0\0\0\0\0\0\210.\0
\0\0\0\0\0\0\0\0\0@\0008\0\5\0@\0\32\0\31\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t*\0\0\0\0\0\0t*\0\0\0\0\0\0\0\0 \0\0\0\0\0\1\0\0\0\6\0\0\0x*\0\0\0\0\0\0x* \0\0\0\0\0x* \0 \0\0\0\0\24\3\0\0\0\0\0\0\230\3\0\0\0\0\0\0\0\0 \0\0\0\0\0\2\0\0\0\6\0\0\0\260*\0\0\0\0\0\0\260* \0
\0\0\0\0\260* \0\0\0\0\0\220\1\0\0\0\0\0\0\220\1\0\0\0\0\0\0\10\0\0\0\0\0\0\0P\345td\4\0\0\0\274'\0
\0\0\0\0\0\274'\0\0\0\0\0\0"..., 832) = 832
31285 fstat(7, {st_mode=S_IFREG|0755, st_size=13576, ...}) = 0
31285 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aafe17d4000
31285 mmap(NULL, 2108944, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 7, 0) = 0x2aafe19c5000
31285 mprotect(0x2aafe19c8000, 2093056, PROT_NONE) = 0
31285 mmap(0x2aafe1bc7000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7, 0x2000) = 0x2aafe1bc7000
31285 close(7)           = 0
31285 open("/lib/libdl.so.2", O_RDONLY) = 7
31285 read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\n\0\0004\0\0\00044\0\0\0\0\0\0004\0
 \0\10\0(\0 \0\37\0\6\0\0\0004\0\0\0004\0\0\0004\0\0\0\0\1\0\0\0\1\0\0\5\0\0\0\4\0\0\0\3\0\0\0C\33\
0\0C\33\0\0C\33\0\0\23\0\0\0\23\0\0\0\4\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\f\35\0\0\f\35
\0\0\5\0\0\0\0\20\0\0\1\0\0\0\260\36\0\0\260.\0\0\260.\0\0\224\1\0\0\310\1\0\0\6\0\0\0\0\20\0\0\2\0
\0\0\320\36\0\0\320.\0\0\320.\0\0\370\0\0\0\370\0\0\0\6\0\0\0\4\0\0\0\4\0\0\0004\1\0\0004\1\0\0004\
1\0\0 \0\0\0 \0\0\0\4\0\0\0\4\0\0\0Q\345td\0\0\0\0\0\0\0\0"..., 832) = 832
31285 close(7)                          = 0
31285 open("/lib64/tls/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
31285 stat("/lib64/tls/x86_64", 0x7fff3bb360a0) = -1 ENOENT (No such file or directory)
31285 open("/lib64/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
31285 stat("/lib64/tls", 0x7fff3bb360a0) = -1 ENOENT (No such file or directory)
31285 open("/lib64/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
31285 stat("/lib64/x86_64", 0x7fff3bb360a0) = -1 ENOENT (No such file or directory)
31285 open("/lib64/libdl.so.2", O_RDONLY) = 7
31285 read(7, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\16\0\0\0\0\0\0@\0\0\0\0\0\0\0\210G
\0\0\0\0\0\0\0\0\0\0@\0008\0\t\0@\0!\0 \0\6\0\0\0\5\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\
0\0\370\1\0\0\0\0\0\0\370\1\0\0\0\0\0\0\10\0\0\0\0\0\0\0\3\0\0\0\4\0\0\0\300\32\0\0\0\0\0\0\300\32\
0\0\0\0\0\0\300\32\0\0\0\0\0\0\34\0\0\0\0\0\0\0\34\0\0\0\0\0\0\0\20\0\0\0\0\0\0\0\1\0\0\0\5\0\0\0\0
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\224\37\0\0\0\0\0\0\224\37\0\0\0\0\0\0\0\0 \0\0\0\0\0
\1\0\0\0\6\0\0\0`-\0\0\0\0\0\0`- \0\0\0\0\0"..., 832) = 832
31285 close(7)                          = 0
31285 stat("/lib64", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
31285 open("/usr/lib64/tls/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
31285 stat("/usr/lib64/tls/x86_64", 0x7fff3bb360a0) = -1 ENOENT (No such file or directory)
31285 open("/usr/lib64/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
31285 stat("/usr/lib64/tls", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
31285 open("/usr/lib64/x86_64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
31285 stat("/usr/lib64/x86_64", 0x7fff3bb360a0) = -1 ENOENT (No such file or directory)
31285 open("/usr/lib64/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
31285 stat("/usr/lib64", {st_mode=S_IFDIR|0755, st_size=36864, ...}) = 0
31285 writev(2, [{"sh", 2}, {": ", 2}, {"error while loading shared libraries", 36}, {": ", 2}, {"libdl.so.2", 10}, {": ", 2}, {"wrong ELF class: ELFCLASS32", 27}, {"", 0}, {"", 0}, {"\n", 1}], 10) = 82
31285 exit_group(127)                   = ?

My question is that is it error while loading "/lib/libdl.so.2" - when does this error gets printed - error while loading shared libraries : wrong ELF class: ELFCLASS32

We ran through a couple of same test cases on another box having the same config and binary but we see no error. Both "/lib/libdl.so.2" and "/lib64/libdl.so.2" got loaded successfully.

What is the error then - I believe that it is not race error when another application is also trying to load the same library? Why is the executable failing with the above mentioned error?