Path: utzoo!yunexus!ists!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!RAND.ORG!salzman%gaucho From: salzman%gaucho@RAND.ORG (Isaac Salzman) Newsgroups: comp.soft-sys.andrew Subject: WP bug on SPARC, new release version? Message-ID: Date: 15 Nov 89 17:36:04 GMT Article-I.D.: gaucho.wZMNu4H01EthMLi0cI Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 147 [this was part of one long message - i decided to split it into several smaller messages] hi there. the following is in reference to Andrew R4 Beta release, patch level 5 running on a Sparcstation-1 (SunOS 4.0.3c). i've discovered a bug in the wp code on SPARC. actually, it's a bug in Sun's SPARC C compiler that's exercised by wp. it's in wp_DeAllocate() in overhead/util/lib/wpbase.c, which is declared as follows: wp_ErrorCode wp_DeAllocate(StrPtr) union { wp_PrimeKeySet *PKSet; struct wp_SrchToken *ST; wp_SearchToken XX;} StrPtr; { /* stuff */ } Sun's C compiler doesn't like the union. it compiles ok, but gets a bus error when you try to run it (when called from wpq for instance). this works ok on a Sun3, or a Sun4 with the GNU C Compiler (gcc). i'm going to send a bug report to sun. i don't suspect a fixed compiler will happen anytime soon, so i've hacked the code to pass StrPtr as a char *, and then cast it to the apropriately (e.g. ((struct xxx *)StrPtr)->yyy). context diff's enclosed. i've noticed a new .tar.Z file and emsworth. i gather that's the "release" version? i've grabbed patch06 but haven't applied it (it doesn't fix the wp problem - i checked). ciao! * Isaac J. Salzman ---- * The RAND Corporation - Information Sciences Dept. /o o/ / * 1700 Main St., PO Box 2138, Santa Monica, CA 90406-2138 | v | | * AT&T : +1 213-393-0411 x6421 or x7923 (ISL lab) _| |_/ * Internet : salzman@rand.org / | | * UUCP : !uunet!rand.org!salzman | | | * CompuServe: 76167,1046 ---- Enclosure ---- *** Orig/wpbase.c Wed Nov 15 08:03:12 1989 --- wpbase.c Wed Nov 15 08:14:07 1989 *************** *** 363,408 **** Clean up after the client is done with malloc'ed storage. */ wp_ErrorCode wp_DeAllocate(StrPtr) ! union { wp_PrimeKeySet *PKSet; struct wp_SrchToken *ST; wp_SearchToken XX;} StrPtr; { int ctr; struct wp_Constraint *CPtr; ! if (StrPtr.PKSet == NULL) return wperr_NoError; #if Logs Log(700, "wp_DeAllocate(0x%x) called", StrPtr); #endif /* Logs */ ! if (StrPtr.PKSet->KeyCount >= 0) { /* it's a pointer to PrimeKeySetStr */ if (wp_Debugging) {fprintf(stderr, "wp_DeAllocate(%#x) releasing a %d-key PrimeKeySet.\n", ! StrPtr.PKSet, StrPtr.PKSet->KeyCount); } ! if (StrPtr.PKSet->Keys != NULL) { if (wp_Debugging) fprintf(stderr, "PrimeKeySet has keys at %#x.\n", ! StrPtr.PKSet->Keys); ! for (ctr = StrPtr.PKSet->KeyCount - 1; ctr >= 0; --ctr) { ! if (StrPtr.PKSet->Keys[ctr] != NULL) { if (wp_Debugging) fprintf(stderr, ! "Releasing PKset key[%d]=%#x.\n", ! ctr, StrPtr.PKSet->Keys[ctr]); ! free(StrPtr.PKSet->Keys[ctr]); } } ! free(StrPtr.PKSet->Keys); } ! free(StrPtr.PKSet); ! } else if (StrPtr.ST->Tag == SrchTokenTag) { ! CPtr = StrPtr.ST->Constraints; while (CPtr != NULL) { ! StrPtr.ST->Constraints = CPtr->Next; if (CPtr->Tag != ConstraintTag) return wperr_TokenMalformed; free(CPtr->FieldContent); free(CPtr); ! CPtr = StrPtr.ST->Constraints; } ! free(StrPtr.ST->Probe); ! free(StrPtr.ST); } else return wperr_NoSuchTokenKind; if (wp_Debugging) fprintf(stderr, "wp_DeAllocate returning.\n"); #if Logs --- 363,415 ---- Clean up after the client is done with malloc'ed storage. */ wp_ErrorCode wp_DeAllocate(StrPtr) ! char *StrPtr; ! ! /* union { wp_PrimeKeySet *PKSet; struct wp_SrchToken *ST; ! wp_SearchToken XX;} StrPtr; ! */ ! { int ctr; struct wp_Constraint *CPtr; ! if (StrPtr == NULL) return wperr_NoError; #if Logs Log(700, "wp_DeAllocate(0x%x) called", StrPtr); #endif /* Logs */ ! if ( ((wp_PrimeKeySet *)StrPtr)->KeyCount >= 0) { /* it's a pointer to PrimeKeySetStr */ if (wp_Debugging) {fprintf(stderr, "wp_DeAllocate(%#x) releasing a %d-key PrimeKeySet.\n", ! (wp_PrimeKeySet *)StrPtr, ! ((wp_PrimeKeySet *)StrPtr)->KeyCount); } ! if (((wp_PrimeKeySet *)StrPtr)->Keys != NULL) { if (wp_Debugging) fprintf(stderr, "PrimeKeySet has keys at %#x.\n", ! ((wp_PrimeKeySet *)StrPtr)->Keys); ! for (ctr = ((wp_PrimeKeySet *)StrPtr)->KeyCount - 1; ctr >= 0; ! --ctr) { ! if (((wp_PrimeKeySet *)StrPtr)->Keys[ctr] != NULL) { if (wp_Debugging) fprintf(stderr, ! "Releasing PKset key[%d]=%#x.\n", ctr, ! ((wp_PrimeKeySet *)StrPtr)->Keys[ctr]); ! free(((wp_PrimeKeySet *)StrPtr)->Keys[ctr]); } } ! free(((wp_PrimeKeySet *)StrPtr)->Keys); } ! free((wp_PrimeKeySet *)StrPtr); ! } else if (((struct wp_SrchToken *)StrPtr)->Tag == SrchTokenTag) { ! CPtr = ((struct wp_SrchToken *)StrPtr)->Constraints; while (CPtr != NULL) { ! ((struct wp_SrchToken *)StrPtr)->Constraints = CPtr->Next; if (CPtr->Tag != ConstraintTag) return wperr_TokenMalformed; free(CPtr->FieldContent); free(CPtr); ! CPtr = ((struct wp_SrchToken *)StrPtr)->Constraints; } ! free(((struct wp_SrchToken *)StrPtr)->Probe); ! free(((struct wp_SrchToken *)StrPtr)); } else return wperr_NoSuchTokenKind; if (wp_Debugging) fprintf(stderr, "wp_DeAllocate returning.\n"); #if Logs ---- Enclosure ----