cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Segmentation fault in curl_easy_cleanup() [AIX]

From: <cml932atom_at_sulusea.org>
Date: Sat, 19 Oct 2002 14:49:14 -0400

Thanks for the reply Daniel. Comments follow...

On Fri, Oct 18, 2002 at 04:45:52PM +0200, Daniel Stenberg wrote:
> Also, have you tried to run this on any other platform to see if the
> problem is AIX-only or not?

No we have not tested our applications or our shared lib (that wraps
curl) on other platform. The applications are AIX & OS/2 specific
(although we should be able to port the test client and our lib to
Linux for testing if it comes to that).

Our current plan is to restart long-running tests with our source
build of 7.10.1 using xlC. If the behaviour is no longer exhibited,
and long running tests complete successfully, then we will probably
chalk the difficult to reproduce seg fault up to a "compiler
interaction" (libcurl: gcc?, app: xlC) and/or a pre-7.10.1 feature.

  ASIDE: Notes for building curl (7.10.1) using xlC_r on AIX 4.3.3.

    This is not a definitive guide to building curl using AIX/xlC, but
    only the route we took to successfully get past "configure && make
    && make test && make install".

    # The thread safe xlC mode "xlC_r" was required to get past the
    # configure script's compiler tests

    $ export CC=xlC_r

    $ export LDFLAGS="-Wl,-brtl"
    $ export CFLAGS="-O2 -qmaxmem=-1 -qarch=com"

    # Built libcurl as a static lib as we didn't want to hassle with
    # AIX's abnormal handling of shared libraries. Also, unsure sure
    # why our system didn't have the requisite header files for IPv6
    # but the '--disable-ipv6' was necessary.

    $ ./configure --enable-static --disable-shared --disable-ipv6

    $ make
    $ make test
    $ make install (as root)

> Possibly it would help to use some kind of memory tracking tool
> here, since that free() seems to be passing in a bad
> pointer. Building libcurl with the memory debug stuff enabled may
> offer some clues.

We attempted to use the memory tracking approach that was posted to
the list (by Daniel) on 2002/10/17, but ran into two problems due to
our use of xlC and AIX. (See MEMDEBUG PROBLEM DETAILS 1 & 2 below)

Note that we didn't necessarily expect "--enable-debug" to work OOTB
with xlC/AIX. We are just posting this detail for general awareness.
As mentioned above, our current plan is to see how far we get using
our local source build of 7.10.1. If we can be of any further
assistance in getting the memory debugging steps working specifically
with xlC/AIX, let us know and we'll do what we can (we may need to do
this anyway if the apps begin to seg fault with 7.10.1).

> > Each of these apps is dynamically linked with a shared library
> > (that implements Go() in the traces below) which utilizes the
> > "easy" curl API and is in turn statically linked with libcurl.
> > This shared library, the one containing Go(), utilizes no other
> > libraries.
> >
> > On each invocation curl_init() is called at the start of the
> > procedure and curl_easy_cleanup() is called at the end.
> >
> > Somewhat repeatable-- has occured with 3 distinct applications.
> > Not easily reproducible. Uncertain how the application/library
> > enters this state.
>
> So every time they call this, it fetches just one URL and then
> cleans up everything again?

Correct. The crash occurred (in each of the three instances) after
several thousand procedure calls.

> Can you see any pattern in the downloads that were done when the
> crash happens (size/speed or similar)?

We haven't seen a pattern, nor have we been able to induce a crash by
randomly varying the size of the returned document. We have added
additional logging to our library so we'll hopefully have more
information if this crash occurs again.

If the crash occurs with the 7.10.1 build, then we'll have to resolve
the AIX/xlC specific issues with the memory debugging procedure.

MEMDEBUG PROBLEM DETAIL 1/2:

IBM's xlC compiler is incompatible with the empty -W as well as all
other -W flags that "--debug-enabled" generates.

