Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
--- Igor Robul [EMAIL PROTECTED] wrote: Rob wrote: --- Igor Robul [EMAIL PROTECTED] wrote: First: NULL return from dlsym() does not always imply an error. dlsym() can return NULL because it has an empty list, but this does not set the error indicator of dlerror(), because it is not an error. However, if an error occurs, dlsym() has NULL as a return (that's probably most sensible return). From manual page: The dlsym() function returns a null pointer if the symbol cannot be found, and sets an error condition which may be queried with dlerror(). This is a matter of symantic and logic. I /can/ read this as follows: If the symbol cannot be found, then dlsym() returns a null pointer *AND* sets the error condition. However, dlsym() can also return the null pointer, *WITHOUT* setting the error condition. The latter case seems to be better specified in the Linux manpages of dlsym(). Hence the conflict between FreeBSD and Linux/Grace, I guess. Rob. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
--- Igor Robul [EMAIL PROTECTED] wrote: Rob wrote: The dlsym() function returns a null pointer if the symbol cannot be found, and sets an error condition which may be queried with dlerror(). This is a matter of symantic and logic. I /can/ read this as follows: If the symbol cannot be found, then dlsym() returns a null pointer *AND* sets the error condition. Ok, English is not my native language, and I even had not learned it in school :-). Neither is it for me, though I had some English language classes at high school. However, I assume everybody to understand the language of logic and symantics when it comes to computer problems :). However, dlsym() can also return the null pointer, *WITHOUT* setting the error condition. The latter case seems to be better specified in the Linux manpages of dlsym(). Hence the conflict between FreeBSD and Linux/Grace, I guess. Maybe. But I see conflict in using previous/non-grace result from dlerror(), which I think grace should not do. Indeed, so the proper way is to call dlerror() prior to a dlsym() call, to reset any previous error condition. Something like this: /* clear error condition */ dlerror(); /* use dlsym and check for error */ data = dlsym(); if ( (error = dlerror()) != NULL ) { errmsg(error); return FAILURE; } Rob. __ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
--- Igor Robul [EMAIL PROTECTED] wrote: %mkdir %cd / %cat ~/.grace/gracerc.user USE pow TYPE f_of_dd FROM /usr/lib/libm.so %ls %xmgrace % OK, great. Meanwhile, I came closer to the real problem. You don't need to create the link in /usr/X11R6/lib. The problem is dlerror(). Whenever one of the dl-functions is called, it will set the error indicator in dlerror() in case of problems. For some unclear reason, the error indicator in dlerror is set when grace starts-up. I don't know why yet (I'll discuss that with the grace mailing list). When grace uses the dl-functions in src/dlmodule.c, which is caused by the USE... lines in gracerc.user, something like this happens: dlopen(library name, MODE); if (dlerror() != NULL) { report_error(); exit(1); } Now, dlerror() is set, but not by dlopen(), but by some other part at start-up. A workaround is following: /* reset any possible earlier error */ dlerror(); dlopen(library name, MODE); if (dlerror() != NULL) { report_error(); exit(1); } When I patch grace with this dummy dlerror(), prior to the dl-function calls, all works like a charm (and you don't need the link in /usr/X11R6/lib anymore). As I said before, I now have to find out why grace activates the dlerror() at start-up. Regards, Rob. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
--- Igor Robul [EMAIL PROTECTED] wrote: Rob wrote: When I patch grace with this dummy dlerror(), prior to the dl-function calls, all works like a charm (and you don't need the link in /usr/X11R6/lib anymore). As I said before, I now have to find out why grace activates the dlerror() at start-up. So, problem is on grace side, not on FreeBSD side. I think there are some differences in execution environment for grace on Linux and FreeBSD. Then we have to tell the grace developper, who is a devote Linux user, about the oddities on FreeBSD, or we have to come up with a reasonable patch to make it work properly on FreeBSD. Meanwhile I digged a little deeper in the grace source code, to find out at what place exactly the dlerror() error-indicator is set. When grace initializes its GUI, there is this kind of code: --- XtAppContext app_con; Display *disp = NULL; char *display_name = NULL; XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize(); app_con = XtCreateApplicationContext(); disp = XOpenDisplay(display_name); --- (I have simplified this code snippet a bit, for this example; also, grace uses Motif for its GUI). Before the XOpenDisplay() call, dlerror() does not have the error-indicator set, but after that call, it has. Is this where Linux and FreeBSD are out-of-sync? Or does Grace something wrong here, or is this a problem cause by FreeBSD or Xorg? I feel I'm getting closer and closer, but still I have not really a good idea of what's going on here! Thanks, Rob. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
Rob wrote: --- XtAppContext app_con; Display *disp = NULL; char *display_name = NULL; XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize(); app_con = XtCreateApplicationContext(); disp = XOpenDisplay(display_name); --- (I have simplified this code snippet a bit, for this example; also, grace uses Motif for its GUI). Before the XOpenDisplay() call, dlerror() does not have the error-indicator set, but after that call, it has. Is this where Linux and FreeBSD are out-of-sync? Or does Grace something wrong here, or is this a problem cause by FreeBSD or Xorg? I think, that when XOpenDisplay called, ld.so tries load some libraries from preconfigured paths, and last unsuccessful attempt is recorded for dlerror(). dlopen() _does not_ reset dlerror() state on sucess, it just returns non NULL. So you must not check dlerror() for error condition, you need check return result of dlopen(), and if it is NULL, then you need use dlerror(). So, code in grace: dlopen(library name, MODE); if (dlerror() != NULL) { report_error(); exit(1); } need to be: handle = dlopen(library name, MODE); if (handle == NULL) { report_error(dlerror()); exit(1); } just because dlerror() != NULL is not indicator of error. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
Igor Robul wrote: dlopen() _does not_ reset dlerror() state on sucess, it just returns non NULL. So you must not check dlerror() for error condition, you need check return result of dlopen(), and if it is NULL, then you need use dlerror(). So, code in grace: dlopen(library name, MODE); if (dlerror() != NULL) { report_error(); exit(1); Actual code in grace is: newkey.data = dlsym(handle, dl_function); if ((error = (char *) dlerror()) != NULL) { errmsg(error); dlclose(handle); return RETURN_FAILURE; } But I think it is needed to be something like (I dont know if they need error variable later): newkey.data = dlsym(handle, dl_function); if ( newkey.data == NULL) { errmsg(error=dlerror()); dlclose(handle); return RETURN_FAILURE; } ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
Sorry, I have reread manual page for dlerror() and found that it need clear error state after call, but dlerror() in src/libc/gen/dlfcn.c does not do this: #pragma weak dlerror const char * dlerror(void) { return sorry; } So error is in FreeBSD libc, if I understand this correctly. I'll do PR. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
Igor Robul wrote: Sorry, I have reread manual page for dlerror() and found that it need clear error state after call, but dlerror() in src/libc/gen/dlfcn.c does not do this: #pragma weak dlerror const char * dlerror(void) { return sorry; } So error is in FreeBSD libc, if I understand this correctly. I'll do PR. Bad day for me :-(. Above code is from src/libc/gen/dlfcn.c, but real dlerror for dynamicaly linked executables is in rtdl.c, and it works as described in manual page (clears error status). So problem is somewhere else. Sorry for false info. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: math/grace port: libXcursor.so.1.0 not found ?? [SOLVED]
--- Igor Robul [EMAIL PROTECTED] wrote: Rob wrote: --- XtAppContext app_con; Display *disp = NULL; char *display_name = NULL; XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize(); app_con = XtCreateApplicationContext(); disp = XOpenDisplay(display_name); --- (I have simplified this code snippet a bit, for this example; also, grace uses Motif for its GUI). Before the XOpenDisplay() call, dlerror() does not have the error-indicator set, but after that call, it has. I wrote simple program to test XOpenDisplay + dlopen: #include X11/Xlib.h #include dlfcn.h #include stdio.h main(int argc, char **argv) { Display *d; void *handle; void *f; char *err; if ((err=dlerror()) != NULL) { fprintf(stderr,dlerror: %s\n, err); exit(1); } d = XOpenDisplay(NULL); if (d == NULL) { fprintf(stderr, Error in XOpenDisplay\n); exit(1); } if ((err=dlerror()) != NULL) { fprintf(stderr, dlerror: %s\n, err); exit(1); } XCloseDisplay(d); handle = dlopen(argv[1], RTLD_NOW); if (handle == NULL) { fprintf(stderr, dlopen: %s\n, dlerror()); exit(1); } f = dlsym(handle, argv[2]); if (f == NULL) { fprintf(stderr, dlsym: %s\n, dlerror()); exit(1); } dlclose(handle); } Compile it with gcc -o t t.c -I /usr/X11R6/include -L /usr/X11R6/lib -lX11 Then test with: ./t /usr/lib/libm.so pow Then ./t /usr/lib/libm.so pow33 dlsym: Undefined symbol pow33 So as you can see on my system all looks good. Try it on your system. First: NULL return from dlsym() does not always imply an error. dlsym() can return NULL because it has an empty list, but this does not set the error indicator of dlerror(), because it is not an error. However, if an error occurs, dlsym() has NULL as a return (that's probably most sensible return). Second: I get different output than you, from this part of the program: d = XOpenDisplay(NULL); if (d == NULL) { fprintf(stderr, Error in XOpenDisplay\n); exit(1); } if ((err=(char *)dlerror()) != NULL) { fprintf(stderr, dlerror: %s\n, err); exit(1); } I get here: dlerror: Shared object nss_dns.so.1 not found, required by t So apparently dlerror() is set by XOpenDisplay(). Hmmmyesterday I updated my world and kernel to most recent 5-Stable, and after that I recompiled all my ports. Still get this problem! This is my /etc/make.conf: --- CFLAGS= -O -pipe NOPROFILE=true NO_PF=true CUPS_OVERWRITE_BASE=yes NO_LPR=yes WITHOUT_NLS=yes WITHOUT_XFT=yes DOC_LANG=en_US.ISO8859-1 WITH_ASPELL=yes WITH_GTK2=yes WITH_GIMP=yes A4=yes WITH_X11=yes # added by use.perl 2005-10-26 14:20:09 PERL_VER=5.8.7 PERL_VERSION=5.8.7 --- Does that cause any problems? Rob. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]