libtool
[Top][All Lists]
Advanced

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

Re: libltdl apparently totally broken


From: Rob Browning
Subject: Re: libltdl apparently totally broken
Date: Tue, 06 Nov 2001 17:04:11 -0600
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1

stefan <address@hidden> writes:

> I ran into this either.  The following patch removes the bug once for a
> while:
>
> =======================================================================
> @@ -1955,8 +1962,9 @@
>    assert (strchr (dirname, LT_DIRSEP_CHAR) == 0);
>  #endif
>  
> -  if (dirname[dirname_len -1] == '/')
> -    --dirname_len;
> +  if (dirname_len > 0)
> +    if (dirname[dirname_len -1] == '/')
> +      --dirname_len;
>    filename_len = dirname_len + 1 + LT_STRLEN (dlname);
>  
>    /* Allocate memory, and combine DIRNAME and MODULENAME into it.
> =======================================================================

Thanks.  This sounds suspciously like our problem.  I added your
patch, but we still have a segfault in lt_dlopen (in memcpy).  It
looks like the first time while loading a .la file that the code needs
to realloc a buffer larger than 64K, it segfaults (and yes, our
dependency_libs line is longer than that :< -- hence my original post
regarding link times).

Anyone know why?

Here's the segment of code that'll reliably cause a segfault, even
though it should be an expensive no-op.  Are there 16-bit issues of
some kind here?

Also, I added a (!feof(file)) check to the while guard below.  It
seemed like that would be wise.

          /* Handle the case where we occasionally need to read a line
             that is longer than the initial buffer size.  */
          while (line[LT_STRLEN(line) -1] != '\n' && (!feof(file)))
            {
              /* Quick and dirty segfault. */
              char *tmp;
              printf("Reallocing to %ul for %.20s\n", line_len * 2, line);
              tmp = lt_dlmalloc(32 * 1024);
              tmp = LT_DLREALLOC (char, tmp, 128 * 1024L);
              lt_dlfree(tmp);

              line = LT_DLREALLOC (char, line, line_len *2);
              if (!fgets (&line[line_len -1], line_len +1, file))
                {
                  break;
                }
              line_len *= 2;
            }

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD



reply via email to

[Prev in Thread] Current Thread [Next in Thread]