http://www.google.com/search?q=IBM+xlC++%22W+%3Cx%2Cy%3E%22+%22Flag+options%22

When "--debug-enabled" is used, the environment var CFLAGS is not
used. (This is probably not AIX/xlC specific, and if it is not
intentional might be something that needs to be addressed.)

---LOG 1/2 START---
$ export CC=xlC_r; export LDFLAGS="-Wl,-brtl"; export CFLAGS="-O2 -qmaxmem=-1 -qarch=com";
$ ./configure --enable-static --disable-shared --disable-ipv6 --enable-debug; make
checking for a BSD compatible install... ./install-sh -c
checking whether build environment is sane... yes
[snip]
Target "all-am" is up to date.
Target "all" is up to date.
Making all in lib
        cd .. && CONFIG_FILES= CONFIG_HEADERS=lib/ca-bundle.h /bin/sh ./config.status
config.status: creating lib/ca-bundle.h
config.status: lib/ca-bundle.h is unchanged
        make all-am
        source='file.c' object='file.lo' libtool=yes depfile='.deps/file.Plo' tmpdepfile='.deps/file.TPlo' depmode=aix /bin/sh ../depcomp /bin/sh ../libtool --mode=compile xlC_r -DHAVE_CONFIG_H -I../include -I../lib -I../lib -DMALLOCDEBUG -W -Wall -Wwrite-strings -pedantic -Wundef -Wpointer-arith -Wcast-align -Wnested-externs -g -c -o file.lo `test -f file.c || echo './'`file.c
xlC_r -DHAVE_CONFIG_H -I../include -I../lib -I../lib -DMALLOCDEBUG -W -Wall -Wwrite-strings -pedantic -Wundef -Wpointer-arith -Wcast-align -Wnested-externs -g -c -M file.c
xlC_r: 1501-208 command option W is missing a subargument
make: 1254-004 The error code from the last command is 1.

Stop.
---LOG 1/2 END---

MEMDEBUG PROBLEM DETAIL 2/2:

After running configure with "--enable-debug" (see above), we
customized the Makefiles by removing all "-W" options from CFLAGS and
restoring our own CFLAGS. Note that "-DMALLOCDEBUG" as well as "-g"
remain.

The problem here apparently is that our (more restrictive?)
pre-processor doesn't allow a DEFINE macro to redefine the standard
function definition in "/usr/include/sys/socket.h". If it is as
simple as this, then hopefully we can contact IBM AIX/xlC support for
help in loosening this restriction.

---LOG 2/2 START---
$ make
[snip]
Making all in lib
        cd .. && CONFIG_FILES= CONFIG_HEADERS=lib/ca-bundle.h /bin/sh ./config.status
config.status: creating lib/ca-bundle.h
config.status: lib/ca-bundle.h is unchanged
        make all-am
        source='file.c' object='file.lo' libtool=yes depfile='.deps/file.Plo' tmpdepfile='.deps/file.TPlo' depmode=aix /bin/sh ../depcomp /bin/sh ../libtool --mode=compile xlC_r -DHAVE_CONFIG_H -I../include -I../lib -I../lib -DMALLOCDEBUG -O2 -qmaxmem=-1 -qarch=com -g -c -o file.lo `test -f file.c || echo './'`file.c
xlC_r -DHAVE_CONFIG_H -I../include -I../lib -I../lib -DMALLOCDEBUG -O2 -qmaxmem=-1 -qarch=com -g -c -M file.c
"memdebug.h", line 67.9: 1506-213 (S) Macro name accept cannot be redefined.
"memdebug.h", line 67.9: 1506-358 (I) "accept" is defined on line 127 of /usr/include/sys/socket.h.
make: 1254-004 The error code from the last command is 1.

Stop.
---LOG 2/2 END---

-------------------------------------------------------
This sf.net email is sponsored by:
Access Your PC Securely with GoToMyPC. Try Free Now
https://www.gotomypc.com/s/OSND/DD
Received on 2002-10-19