Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Dec 1998 12:20:25 -0800
From:      John-Mark Gurney <gurney_j@efn.org>
To:        FreeBSD Hackers <freebsd-hackers@FreeBSD.ORG>
Subject:   _rtld_bind_start Segfault
Message-ID:  <19981219122025.22295@hydrogen.nike.efn.org>

next in thread | raw e-mail | index | archive | help

--ZO5zC0uMSeAMfFXi
Content-Type: text/plain; charset=us-ascii

has anyone else encountered stange segfaults when calling libc functions
late in yor program?

I have run across a couple programs that would segfault upon calling a
libc function, but if you "prebound" it in your program by calling that
function earlier, you don't run into any problems...

also, if you have main return instead of calling exit, the program
will segfault at address 0x13....

attached is the file that I first saw this problem... this file isn't
my code, but some code that I want sent to help find an unrelated problem
in...

I am running on 3.0-R with a partially updated kernel (mainly cam
updated)... and I just tested this on bento.freebsd.org and it behaves
the same...  (blah.c in /tmp on bento)

there are two ifdefs.. if you compile the program without any special
defines, it segfaults when it hits the first printf... if you define
BIND_PRINTF, it will run, but segfault upon the return...  if you define
CALL_EXIT, it will exit normally, but there is no reason that you should
have to specially bind and call exit from a program...

any ideas?

-- 
  John-Mark Gurney                              Voice: +1 541 684 8449
  Cu Networking					  P.O. Box 5693, 97405

  Live in Peace, destroy Micro$oft, support free software, run FreeBSD
	    Don't trust anyone you don't have the source for

--ZO5zC0uMSeAMfFXi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="blah.c"

#include <stdio.h>

#define MAX 20

int main()
{
   int A[MAX][MAX];
   int B[MAX][MAX];
   int C[MAX][MAX];	/* result AB */
   int i, j, k;		/* loop vars */
   int temp;		/* holds C(i,j) while computing */
   int counter1 = 0;	/* number of times first branch executed */
   int counter2 = 0;	/* number of times second branch executed */

#ifdef BIND_PRINTF
	printf("");
#endif
   for (j = 0; j < MAX; j++) 
   { for (i = 0; i < MAX; i++); 
     { A[i][j] = i - j;
       B[i][j] = i + j;
     }
   }

   temp = 0;
   for (j = 0; j < MAX; j++)
   { for (i = 0; i < MAX; i++)
     { for (k = 0; k < MAX; k++)
       { temp += A[i][k]*B[k][j];
       }
       C[i][j] = temp;
       printf("temp: %d\n",temp);
       if (temp > 0) 
       { temp = -1;
         counter1++;
       }
       if (temp < 0) 
       { temp = 0;
	 counter2++; }
     }
   }
   printf("New value was > 0 %d times\n",counter1);
   printf("After if, value was < 0 %d times\n",counter2);
#ifdef CALL_EXIT
	exit(0);
#endif
   return 0;
}

--ZO5zC0uMSeAMfFXi--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981219122025.22295>