OpenWrt Forum Archive

Topic: Cross-Compile Apache Thrift for OpenWRT

The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

as you seen here (https://issues.apache.org/jira/browse/THRIFT-177), I
am trying to cross-compile Thrift for the OpenWRT platform.

After a two-night-fight, my result are the following:

- I've created a OpenWRT package for thrift (see the attachment if you
are interested).
- I've successfully compiled the cpp-library (which results in
libthrift, libthriftz and libthriftnb)
- For now, I will not cross-compile the thrift-compiler since I will
compile the thrift definition files on my PC.

Coming to this point, I was very happy and I thought that the story
ends, but now I am faced with a problem I cannot solve myself:

For testing my cross-compilation result, I cross-compiled the cpp-part
of the thrift tutorial. I installed the cross-compiled libraries on the
target device and start the CppServer and the only reaction was
"Segmentation Fault"  :-(


I tried to backtrack the problem and I came to the finding, that a
simple hello world program, which is linked to my cross-compiled
thrift-library, causes the "Segmentation Fault". Without linking the
thrift-library, everything is O.K.


=======================
------------
Hello.cpp
------------

#include <iostream>

using namespace std;

int main(int argc, char **argv) {
  printf("Hello World!\n");
  return 0;
}

1) First try

$ i386-linux-uclibc-g++ -L${LIB_DIR} -levent -lthrift -o Hello Hello.cpp

On the target device:

root@OpenWrt:~# ./Hello
Segmentation fault

2) Second try

$ i386-linux-uclibc-g++ -L${LIB_DIR} -levent -o Hello Hello.cpp

On the target device:

root@OpenWrt:~# ./Hello
Hello World!

======================

I will try to debug it with gdb, but I'm not an expert in this.


So, please, can someone help me?



Kind regards,

Siamak Haschemi


Here is the Makefile:

#
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=thrift
PKG_VERSION:=snapshot
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-HEAD.tgz
#Automatic downloading of the current Thrift HEAD does not work with the URL below
#PKG_SOURCE_URL:=http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_CAT:=zcat

include $(INCLUDE_DIR)/package.mk

define Package/libthrift/Default
  SUBMENU:=Apache Thrift - Cross-language services
  SECTION:=lib
  CATEGORY:=Libraries
  TITLE:=Thrift 
  URL:=http://incubator.apache.org/thrift
endef

define Package/libthrift/Default/description
 Thrift is a software framework for scalable cross-language services 
 development. It combines a software stack with a code generation 
 engine to build services that work efficiently and seamlessly between 
 C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, 
 Smalltalk, and OCaml.
endef

define Package/libthrift
$(call Package/libthrift/Default)
  TITLE+= (core)
# DEPENDS:= boost
  PROVIDES:=libthrift
endef

define Package/libthrift/description
$(call Package/libthrift/Default/description)
 .
 libthrift: The core Thrift library contains all the core Thrift code. 
 It requires boost shared pointers, pthreads, and librt.
endef

define Package/libthriftnb
$(call Package/libthrift/Default) 
  TITLE+= (non-blocking server) 
  DEPENDS+= libthrift +libevent
endef

define Package/libthriftnb/description
$(call Package/libthrift/Default/description)
 .
 libthriftnb: This library contains the Thrift nonblocking server, 
 which uses libevent. To link this library you will also need to link libevent.
endef

THRIFT_CPP_LIB_DIR=$(PKG_BUILD_DIR)/lib/cpp
THRIFT_HEADERS_DIR=$(1)/usr/include/thrift

CONFIGURE_ARGS+= \

MAKE_FLAGS+= \

define Build/Prepare
    wget -O $(TOPDIR)/dl/$(PKG_SOURCE) "http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz"
    $(call Build/Prepare/Default)
endef

define Build/Configure
    cd $(PKG_BUILD_DIR) && ./bootstrap.sh
    $(call Build/Configure/Default)
endef


MAKE_VARS = \
    CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
    CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
    LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"

