• Why does the following C++ program , DataServer.cpp, throws a segme

    From Francis Glassborow@21:1/5 to allswellthatendswell on Mon Jan 4 10:08:40 2016
    On 04/01/2016 12:55, allswellthatendswell wrote:
    { edited by mod to shorten text lines to ~70 characters. the source
    and command lines have not been edited. -mod }

    The following C++ program , DataServer.cpp, throws a segmentation
    fault at the exit of the extern "C" function, void func(void) shown
    in the bottom of this question. I compiled this program on Ubuntu
    Linux 14.04 LTS with the g++ entry point feature.


    Well I note two things in the extern "c" function

    1) Its return type is NOT void
    2) There is no return type


    If you expect others to wade through your code looking for causes you
    need first to provide code as specified.

    Finally as you appear to be using a g++ extension you might get a more
    informed answer in a g++ forum

    Francis


    --
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]
    [ comp.lang.c++.moderated. First time posters: Do this! ]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From marlow.agents@googlemail.com@21:1/5 to allswellthatendswell on Tue Jan 12 07:22:22 2016
    On Monday, January 4, 2016 at 1:00:18 PM UTC, allswellthatendswell wrote:
    The following C++ program , DataServer.cpp, throws a segmentation
    fault at the exit of the extern "C" function, void func(void) shown
    in the bottom of this question. I compiled this program on Ubuntu
    Linux 14.04 LTS with the g++ entry point feature.

    Use valgrind.


    --
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]
    [ comp.lang.c++.moderated. First time posters: Do this! ]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jerry Stuckle@21:1/5 to allswellthatendswell on Mon Jan 4 11:22:41 2016
    On 1/4/2016 7:55 AM, allswellthatendswell wrote:
    { edited by mod to shorten text lines to ~70 characters. the source
    and command lines have not been edited. -mod }

    The following C++ program , DataServer.cpp, throws a segmentation
    fault at the exit of the extern "C" function, void func(void) shown
    in the bottom of this question. I compiled this program on Ubuntu
    Linux 14.04 LTS with the g++ entry point feature.

    g++ -shared -g -fPIC -DLINUX -Wl,-soname,libdataserver.so -efunc -I /home/venkat/Downloads/waitForMultipleObjects -I /home/venkat/developmentMono/SmartCamXi_Hybrid/Include DataServer.cpp DataServerLib.cpp DataTransferClient.cpp CWinEventHandle.cpp WinEvent.cpp -lpthread -lrt

    When I run gdb ./a.out core, I get the following output: :~/Downloads/DataServerLib$ gdb ./a.out

    Reading symbols from ./a.out...done.
    [New LWP 8538]
    Core was generated by `./a.out'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0 0x0000000000000001 in ?? ()
    (gdb) bt
    #0 0x0000000000000001 in ?? ()
    #1 0x00007ffdab79f29e in ?? ()
    #2 0x0000000000000000 in ?? ()
    (gdb) where
    #0 0x0000000000000001 in ?? ()
    #1 0x00007ffdab79f29e in ?? ()
    #2 0x0000000000000000 in ?? ()
    (gdb) list

    <snip code>

    Normally a segfault on a function return means the stack has been
    overwritten and the return address is bad. It could be anything from a
    buffer overrun to insufficient stack size (shouldn't be a problem
    nowadays, but I don't know what you've allocated from the stack before
    arriving here). Looking through your code I don't see anything that
    jumps out at me, but you've left out a lot of information.

    Which compiler are you using? What compiler options? Do you have any
    errors or warnings?

    You didn't provide a compilable example (or even the header files), so
    it's impossible for others to test. All I can recommend is to comment
    out all of the code in func() and try uncommenting a couple of lines at
    a time until you get the error.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    jstucklex@attglobal.net
    ==================


    [ See http://www.gotw.ca/resources/clcm.htm for info about ]
    [ comp.lang.c++.moderated. First time posters: Do this! ]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)