[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [APR PATCH] Bootstrapping problem on Mac OS X

From: Pier Fumagalli <pier_at_betaversion.org>
Date: 2002-06-10 18:00:23 CEST

Hmm... I basically rewrote that part, so, I believe it's my fault...

Yes, you're right, without the default error handlers, the baby exits (but
this is not a problem in Apache 2.0 as DSO modules are required to be there
at startup, but your point is right, if we don't have to terminate the
process, we'd better not to...

Now, the question is _why_ that thing is called and why libsvn_ra_local.so
does not exist (if shared is disabled, it should be compiled in, right?)...

You'd have to compile that library as a MH_BUNDLE, and it should go away...

    Pier

"David Mankin" <mankin@ants.com> wrote:

>
> Sander Striker suggested I forward this on to the APR dev list so
> someone who has access to OS X can take a look at it. I'm not on the
> APR mailing list, so please crosspost replies to me or
> dev@subversion.tigris.org.
>
> -David Mankin
>
> ---------- Forwarded message ----------
> Date: Mon, 10 Jun 2002 01:44:05 -0700 (PDT)
> From: David Mankin <mankin@ants.com>
> To: dev@subversion.tigris.org
> Subject: [APR PATCH] Bootstrapping problem on Mac OS X
>
>
> This weekend I tried to bootstrap subversion from the r1868 tarball.
> However, I ran into a Mac OS X related stopper. Every time I tried to
> run svn to checkout the repository, it exited with this error:
>
> dyld: svn can't open library: libsvn_ra_local.so (No such file or directory,
> errno = 2)
>
> I configured and built svn with the --enable-maintainer-mode and
> --disable-shared.
>
> Using gdb I tracked the problem down to a call in APR's apr_dso_load()
> in unix/dso.c, line 144. apr_dso_load calls NSAddLibrary(path). It
> checks the return value of NSAddLibrary. Unfortunately, if you don't
> setup an error handler with a call to NSInstallLinkEditErrorHandlers(),
> then all link errors are fatal and the whole program exits.
>
> The man page for NSAddLibrary() (NSModule(3)) is a little confusing on
> what an error in NSAddLibrary() means. Two excerpts:
>
> NSAddLibrary is passed the file name of a dynamic shared
> library to be added to the search list. If it is success-
> ful it returns TRUE else it returns FALSE.
>
> ...
>
> If the user does not supply [error handlers], the default
> will be to write an error message on to file descriptor 2
> (usually stderr) and exit the program... [except for warnings].
>
> (Whole manpage available at http://www.osxfaq.com/man/3/NSModule.ws)
>
> My experience shows that on failure, rather than returning FALSE, the
> default error handling is exiting the program.
>
> I really don't know much about dynamic libraries or APR, so I don't know
> the right way to fix this. At the end of this message is a patch for
> APR that works for me and at least makes the Subversion bootstrapping
> work. But I'm nowhere near sure it's good to apply this to APR. (For
> instance, my patch installs NSLinkEditErrorHandlers, but never
> uninstalls them. I don't know if it should. Also, it compiles with
> warnings.)
>
> IMO this is a bug in APR that should be fixed (trying to load a
> non-existent library shouldn't kill the program).
>
> However, I think there might also be a bug (or several) in Subversion.
> I compiled with --disable-shared, and yet subversion is still trying to
> load a dynamic library. I'm trying to do an HTTP checkout, and yet it's
> trying to load a dynamic library for RA local. Both of these seem like
> they might be problems. (And even with my patch to APR, I still get a
> warning, about not being able to load libsvn_ra_local.so, every time I
> do anything with the client. Maybe my patch should throw away the error
> instead of printing it?)
>
> [A fourth thing that may be an issue: when I modified dso.c and then
> re-ran make from the top-level svn makefile, it didn't re-link the svn
> binary, even though the apr.la (?) library had changed. I had to touch
> clients/cmdline/main.c in order to force make to rebuild svn.]
>
> Here was my stack trace when apr quits my program:
>
> #0 apr_dso_load (res_handle=0xbffff5b8, path=0xbffff580 "¿ÿõà¿ÿù´",
> pool=0x18) at dso.c:148
> #1 0x00039d54 in load_ra_module (func=0xbffff620, ra_name=0x9a724
> "local", pool=0x2a8350) at subversion/libsvn_ra/ra_loader.c:96
> #2 0x00039e84 in svn_ra_init_ra_libs (ra_baton=0xbffff6a8,
> pool=0x2a8350) at subversion/libsvn_ra/ra_loader.c:150
> #3 0x0000cf1c in svn_client_checkout (before_editor=0x0,
> before_edit_baton=0x0, after_editor=0x2a8600, after_edit_baton=0x2ac550,
> auth_baton=0x2a85e8, URL=0x2a85d8, path=0x2a84b8, revision=0xbffff798,
> recurse=1, xml_src=0x0, pool=0x2a8350) at
> subversion/libsvn_client/checkout.c:105
> #4 0x00002abc in svn_cl__checkout (os=0x2a8468, opt_state=0xbffff798,
> pool=0x2a8350) at subversion/clients/cmdline/checkout-cmd.c:125
> #5 0x0000689c in main (argc=5, argv=0xbffff99c) at
> subversion/clients/cmdline/main.c:1108
> #6 0x0000266c in _start ()
> #7 0x0000249c in start ()
>
> (line numbers, except in dso.c, reference r1868, sorry.)
>
> I haven't dug into the svn code enough to know how to fix the problems,
> but here's my patch to dso.c:
>
> --- subversion-r1868-clean/apr/dso/unix/dso.c Fri May 3 09:00:27 2002
> +++ subversion-r1868/apr/dso/unix/dso.c Mon Jun 10 01:35:52 2002
> @@ -115,6 +115,25 @@
> return APR_SUCCESS;
> }
>
> +/*
> + * Under Darwin, we need to have a linkEdit error handler, or else if
> + * NSAddLibrary() fails, it will exit the whole program. This function
> prints
> + * the same message that the OS would, but does not exit the program.
> + */
> +#if defined(DSO_USE_DYLD)
> +APR_DECLARE(void) apr_dso_load_linkEdit_errorhander(NSLinkEditErrors
> errorClass,
> + int errorNumber,
> + const char *filename,
> + const char *errorString)
> +{
> + if (errorString != NULL) {
> + fprintf(stderr, "%s", errorString);
> + } else {
> + fprintf(stderr, "LinkEdit error! errorno = %d\n", errorNumber);
> + }
> +}
> +#endif
> +
> APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle,
> const char *path, apr_pool_t *pool)
> {
> @@ -125,6 +144,21 @@
> NSObjectFileImage image;
> NSModule os_handle = NULL;
> char* err_msg = NULL;
> +
> + /*
> + * Only set the linkEdit handler, not the missing-symbol or
> + * multiply-defined-symbol handlers.
> + */
> + NSLinkEditErrorHandlers error_handlers = {
> + NULL, NULL, &apr_dso_load_linkEdit_errorhander
> + };
> + /*
> + * Load fprintf so that the error handler can use it. Otherwise we can
> get
> + * deadlock because the error handling needs to load the fprintf library.
> + */
> + fprintf(stderr, "");
> + NSInstallLinkEditErrorHandlers(&error_handlers);
> +
> if (NSCreateObjectFileImageFromFile(path, &image) ==
> NSObjectFileImageSuccess) {
>
> /*
>
>
>
> If people want, I can provide the patch as a diff against APR HEAD so
> that someone (Sander?) can apply it or pass it off the the APR folks.
>
> -David Mankin
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jun 10 18:10:01 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.