OpenWrt Forum Archive

Topic: Segfaults with corrupted stack - kamikaze and c++

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

I am stuck on what to try next in terms of trying to figure out why a program would cross-compile just fine, but SEGFAULTs when trying to run it on the router before main() is even entered.

To avoid flooding this post with too much information, here's the short story.  I am mostly interested in whether this problem sounds familiar to anyone and what next steps I could take to diagnose the problem.

  o The router is a Linksys WRTSL54GS running a 2.4 kamikaze:
      uname -a
      Linux sparky 2.4.34 #3 Sun Sep 30 20:33:21 CEST 2007 mips unknown

  o The code is a mix of C and C++ code, and the C parts themselves compile and run fine. Add the C++ parts and it compiles fine (using the OpenSDK on an ubuntu machine) but SEGFAULTS when run on the router. Native compiling on ubuntu, the code runs just fine.

  o I've tried this with two completely different C++ parts added to it and get the same behavior, though one gives a SEGFAULT and the other an 'Aborted'.  Core dumps of both look identically bad in the mipsel GDB:

    (gdb) target core /tmp/core
    Core was generated by `./facetrack2'.
    Program terminated with signal 6, Aborted.
    #0  0x00000020 in ?? ()
    (gdb) bt
    #0  0x00000020 in ?? ()
    #1  0x00000020 in ?? ()
    Previous frame identical to this frame (corrupt stack?)

  o I've tried the remote debugging with a gdbserver on the router, and get a similar issue with the stack when trying to connect with the missel debugger:

    (gdb) target remote 192.168.200.203:1234
    Remote debugging using 192.168.200.203:1234
    0x2aaa8ad0 in ?? ()
    (gdb) bt
    #0  0x2aaa8ad0 in ?? ()
    #1  0x2aaa8ad0 in ?? ()
    Previous frame identical to this frame (corrupt stack?)

  o Putting a printf statement as first line in main() never gets printed before SEGFAULT.

  o I've followed lots of the tutorials for setting up the package building and ipkgs needed, and have the libcpp installed, and have gotten past all the issues with cross-compiling and not being able to find the necessary libraries, so all looks good until I run it.

  o I've tried linking to both libstdc++ and uClibc++ with the same results both times.

Anyone have any similar experience or know some way to look at the core file to diagnose?

Thanks.

-Tony

(Last edited by TonyC on 17 Dec 2007, 00:01)

I have the same problem. Any hints on this?

The discussion might have continued from here.