This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

64 bit seg fault


Hi,

I'm not familiar with the code, but in working with the calculator
example from www.inspirel.com/yami4/, I'm getting a segmentation
fault on a 64 bit gentoo (and SuSE 11) system with the python example
(python version 2.6.5). Others don't run into this problem on a 32 bit
systems. I'm using libffi 3.0.9. Part of the backtrace is:

Core was generated by `/usr/bin/python2.6 client.py tcp://localhost:12345 2 5'.
Program terminated with signal 11, Segmentation fault.
#0  0x00007fd5b71f04cf in yami4_is_success ()
   from /home/jeff/build/yami4-gpl-1.2.1/lib/libyami4py.so
(gdb) bt full
#0  0x00007fd5b71f04cf in yami4_is_success ()
   from /home/jeff/build/yami4-gpl-1.2.1/lib/libyami4py.so
No symbol table info available.
#1  0x00007fd5b7e6ce60 in ffi_call_unix64 () at src/x86/unix64.S:75
No locals.
#2  0x00007fd5b7e6c91d in ffi_call (cif=0x7fff2abebe50,
    fn=0x7fd5b71f04bb <yami4_is_success>, rvalue=0x7fff2abebf10,
    avalue=0x7fff2abebef0) at src/x86/ffi64.c:484
        classes = {X86_64_INTEGERSI_CLASS, X86_64_NO_CLASS, 717143536, 32767}
        stack = 0x7fff2abebc60 "@\n"
        argp = 0x7fff2abebd10 "\n"
        arg_types = 0x7fff2abebed0
        gprcount = 1
        ssecount = 0
        ngpr = 1
        nsse = 0
        i = 1
        avn = 1
        ret_in_memory = false
        reg_args = 0x7fff2abebc60
#3  0x00007fd5b8084747 in _call_function_pointer (flags=4353,
    pProc=0x7fd5b71f04bb <yami4_is_success>, avalues=0x7fff2abebef0,
    atypes=0x7fff2abebed0, restype=0x6f6c40, resmem=0x7fff2abebf10, argcount=1)
    at /usr/src/debug/dev-lang/python-2.6.5-r3/Python-2.6.5/Modules/_ctypes/callproc.c:816
        _save = 0x6020a0
        error_object = 0x0
        space = 0x0
        cif = {abi = FFI_UNIX64, nargs = 1, arg_types = 0x7fff2abebed0,
          rtype = 0x6f6c40, bytes = 0, flags = 10}
        cc = 2
#4  0x00007fd5b808514e in _CallProc (pProc=0x7fd5b71f04bb <yami4_is_success>,
    argtuple=0x7fd5b97cfb10, flags=4353, argtypes=0x0,
restype=0x6f6770, checker=0x0)
    at /usr/src/debug/dev-lang/python-2.6.5-r3/Python-2.6.5/Modules/_ctypes/callproc.c:1163
        i = 1
        n = 1
        argcount = 1
        argtype_count = 0
        resbuf = 0x7fff2abebf10
        args = 0x7fff2abebf30
        pa = 0x7fff2abebf50
        atypes = 0x7fff2abebed0
        rtype = 0x6f6c40
        avalues = 0x7fff2abebef0
        retval = 0x0
...

The code fragment for the first stack frame is:
extern "C" int yami4_is_success(void * pr)
{
    result * res = static_cast<result *>(pr);
    return res->success_ ? 1 : 0;
}

where result is:

struct result
{
    result(void * p) : success_(true), p_(p) {}
    result(int i) : success_(true), i_(i) {}
    result(void * p, int i) : success_(true), p_(p), i_(i) {}
    result(int i, int j, int k) : success_(true), i_(i), j_(j), k_(k) {}
    result(const std::string & s) : success_(true), s_(s) {}
    result(const std::exception &e) : success_(false), error_(e.what()) {}

    bool success_;
    void * p_;
    int i_;
    int j_;
    int k_;
    std::string s_;
    std::string error_;
};


To reproduce:
wget http://www.inspirel.com/yami4/files/yami4-gpl-1.2.1.tar.gz
tar xzvf yami4-gpl-1.2.1.tar.gz
cd yami4-gpl-1.2.1/src/python2
make
cd ../../lib
export LD_LIBRARY_PATH=`pwd`
export PYTHONPATH=`pwd`
cd ../src/python2/examples/calculator
python server.py tcp://localhost:12345

And in another windown, in the same directory, with
LD_LIBRARY_PATH and PYTHONPATH exported:
python client.py tcp://localhost:12345 2 5

It may take running the client up to about 10 times to seg fault.

--
Jeff Garlough


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]