How do I submit a bug for Sun's C Compiler?

How do I submit a bug for Sun's C Compiler?

Post by Matthew Ric » Tue, 07 Apr 1998 04:00:00



I've found (what I consider) a big bug in Sun's C compiler (v4.2).
I've tried sending feedback to Sun through the address given with
my demo of Visual Workshop (comments-dp... or something) but it's
been almost a week and I haven't heard back.

Is there a better way to report this bug?  Or is my only recourse
to start using the C++ compiler exclusively (it doesn't have the bug)?
Is the C++ compiler consider more stable/reliable than the C compiler?

In case anyone is interested, I've included the test code that
reveals the problem.  When you compile and run it you should get
a non-zero exit value but due to the problem you get zero.
I've also included the assembler that is generated where you can
see that the branch to break out of the while loop is missing.

Thanks,
--
Matthew Rice                             e-mail: matthew.r...@ftlsol.com

PS - I'm just porting this code, I didn't write it.  I know it stinks
     to begin with, that they should have used strncasecmp, etc...
     However, they do this jumping into loops elsewhere (old FORTRAN
     programmers die hard, I guess) so I would like to resolve this.

/******************* BEGIN broke.c ************************/
#include <ctype.h>

short
Strnicmp_SYS(const char *pc1,
             const char *pc2,
             short   sI)
{
   register short i = 0;
   register int   c1 = 0,c2 = 0;

   goto START;
   do {

     if (c1 != c2) break;
     pc1++; pc2++; i++;
     START:
     c1 = toupper(*pc1);
     c2 = toupper(*pc2);

   } while ((c1 != 0) && (c2 != 0) && (i < sI));

   if (i >= sI) return(0);
   return( (short) (c1 - c2) );

}

int main(int argc, char *argv[])
{
   char *p1 = "-v";
   char *p2 = "-h";

   int i = Strnicmp_SYS(p1, p2, 2);

   return i;

}

/*************** END broke.c ***************************/

/*************** BEGIN broke.s *************************/
        .section        ".text",#alloc,#execinstr
        .align  8
        .skip   16

        ! block 0

        .global Strnicmp_SYS
        .type   Strnicmp_SYS,2
Strnicmp_SYS:
        save    %sp,-104,%sp
        st      %i2,[%fp+76]
        st      %i1,[%fp+72]
        st      %i0,[%fp+68]

        ! block 1
.L32:
.L33:
.L34:

! File strbroke.c:
!    1  #include <ctype.h>
!    2  
!    3  short
!    4  Strnicmp_SYS(const char *pc1,
!    5               const char *pc2,
!    6               short   sI)
!    7  {
!    8     register short i = 0;

        mov     0,%l0
        mov     %l0,%i5

        ! block 2
.L35:

!    9     register int   c1 = 0,c2 = 0;

        mov     0,%l0
        mov     %l0,%i4
        mov     0,%l0
        mov     %l0,%i3

        ! block 3
.L37:

!   11     goto START;

        ba      .L36
        nop

        ! block 4
.L38:
.L41:
.L43:

!   12     do {
!   13  
!   14       if (c1 != c2) break;

        cmp     %i4,%i3
        be      .L42
        nop

        ! block 5
.L44:
.L42:
.L45:

!   15       pc1++; pc2++; i++;

        ld      [%fp+68],%l0
        add     %l0,1,%l0
        st      %l0,[%fp+68]
        ld      [%fp+72],%l0
        add     %l0,1,%l0
        st      %l0,[%fp+72]
        mov     1,%l0
        add     %i5,%l0,%l0
        mov     %l0,%i5

        ! block 6
.L36:
.L46:

!   16       START:
!   17       c1 = toupper(*pc1);

        ld      [%fp+68],%l0
        ldsb    [%l0+0],%l0
        sll     %l0,24,%l0
        sra     %l0,24,%l0
        mov     %l0,%o0
        call    toupper
        nop
        mov     %o0,%l0
        mov     %l0,%i4

        ! block 7
.L47:

!   18       c2 = toupper(*pc2);

        ld      [%fp+72],%l0
        ldsb    [%l0+0],%l0
        sll     %l0,24,%l0
        sra     %l0,24,%l0
        mov     %l0,%o0
        call    toupper
        nop
        mov     %o0,%l0
        mov     %l0,%i3

        ! block 8
.L48:
.L49:
        cmp     %i4,0
        be      .L50
        nop

        ! block 9
.L51:
        cmp     %i3,0
        be      .L50
        nop

        ! block 10
.L52:
        sll     %i5,16,%l0
        sra     %l0,16,%l1
        ldsh    [%fp+78],%l0
        sll     %l0,16,%l0
        sra     %l0,16,%l0
        cmp     %l1,%l0
        bl      .L38
        nop

        ! block 11
.L53:
.L50:
.L55:

!   20     } while ((c1 != 0) && (c2 != 0) && (i < sI));
!   21  
!   22     if (i >= sI) return(0);

        sll     %i5,16,%l0
        sra     %l0,16,%l1
        ldsh    [%fp+78],%l0
        sll     %l0,16,%l0
        sra     %l0,16,%l0
        cmp     %l1,%l0
        bl      .L54
        nop

        ! block 12
.L56:
        mov     0,%l0
        st      %l0,[%fp-4]
        ba      .L31
        nop

        ! block 13
.L54:
.L57:

!   23     return( (short) (c1 - c2) );

        sub     %i4,%i3,%l0
        sll     %l0,16,%l0
        sra     %l0,16,%l0
        st      %l0,[%fp-4]
        ba      .L31
        nop

        ! block 14
        ba      .L31
        nop

        ! block 15
.L58:
.L59:
.L31:
        ld      [%fp-4],%l0
        mov     %l0,%i0
        jmp     %i7+8
        restore
        .size   Strnicmp_SYS,(.-Strnicmp_SYS)
        .align  8
        .align  8
        .skip   16

        ! block 0

        .global main
        .type   main,2
main:
        save    %sp,-112,%sp
        st      %i1,[%fp+72]
        st      %i0,[%fp+68]

        ! block 1
.L63:
.L64:
.L65:

! File strbroke.c:
!   24  }
!   25  
!   26  int main(int argc, char *argv[])
!   27  {
!   28     char *p1 = "-v";

        sethi   %hi(.L66),%l0
        or      %l0,%lo(.L66),%l0
        st      %l0,[%fp-8]

        ! block 2
.L67:

!   29     char *p2 = "-h";

        sethi   %hi(.L68),%l0
        or      %l0,%lo(.L68),%l0
        st      %l0,[%fp-12]

        ! block 3
.L69:

!   31     int i = Strnicmp_SYS(p1, p2, 2);

        ld      [%fp-8],%l0
        ld      [%fp-12],%l1
        mov     2,%l2
        mov     %l0,%o0
        mov     %l1,%o1
        mov     %l2,%o2
        call    Strnicmp_SYS
        nop
        mov     %o0,%l0
        st      %l0,[%fp-16]

        ! block 4
.L70:

!   33     return i;

        ld      [%fp-16],%l0
        st      %l0,[%fp-4]
        ba      .L62
        nop

        ! block 5
        ba      .L62
        nop

        ! block 6
.L71:
.L72:
.L62:
        ld      [%fp-4],%l0
        mov     %l0,%i0
        jmp     %i7+8
        restore
        .size   main,(.-main)
        .align  8

        .section        ".data1",#alloc,#write
        .align  4
.L66:
        .ascii  "-v\000"
        .skip   1
        .type   .L66,#object
        .size   .L66,4
        .align  4
.L68:
        .ascii  "-h\000"
        .type   .L68,#object
        .size   .L68,3

        .section        ".bss",#alloc,#write
Bbss.bss:
        .skip   0
        .size   Bbss.bss,0

        .section        ".data",#alloc,#write
Ddata.data:
        .skip   0
        .size   Ddata.data,0

        .section        ".rodata",#alloc
Drodata.rodata:
        .skip   0
        .size   Drodata.rodata,0

        .file   "strbroke.c"
        .xstabs ".stab.index","/mnt/files1/matt/tst/",100,0,0,0
        .xstabs ".stab.index","strbroke.c",100,0,3,0
        .stabs  "/mnt/files1/matt/tst/",100,0,0,0
        .stabs  "strbroke.c",100,0,3,0
        .xstabs ".stab.index","",56,0,0,0
        .xstabs ".stab.index","",56,0,0,0
        .stabs  "",56,0,0,0
        .stabs  "",56,0,0,0
        .xstabs ".stab.index","Xa ; g ; V=3.1 ; R=WorkShop Compilers 4.2 30 Oct 1996 C 4.2 ; G=$XACqCqAgKpI1TKg.",60,0,0,891458208
        .stabs  "Xa ; g ; V=3.1 ; R=WorkShop Compilers 4.2 30 Oct 1996 C 4.2 ; G=$XACqCqAgKpI1TKg.",60,0,0,891458208
        .xstabs ".stab.index","/mnt/files1/matt/tst; /opt/SUNWspro/bin/../SC4.2/bin/cc -g -S  strbroke.c -W0,-xp\\$XACqCqAgKpI1TKg.",52,0,0,0
        .stabs  "char:t(0,1)=bsc1;0;8;",128,0,0,0
        .stabs  "short:t(0,2)=bs2;0;16;",128,0,0,0
        .stabs  "int:t(0,3)=bs4;0;32;",128,0,0,0
        .stabs  "long:t(0,4)=bs4;0;32;",128,0,0,0
        .stabs  "long long:t(0,5)=bs8;0;64;",128,0,0,0
        .stabs  "signed char:t(0,6)=bsc1;0;8;",128,0,0,0
        .stabs  "signed short:t(0,7)=bs2;0;16;",128,0,0,0
        .stabs  "signed int:t(0,8)=bs4;0;32;",128,0,0,0
        .stabs  "signed long:t(0,9)=bs4;0;32;",128,0,0,0
        .stabs  "signed long long:t(0,10)=bs8;0;64;",128,0,0,0
        .stabs  "unsigned char:t(0,11)=buc1;0;8;",128,0,0,0
        .stabs  "unsigned short:t(0,12)=bu2;0;16;",128,0,0,0
        .stabs  "unsigned:t(0,13)=bu4;0;32;",128,0,0,0
        .stabs  "unsigned int:t(0,14)=bu4;0;32;",128,0,0,0
        .stabs  "unsigned long:t(0,15)=bu4;0;32;",128,0,0,0
        .stabs  "unsigned long long:t(0,16)=bu8;0;64;",128,0,0,0
        .stabs  "float:t(0,17)=R1;4;",128,0,0,0
        .stabs  "double:t(0,18)=R2;8;",128,0,0,0
        .stabs  "long double:t(0,19)=R6;16;",128,0,0,0
        .stabs  "void:t(0,20)=bs0;0;0",128,0,0,0
        .stabs  "/usr/include/ctype.h",130,0,0,0
        .stabs  "/usr/include/sys/feature_tests.h",130,0,0,0
        .stabn  162,0,0,0
        .stabn  162,0,0,0
        .xstabs ".stab.index","Strnicmp_SYS",36,0,0,0
        .stabs  "Strnicmp_SYS:F(0,2);(0,21)=*(0,22)=k(0,1);(0,23)=*(0,24)=k(0,1);(0,2)",36,0,0,0
        .stabs  "pc1:p(0,21)",160,0,4,68
        .stabs  "pc2:p(0,23)",160,0,4,72
        .stabs  "sI:p(0,2)",160,0,2,78
        .stabn  192,0,1,.L33-Strnicmp_SYS+0
        .stabs  "i:r(0,2)",64,0,2,29
        .stabs  "strbroke.c",132,0,0,0
        .stabn  68,0,8,.L34-Strnicmp_SYS+0
        .stabs  "c1:r(0,3)",64,0,4,28
        .stabn  68,0,9,.L35-Strnicmp_SYS+0
        .stabs  "c2:r(0,3)",64,0,4,27
        .stabn  68,0,11,.L37-Strnicmp_SYS+0
        .stabn  192,0,2,.L41-Strnicmp_SYS+0
        .stabn  68,0,14,.L43-Strnicmp_SYS+0
        .stabn  68,0,15,.L45-Strnicmp_SYS+0
        .stabn  68,0,17,.L46-Strnicmp_SYS+0
        .stabn  68,0,18,.L47-Strnicmp_SYS+0
        .stabn  224,0,2,.L48-Strnicmp_SYS+0
        .stabn  68,0,20,.L49-Strnicmp_SYS+0
        .stabn  68,0,22,.L55-Strnicmp_SYS+0
        .stabn  68,0,23,.L57-Strnicmp_SYS+0
        .stabn  68,0,24,.L58-Strnicmp_SYS+0
        .stabn  224,0,1,.L59-Strnicmp_SYS+0
        .xstabs ".stab.index","main",42,0,0,0
        .xstabs ".stab.index","main",36,0,0,0
        .stabs  "main:F(0,3);(0,3);(0,25)=*(0,26)=*(0,1)",36,0,0,0
        .stabs  "main",42,0,0,0
        .stabs  "argc:p(0,3)",160,0,4,68
        .stabs  "argv:p(0,25)",160,0,4,72
        .stabn  192,0,1,.L64-main+0
        .stabs  "p1:(0,26)",128,0,4,-8
        .stabn  68,0,28,.L65-main+0
        .stabs  "p2:(0,26)",128,0,4,-12
        .stabn  68,0,29,.L67-main+0
        .stabs  "i:(0,3)",128,0,4,-16
        .stabn  68,0,31,.L69-main+0
        .stabn  68,0,33,.L70-main+0
        .stabn  68,0,34,.L71-main+0
        .stabn  224,0,1,.L72-main+0
        .stabs  "toupper:P(0,3);(0,3)",36,0,0,0
        .stabs  "",98,0,0,0
        .ident  "@(#)ctype.h       1.19    95/01/28 SMI"
        .ident  "@(#)feature_tests.h       1.7     94/12/06 SMI"
        .ident  "acomp: WorkShop Compilers 4.2 30 Oct 1996 C 4.2"

        .global __fsr_init_value
__fsr_init_value = 0x0

/*************** END broke.s ***************************/

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by Casper H.S. Dik - Network Security Engine » Wed, 08 Apr 1998 04:00:00


[[ Reply by email or post, don't do both ]]


>I've found (what I consider) a big bug in Sun's C compiler (v4.2).
>I've tried sending feedback to Sun through the address given with
>my demo of Visual Workshop (comments-dp... or something) but it's
>been almost a week and I haven't heard back.

I filed bug #4126385 (the bug is common in x86/SPARC and is independent
of optimization level, still broken in C5.0)

But it's not the rigth way to file bug reports.  And if you want a patch,
you need to go through support channels.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by D. J. Hagbe » Thu, 09 Apr 1998 04:00:00


: I've found (what I consider) a big bug in Sun's C compiler (v4.2).
: I've tried sending feedback to Sun through the address given with
: my demo of Visual Workshop (comments-dp... or something) but it's
: been almost a week and I haven't heard back.

: Is there a better way to report this bug?  Or is my only recourse
: to start using the C++ compiler exclusively (it doesn't have the bug)?
: Is the C++ compiler consider more stable/reliable than the C compiler?

The "correct" way to report bugs is to open a case with Sun's
support people.  In the US, you can call 1-800-USA-4SUN.  I believe,
however, that this requires a support contract number.  If you're
using a demo or eval version of the compiler, I think you're out
of luck...

                        -=- D. J.

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by Casper H.S. Dik - Network Security Engine » Fri, 10 Apr 1998 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]



>: I've found (what I consider) a big bug in Sun's C compiler (v4.2).
>: I've tried sending feedback to Sun through the address given with
>: my demo of Visual Workshop (comments-dp... or something) but it's
>: been almost a week and I haven't heard back.
>: Is there a better way to report this bug?  Or is my only recourse
>: to start using the C++ compiler exclusively (it doesn't have the bug)?
>: Is the C++ compiler consider more stable/reliable than the C compiler?
>The "correct" way to report bugs is to open a case with Sun's
>support people.  In the US, you can call 1-800-USA-4SUN.  I believe,
>however, that this requires a support contract number.  If you're
>using a demo or eval version of the compiler, I think you're out
>of luck...

Well, it seems that the report send to the comments-dp or some
such did get entered into our bugs database after-all.

But no ack was send.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by Casper H.S. Dik - Network Security Engine » Fri, 10 Apr 1998 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>I've found (what I consider) a big bug in Sun's C compiler (v4.2).
>I've tried sending feedback to Sun through the address given with
>my demo of Visual Workshop (comments-dp... or something) but it's
>been almost a week and I haven't heard back.

Well, actually, these people did file a bug for you, #4125265

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by Matthew Ric » Sat, 11 Apr 1998 04:00:00



Quote:> >: Is there a better way to report this bug?  Or is my only recourse
> >: to start using the C++ compiler exclusively (it doesn't have the bug)?
> >: Is the C++ compiler consider more stable/reliable than the C compiler?

> Well, it seems that the report send to the comments-dp or some
> such did get entered into our bugs database after-all.

Actually, another Sun employee saw my posting here and submitted the
bug.  Which, I guess, answers my question on how to report a bug :)

Regards,
--

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by Michael He » Mon, 13 Apr 1998 04:00:00



>reveals the problem.  When you compile and run it you should get
>a non-zero exit value but due to the problem you get zero.

Interesting.  The previous edition of this compiler (4.0)
doesn't have this bug.  The bug is in 4.2 either with or without
the cc jumbo patch (104668-06).

It seems to have something to do with the jump into the loop;
the compiler warns about this:
line 13: warning: loop not entered at top
hacking around this, so this doesn't happen, the code returns
the expected value.

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by Tim Write » Sat, 18 Apr 1998 04:00:00




> >reveals the problem.  When you compile and run it you should get
> >a non-zero exit value but due to the problem you get zero.

> Interesting.  The previous edition of this compiler (4.0)
> doesn't have this bug.  The bug is in 4.2 either with or without
> the cc jumbo patch (104668-06).

Yeah, we (Matt's my partner) know - I have 4.0.  

Quote:> It seems to have something to do with the jump into the loop;
> the compiler warns about this:
> line 13: warning: loop not entered at top
> hacking around this, so this doesn't happen, the code returns
> the expected value.

We know this too.  Unfortunately, we didn't write the code.  We're working
with a large body of code from a third party and it has a lot of stuff like
this.  We're kind of reluctant to upgrade to 4.2 until we can be sure this
bug has been fixed.

This bug has really shaken my confidence in Sun's compilers.  I know
programmers shouldn't write code like this but what about code generators
like lex and yacc?

--

FTL Solutions Inc.
Toronto, Ontario, CANADA

 
 
 

How do I submit a bug for Sun's C Compiler?

Post by Casper H.S. Dik - Network Security Engine » Tue, 21 Apr 1998 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>We know this too.  Unfortunately, we didn't write the code.  We're working
>with a large body of code from a third party and it has a lot of stuff like
>this.  We're kind of reluctant to upgrade to 4.2 until we can be sure this
>bug has been fixed.
>This bug has really shaken my confidence in Sun's compilers.  I know
>programmers shouldn't write code like this but what about code generators
>like lex and yacc?

I don't think lex & yacc generate much code; they mostly generate tables/

It seems that the code is uncommon enough that it has taken around 18
months since the release of the compiler for someone to come across it.

You should keep in mind that Sun uses their own compilers for Solaris
and other products.

Interestingly, reversing the test and making it if (a == b) ; else break;
the correct code is generated.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.