[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20041123: udunits & pthread under Solaris for opendap



Mary,

The problem isn't with the UDUNITS package.  The problem is with the set
of functions to manage a binary search tree in the C runtime library
when linked-against POSIX threads.  The attached program exhibits the
same failure when built with POSIX threads yet works correctly when not.

This bug doesn't appear to have been previously reported to SUN.  We'll
see about doing that.

Regards,
Steve Emmerson

NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publicly available
through the web.  If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.

------- Original Message

>To: address@hidden
>From: Mary Haley <address@hidden>
>Subject: Problem linking both OPenDAP/Udunits on Sun
>Organization: National Center for Atmospheric Research
>Keywords: 200411231626.iANGQV7j014381


Dear Unidata Support,

We have been adding OPeNDAP support to NCL on as many systems
as we can, but ran into problems on Solaris 9. The problem is
with the Udunits software that we also have built into NCL.
If we add OPeNDAP support, then suddenly our Udunits functions
no longer work.

I tracked it down to the "pthread" library that needs to be
linked in for the OPeNDAP stuff to work. Apparently this
library is causing the Udunits software to go into an infinite
loop. It looks like the problem is in the "tdelete" call in


Here's a stand-alone Udunits test that illustrates the problem, and
doesn't involve NCL at all. (I'm using version 1-12.3 of Udunits to
link it.)

#include <stdio.h>
#include <udunits.h>

void main()
{
   int utret;
   utUnit unit;

   char *units = "months since 1870-1-1";

   printf("Calling utInit\n");
   utret = utInit("udunits.dat");

   printf("Calling utScan\n");
   (void)utScan(units, &unit);

   printf("Calling utTerm\n");
   utTerm();

   printf("Done calling utTerm\n");
}

If I compile and run this program on a Solaris 9 system:

cc -L/fs/scd/home1/ncargd/dev/sun4_SunOS_5_7_/lib 
-I/fs/scd/home1/ncargd/dev/sun4_SunOS_5_7_/include ud.c -ludunits -lm
niwot[83] ./a.out
Calling utInit
Calling utScan
Calling utTerm
Done calling utTerm
niwot[84]

You'll see it runs fine. However, if I link "-lpthread:" it goes
into an infinite loop and I have to kill it with <CTRL>-c:

niwot[84] cc -L/fs/scd/home1/ncargd/dev/sun4_SunOS_5_7_/lib 
-I/fs/scd/home1/ncargd/dev/sun4_SunOS_5_7_/include ud.c -ludunits -lm 
-lpthread
niwot[85] ./a.out
Calling utInit
Calling utScan
Calling utTerm
^Cniwot[86]

This problem also surfaced on a Solaris 7 system. I'm not sure if this 
is Solaris problem, but I'm wondering if there's a way around this so I
can have both OPeNDAP and Udunits support.

Thanks,

--Mary


-- 
-------------------------------------------------
Mary Haley                   address@hidden
NCAR/SCD/VETS                303-497-1254 (voice)
1850 Table Mesa Dr           303-497-1804 (fax)
Boulder, CO  80305
-------------------------------------------------

--

------- End of Original Message

#undef NDEBUG
#include <assert.h>
#include <search.h>
#include <stddef.h>
#include <string.h>

typedef int(*compare)(const void*, const void*);

void *root = NULL;

static void
delete(
    const void  *node,
    VISIT       order,
    int         level)
{
    if (order == leaf || order == endorder) {
        (void)tdelete(*(const char**)node, &root, (compare)strcmp);
    }
}

int
main()
{
    tsearch("one", &root, (compare)strcmp);

    twalk(root, (void (*)(const void *, VISIT, int))delete);

    return 0;
}