Archived

This forum has been archived. Please start a new discussion on GitHub.

Bug during Ice::initialize (argc, argv)

I am using Ice-2.1.0
The main contains this:

Ice::CommunicatorPtr loIceCommunicator;
try
{
cout << "before ICE init" << endl;
loIceCommunicator = Ice::initialize (argc, argv);
cout << "after ICE init" << endl;
}
......

When the program is started from cmd line (under Linux) the following happens
./iceprogram -seriald dummy
Gives us as output
before ICE init
*** glibc detected *** malloc(): memory corruption (fast): 0x080c4430 ***
Aborted

When the program is started as follows :
./iceprogram -serial dummy
the ice init now works.

Any idea ?

Testing config:
Mandriva 2005 Linux, Ice-2.1.0, gcc 3.4.3


Best regrards
Wim.

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Can you try to run your program in the debugger and get a stack trace of the abort? Do you get the same problem when running the Ice demos?

    Thanks,

    Benoit.
  • Hi,

    I have a somewhat similar problem with the Python demo scripts. The C++ versions work fine. The "Server.py" demo script in the Ice/hello directory segfaults when I try to run it. It dies when executing the "Ice.loadSlice('Hello.ice')" statement. So, I commented out this statement and ran "slice2py Hello.ice" to generate the stubs. It segfaults again when I try running the modified script. This time, it appears that the "Ice.createProperties()" statement is causing the problem. So I commented it out as well as the lines that referenced the "properties" variable. I also changed the Ice initialization statement from "initializeWithProperties(sys.argv, properties)" to "initialize(sys.argv)." I tried running it again, and it gave me the finger:

    *** glibc detected *** free(): invalid pointer: 0x080ca0f0 ***
    Aborted (core dumped)

    This is the same error that occurs when I run the Python server example given on page 65 of the Ice manual:

    *** glibc detected *** free(): invalid pointer: 0x080ca128 ***
    Aborted (core dumped)

    Running the Python server example script again (without first removing the .pyc file) gave the following error:

    *** glibc detected *** double free or corruption (out): 0x080ca128 ***
    Aborted (core dumped)

    I'm using the Ice-2.1.2-bin-fc3.tar.gz binary distribution, and the demos come from Ice-2.1.2-demos.tar.gz. I'm running the latest version of Slackware (slackware-current). With the exception of db-4.2.52 (which I had to recompile with --enable-cxx), all the software that Ice depends on are official Slackware packages. The following list of dependencies shows the Ice requirements on the left, and the package versions that I have on the right.

    db4-4.2.52 | db4-4.2.52

    expat-1.95.7 | expat-1.95.8

    openssl-0.9.7a | openssl-0.9.7g

    bzip2-libs-1.0.2 | bzip2-1.0.3

    readline-4.3 | readline-4.3

    ncurses-5.4 | ncurses-5.4

    libgcc-3.4.2 | gcc-3.4.4

    libstdc++-3.4.2 | gcc-g++-3.4.4

    python-2.3.4 | python-2.4.1

    I compiled Ice from source, but got the same errors. I'm checking out Ice just for fun, so there's no need to break your back trying to resolve this problem. :)

    Thanks!
  • benoit
    benoit Rennes, France
    Hello,

    I wouldn't use the binary package built for Fedora Core 3 on your Slackware distribution which seems to have different versions for the required packages. Recompiling it from the sources is the right thing to do here :).

    It's strange that you got the same errors after recompiling it from source however. Did you also recompile the Ice for Python distribution? You should also make sure that the binaries from the FC3 distribution aren't in your PATH, LD_LIBRARY_PATH or PYTHON_PATH.

    If this still doesn't work after checking this, you could get the stack trace of the abort with the debugger and post it here, we'll take a look at it!

    Benoit.
  • Hi Benoit,

    For what it's worth, I discovered that the following line in IcePy-2.1.2/modules/IcePy/Slice.cpp causes a segfault:

    FILE* cppHandle = icecpp.preprocess(false);

    The function in which the above line appears is called by the "Ice.loadSlice('Hello.ice')" statement in the Python demo script (hello/Server.py). This demo script comes with the IcePy source package. I left my installation of Ice and IcePy from the binary packages intact. I unpacked the IcePy source package, compiled, and installed it in a temporary directory. I also set my PYTHONPATH and LD_LIBRARY_PATH variables to point to the temporary location of IcePy. Besides inserting "cout" statements in Slice.cpp, no other changes were made to either my system or the IcePy source.

    I tried to obtain a stack trace by running "gdb Server.py core" and issuing the "bt" command at the gdb prompt. I don't know if this is the right way to get a stack trace, but here's what gdb-6.3 gave me:

    #0 0x402d86c1 in ?? ()
    #1 0x4038d9c0 in ?? ()
    #2 0x080b8450 in ?? ()
    #3 0x40966c9c in ?? ()
    #4 0x080839f0 in ?? ()
    #5 0x4096bbc0 in ?? ()
    . . .
    #1660 0x6e69622f in ?? ()
    #1661 0x7479702f in ?? ()
    #1662 0x006e6f68 in ?? ()
    #1663 0x00000000 in ?? ()
    Error accessing memory address 0xc0000000: No such file or directory.

    I also tried using the Python debugger, pdb, by running the following command: "python -m pdb Server.py". But when the script segfaulted, I got thrown out of the debugger.

    I think I'll stick with the default C++ bindings for now...
  • benoit wrote:
    Did you also recompile the Ice for Python distribution?
    Yes. Actually, the first thing I did was to compile Ice and IcePy from source. Only after I could not get the IcePy bindings to work did I install the binary packages.
  • benoit
    benoit Rennes, France
    Hi,

    I think you should run gdb with the python executable instead:
        $ gdb python core
        (gdb) bt
    

    Or you can also execute python within the debugger:
        $ gdb python
        (gdb) run Server.py
        ... crash ...
        (gdb) bt
    

    Benoit.
  • Ahh... that makes much more sense. :) Here's the backtrace:
    #0  0x402d86c1 in free () from /lib/libc.so.6
    #1  0x40991341 in operator delete () from /usr/lib/libstdc++.so.6
    #2  0x40972297 in std::string::_Rep::_M_destroy () from /usr/lib/libstdc++.so.6
    #3  0x408a006d in Slice::Preprocessor::preprocess () from /opt/ice-2.1.2/lib/libSlice.so.21
    #4  0x4051efa3 in IcePy_loadSlice () from /opt/ice-2.1.2/lib/IcePy.so
    #5  0x4006d67d in PyCFunction_Call () from /usr/lib/libpython2.4.so.1.0
    #6  0x400a717f in PyEval_GetFuncDesc () from /usr/lib/libpython2.4.so.1.0
    #7  0x400a4e09 in PyEval_EvalFrame () from /usr/lib/libpython2.4.so.1.0
    #8  0x400a58ee in PyEval_EvalCodeEx () from /usr/lib/libpython2.4.so.1.0
    #9  0x400a2b97 in PyEval_EvalCode () from /usr/lib/libpython2.4.so.1.0
    #10 0x400d93f9 in PyRun_FileExFlags () from /usr/lib/libpython2.4.so.1.0
    #11 0x400d8804 in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.4.so.1.0
    #12 0x400d81ba in PyRun_AnyFileExFlags () from /usr/lib/libpython2.4.so.1.0
    #13 0x400e0cc6 in Py_Main () from /usr/lib/libpython2.4.so.1.0
    #14 0x08048699 in main ()
    
  • benoit
    benoit Rennes, France
    The /opt/ice-2.1.2 directory only contains the Ice binaries that you compiled from the source packages (Ice for C++ and Python), correct?

    I don't see why it segfaults in the C++ runtime library... it looks like a problem in your compiler installation. Did you compile Ice with another compiler than the one installed with your Slackware distribution? (in which case you might need to add the libstdc++ library path into your LD_LIBRARY_PATH).

    Also, do you get a similar stack trace if you compile the stubs with slice2py and comment out the Ice.loadSlice() directive in the Python script?

    Benoit.