MAKE_FLAGS = \
    $(TARGET_CONFIGURE_OPTS) \
    CROSS="$(TARGET_CROSS)" \
    ARCH="$(ARCH)"

MAKE_PATH = .

define Build/Compile/Default
    $(MAKE_VARS) \
    $(MAKE) -C $(THRIFT_CPP_LIB_DIR) \
        DESTDIR="$(PKG_INSTALL_DIR)" \
        $(MAKE_FLAGS) \
        $(1) \
        all install;
endef

define Build/InstallDev
    mkdir -p $(1)/usr/include
    mkdir -p $(THRIFT_HEADERS_DIR)
    mkdir -p $(THRIFT_HEADERS_DIR)/concurrency
    mkdir -p $(THRIFT_HEADERS_DIR)/processor
    mkdir -p $(THRIFT_HEADERS_DIR)/protocol
    mkdir -p $(THRIFT_HEADERS_DIR)/server
    mkdir -p $(THRIFT_HEADERS_DIR)/transport
    $(INSTALL_DATA) $(THRIFT_CPP_LIB_DIR)/src/concurrency/*.h $(THRIFT_HEADERS_DIR)/concurrency
    $(INSTALL_DATA) $(THRIFT_CPP_LIB_DIR)/src/processor/*.h $(THRIFT_HEADERS_DIR)/processor
    $(INSTALL_DATA) $(THRIFT_CPP_LIB_DIR)/src/protocol/*.h $(THRIFT_HEADERS_DIR)/protocol
    $(INSTALL_DATA) $(THRIFT_CPP_LIB_DIR)/src/server/*.h $(THRIFT_HEADERS_DIR)/server
    $(INSTALL_DATA) $(THRIFT_CPP_LIB_DIR)/src/transport/*.h $(THRIFT_HEADERS_DIR)/transport
    $(INSTALL_DATA) $(THRIFT_CPP_LIB_DIR)/src/*.h $(THRIFT_HEADERS_DIR)
    $(INSTALL_DATA) $(PKG_BUILD_DIR)/config.h $(THRIFT_HEADERS_DIR)/config.h

    mkdir -p $(1)/usr/lib
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libthrift* $(1)/usr/lib
    $(call Build/InstallDev/Default)
endef

define Build/UninstallDev
    rm -rf $(THRIFT_HEADERS_DIR)
    rm -rf $(1)/usr/lib/libthrift*
    $(call Build/UninstallDev/Default)
endef

define Package/libthrift/install    
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libthrift.so* $(1)/usr/lib/
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libthriftz.so* $(1)/usr/lib/
endef

define Package/libthriftnb/install
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/libthriftnb.so* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,libthrift))
$(eval $(call BuildPackage,libthriftnb))

And here is a needed patch:

001-configure.patch

diff -NaurB thrift.orig/aclocal/ax_lib_event.m4 thrift.mod/aclocal/ax_lib_event.m4
--- thrift.orig/aclocal/ax_lib_event.m4    2008-10-21 02:09:23.000000000 +0200
+++ thrift.mod/aclocal/ax_lib_event.m4    2008-10-21 12:03:59.000000000 +0200
@@ -71,7 +71,7 @@
           AC_LANG_PUSH([C])
           dnl This can be changed to AC_LINK_IFELSE if you are cross-compiling,
           dnl but then the version cannot be checked.
-          AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+          AC_LINK_IFELSE([AC_LANG_PROGRAM([[
           #include <sys/types.h>
           #include <event.h>
           ]], [[
diff -NaurB thrift.orig/aclocal/ax_lib_zlib.m4 thrift.mod/aclocal/ax_lib_zlib.m4
--- thrift.orig/aclocal/ax_lib_zlib.m4    2008-10-21 02:09:23.000000000 +0200
+++ thrift.mod/aclocal/ax_lib_zlib.m4    2008-10-21 12:04:21.000000000 +0200
@@ -69,7 +69,7 @@
           #   (defined in the library).
           AC_LANG_PUSH([C])
           dnl This can be changed to AC_LINK_IFELSE if you are cross-compiling.
-          AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+          AC_LINK_IFELSE([AC_LANG_PROGRAM([[
           #include <zlib.h>
           #if ZLIB_VERNUM >= 0x$WANT_ZLIB_VERSION
           #else

Hello again,

I don't know if it helps, but here is some more information:



root@OpenWrt:~# ldd ./hello

        libthrift.so.0 => /lib/libthrift.so.0 (0xb7f23000)
        libstdc++.so.6 => /lib/libstdc++.so.6 (0xb7e68000)
        libm.so.0 => /lib/libm.so.0 (0xb7e5b000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7e52000)
        libc.so.0 => /lib/libc.so.0 (0xb7e08000)
        librt.so.0 => /lib/librt.so.0 (0xb7e05000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb7df3000)
        ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0xb7fb9000)

root@OpenWrt:~# strace ./hello

execve("/bin/hello", ["/bin/hello"], [/* 8 vars */]) = 0
mmap2(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f52000
stat("/etc/ld.so.cache", 0xbff56254)    = -1 ENOENT (No such file or directory)
open("/lib/libthrift.so.0", O_RDONLY)   = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=604571, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f51000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20q\2\0004\0\0\0"..., 4096) = 4096
mmap2(NULL, 606208, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ebd000
mmap2(0xb7ebd000, 591833, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7ebd000
mmap2(0xb7f4e000, 10651, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x91) = 0xb7f4e000
close(3)                                = 0
munmap(0xb7f51000, 4096)                = 0
open("/lib/libstdc++.so.6", O_RDONLY)   = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=741369, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f51000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0,\0\4\0004\0\0\0"..., 4096) = 4096
mmap2(NULL, 765952, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e02000
mmap2(0xb7e02000, 719316, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7e02000
mmap2(0xb7eb2000, 20473, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xb0) = 0xb7eb2000
mmap2(0xb7eb7000, 23828, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7eb7000
close(3)                                = 0
munmap(0xb7f51000, 4096)                = 0
open("/lib/libm.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=45080, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f51000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0t\21\0\0004\0\0\0"..., 4096) = 4096
mmap2(NULL, 53248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7df5000
mmap2(0xb7df5000, 41028, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7df5000
mmap2(0xb7e00000, 4120, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xa) = 0xb7e00000
close(3)                                = 0
munmap(0xb7f51000, 4096)                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=31974, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f51000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0H\25\0\0004\0\0\0"..., 4096) = 4096
mmap2(NULL, 36864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7dec000
mmap2(0xb7dec000, 31592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7dec000
mmap2(0xb7df4000, 3302, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x7) = 0xb7df4000
close(3)                                = 0
munmap(0xb7f51000, 4096)                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=275645, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f51000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0@\251\0\0004\0\0\0"..., 4096) = 4096
mmap2(NULL, 303104, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7da2000
mmap2(0xb7da2000, 271528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7da2000
mmap2(0xb7de5000, 5309, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x42) = 0xb7de5000
mmap2(0xb7de7000, 16988, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7de7000
close(3)                                = 0
munmap(0xb7f51000, 4096)                = 0
open("/lib/librt.so.0", O_RDONLY)       = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=4110, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f51000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\344\4\0\0004\0\0\0"..., 4096) = 4096
mmap2(NULL, 12288, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d9f000
mmap2(0xb7d9f000, 2336, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7d9f000
mmap2(0xb7da0000, 4110, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7da0000
close(3)                                = 0
munmap(0xb7f51000, 4096)                = 0
open("/lib/libpthread.so.0", O_RDONLY)  = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=58930, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f51000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0004=\0\0004\0\0\0"..., 4096) = 4096
mmap2(NULL, 73728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d8d000
mmap2(0xb7d8d000, 37304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0xb7d8d000
mmap2(0xb7d97000, 22066, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x9) = 0xb7d97000
mmap2(0xb7d9d000, 6232, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7d9d000
close(3)                                = 0
munmap(0xb7f51000, 4096)                = 0
open("/lib/libstdc++.so.6", O_RDONLY)   = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=741369, ...}) = 0
close(3)                                = 0
open("/lib/libm.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=45080, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=275645, ...}) = 0
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=31974, ...}) = 0
close(3)                                = 0
open("/lib/libm.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=45080, ...}) = 0
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=31974, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=275645, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=275645, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=275645, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=275645, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=275645, ...}) = 0
close(3)                                = 0
stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=16390, ...}) = 0
mprotect(0xb7eb2000, 16384, PROT_READ)  = 0
mprotect(0xb7e00000, 4096, PROT_READ)   = 0
mprotect(0xb7de5000, 4096, PROT_READ)   = 0
mprotect(0xb7da0000, 4096, PROT_READ)   = 0
mprotect(0xb7d97000, 4096, PROT_READ)   = 0
mprotect(0xb7f57000, 4096, PROT_READ)   = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
getpid()                                = 2933
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
setrlimit(RLIMIT_STACK, {rlim_cur=2040*1024, rlim_max=RLIM_INFINITY}) = 0
rt_sigaction(SIGRTMIN, {0xb7d95f96, [], SA_RESTORER, 0xb7dac998}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb7d95efe, [RTMIN], SA_RESTORER, 0xb7dac998}, NULL, 8) = 0
rt_sigaction(SIGRT_2, {0xb7d9562a, [], SA_RESTORER, 0xb7dac998}, NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [RTMIN], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1], NULL, 8) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

Kind regards,

Siamak Haschemi

Hello again,

the Hello world program without the thrift library linked shows this strace (only the last relevant lines included):

...
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
brk(0)                                  = 0x88a7000
brk(0x88a8000)                          = 0x88a8000
write(1, "Hello World\n", 12Hello World
)           = 12
_exit(0)

For me, it looks like an problem with "getrlimit" or "setrlimit" function.

Kind regards,

Siamak Haschemi

(Last edited by sesam on 21 Oct 2008, 18:43)

Hello,

I got new results with gdb. IT seems that the problem is related to _pthread_cleanup_push_defer

siamak@siamak-desktop:~/seismo-openwrt/trunk/build_dir/i386/root-x86$ gdb
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
(gdb) set solib-absolute-prefix /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86
(gdb) file bin/hello
Reading symbols from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/bin/hello...done.
(gdb) target remote DEVICE_IP:2345
Remote debugging using DEVICE_IP:2345
0xb7f6e910 in _start () from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/ld-uClibc.so.0
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xb7dafb0a in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
(gdb) bt
#0  0xb7dafb0a in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#1  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#2  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#3  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#4  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#5  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#6  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#7  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#8  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#9  0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#10 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#11 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#12 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#13 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#14 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#15 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#16 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#17 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#18 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#19 0xb7dafb2b in _pthread_cleanup_push_defer ()
   from /home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
---Type <return> to continue, or q <return> to quit---

and the backtrace until setrlimit is:


Breakpoint 1, 0xb7db5aa5 in setrlimit ()
   from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
(gdb) bt
#0  0xb7db5aa5 in setrlimit () from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libc.so.0
#1  0xb7d9bb22 in ?? () from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libpthread.so.0
#2  0xb7d9c137 in ?? () from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libpthread.so.0
#3  0xb7d966c1 in ?? () from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/libpthread.so.0
#4  0xb7fa73f0 in _dl_get_ready_to_run ()
   from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/ld-uClibc.so.0
#5  0xb7fa76ea in ?? () from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/ld-uClibc.so.0
#6  0xb7fa4915 in _start () from
/home/siamak/seismo-openwrt/trunk/build_dir/i386/root-x86/lib/ld-uClibc.so.0

The discussion might have continued from here.