Crash when using the graphviz library

2011-05-19 Thread Reto Schneider
Hi

I have a fresh installation of openBSD 4.9-release where the sample code of the 
graphviz library
fails. It also fails on openBSD 4.8 but works perfectly on 
4.7/Ubuntu/Debian/FreeBSD/etc.

How to get the error:

Install graphviz:

# export PKG_PATH="http://mirror.switch.ch/ftp/pub/OpenBSD/4.9/packages/i386/";
# pkg_add -r graphviz


Creating the file sample.c with this content 
(http://www.graphviz.org/pdf/libguide.pdf, found at
page 40):

#include 
int main(int argc, char **argv)
{
GVC_t *gvc;
graph_t *g;
FILE *fp;
gvc = gvContext();
if (argc > 1)
fp = fopen(argv[1], "r");
else
fp = stdin;
g = agread(fp);
gvLayout(gvc, g, "dot");
gvRender(gvc, g, "plain", stdout);
gvFreeLayout(gvc, g);
agclose(g);
return (gvFreeContext(gvc));
}


Compile it (like shown in the example Makefile on page 39):
$ gcc -o sample sample.c `pkg-config --libs --cflags libgvc`


Run it:
$ ulimit -c unlimited
$ echo "graph G{node1;}"|./sample
./sample:/usr/local/lib/libgthread-2.0.so.2600.0: undefined symbol 
'pthread_getschedparam'
lazy binding failed!
Segmentation fault (core dumped)


Backtrace:
$ gdb sample sample.core

(gdb) bt
#0  0x01deb370 in _dl_bind () from /usr/libexec/ld.so
#1  0x01de7b87 in _dl_bind_start () from /usr/libexec/ld.so
#2  0x7c9a7628 in ?? ()
#3  0x0050 in ?? ()
#4  0xcfbe0033 in ?? ()
#5  0x01de0033 in ?? ()
#6  0x in ?? ()

The workaround I use for now is to link the program sample directly against 
pthread:
$ gcc -o sample sample.c `pkg-config --libs --cflags libgvc` -pthread

I have found a commit to the ports which does exactly this for the dot tool 
(without this patch it
fails like the code above):
http://www.openbsd.org/cgi-bin/cvsweb/ports/math/graphviz/patches/patch-cmd_dot_Makefile_in?rev=1.1;content-type=text%2Fx-cvsweb-markup

Now I am wondering it I did something wrong or if there is a problem with 
openBSD 4.8 and 4.9.

Regards,
Reto



Re: Crash when using the graphviz library

2011-05-19 Thread Reto Schneider
On 05/19/2011 05:03 PM, Stuart Henderson wrote:
> glib2 is now built with threads enabled so anything directly or indirectly
> pulling this in (in this case via gtk+2) must either also be built with 
> threads,
> or must be run with LD_PRELOAD=/usr/lib/libpthread.so

Sorry for my ignorance, but what exactly is the reason that it does not load 
its dependencies on its
own? I think I should not have to care about the dependencies of gvc/glib2, 
instead those libs
should be linked to them and the system should load it.

Is there something OpenBSD specific or did I miss something?



Re: Crash when using the graphviz library

2011-05-23 Thread Reto Schneider
On 05/19/2011 09:30 PM, Reto Schneider wrote:
> On 05/19/2011 05:03 PM, Stuart Henderson wrote:
>> glib2 is now built with threads enabled so anything directly or indirectly
>> pulling this in (in this case via gtk+2) must either also be built with 
>> threads,
>> or must be run with LD_PRELOAD=/usr/lib/libpthread.so
> 
> Sorry for my ignorance, but what exactly is the reason that it does not load 
> its dependencies on its
> own? I think I should not have to care about the dependencies of gvc/glib2, 
> instead those libs
> should be linked to them and the system should load it.
> 
> Is there something OpenBSD specific or did I miss something?
> 

Since I did not get an answer, I am wondering if this is the wrong list
to ask this question. Should I ask it somewhere else?