Professional Web Applications Themes

64 bit binary and 32 bit binary have different result. Is it library bug or compiler bug? - Sun Solaris

#include <errno.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <dirent.h> #include <assert.h> int main(int argc, char *argv[]) { DIR *s_pDIR; struct dirent *s_pDirEnt; struct dirent *s_pResDirEnt; char s_backupDir[1024]; int s_rc; s_pDirEnt = NULL; s_pDirEnt = (struct dirent*)malloc(sizeof(struct dirent) + 1024); if(s_pDirEnt == NULL) { printf("malloc error\n"); exit(1); } strcpy(s_backupDir, argv[1]); s_pDIR = opendir(s_backupDir); s_pResDirEnt = NULL; s_rc = readdir_r(s_pDIR, s_pDirEnt, &s_pResDirEnt); while(s_pResDirEnt != NULL) { s_pResDirEnt = NULL; s_rc = readdir_r(s_pDIR, s_pDirEnt, &s_pResDirEnt); assert(s_rc == 0); }//while closedir(s_pDIR); free(s_pDirEnt); return 0; } OS: Solaris 2.8 first, I compile this source with 32 bit. CC -D_POSIX_PTHREAD_SEMANTICS readdir.cpp -mt -xarch=v8plusa -o readdir ...

  1. #1

    Default 64 bit binary and 32 bit binary have different result. Is it library bug or compiler bug?

    #include <errno.h>
    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>
    #include <dirent.h>
    #include <assert.h>

    int main(int argc, char *argv[])
    {
    DIR *s_pDIR;
    struct dirent *s_pDirEnt;
    struct dirent *s_pResDirEnt;
    char s_backupDir[1024];
    int s_rc;

    s_pDirEnt = NULL;
    s_pDirEnt = (struct dirent*)malloc(sizeof(struct dirent) + 1024);

    if(s_pDirEnt == NULL)
    {
    printf("malloc error\n");
    exit(1);
    }

    strcpy(s_backupDir, argv[1]);
    s_pDIR = opendir(s_backupDir);

    s_pResDirEnt = NULL;
    s_rc = readdir_r(s_pDIR, s_pDirEnt, &s_pResDirEnt);

    while(s_pResDirEnt != NULL)
    {
    s_pResDirEnt = NULL;
    s_rc = readdir_r(s_pDIR, s_pDirEnt, &s_pResDirEnt);

    assert(s_rc == 0);
    }//while

    closedir(s_pDIR);
    free(s_pDirEnt);
    return 0;
    }

    OS: Solaris 2.8

    first, I compile this source with 32 bit.

    CC -D_POSIX_PTHREAD_SEMANTICS readdir.cpp -mt -xarch=v8plusa -o
    readdir

    and test like this.

    echo "y" | testindex ./

    It runs well. but It fails when I compile this source with 64 bit like
    this and test.

    CC -D_POSIX_PTHREAD_SEMANTICS readdir.cpp -mt -xarch=v9 -o readdir

    echo "y" | testindex ./

    Assertion failed: s_rc == 0, file testindex.cpp, line 36.

    So, I remove "echo "y"" and test like this

    testindex ./

    It runs well.

    How can I fix this bug? Is it compile bug?
    newdaily Guest

  2. #2

    Default Re: 64 bit binary and 32 bit binary have different result. Is it library bug or compiler bug?

    [email]newdailyaltibase.com[/email] (newdaily) writes in comp.unix.solaris:
    | s_rc = readdir_r(s_pDIR, s_pDirEnt, &s_pResDirEnt);
    | assert(s_rc == 0);

    The man page states:
    The POSIX readdir_r() returns 0 if successful or
    an error number to indicate failure.

    Have you looked to see what error number you are getting?

    It seems to work fine for me, but obviously you haven't provided the
    whole test case, since you show running a "testindex" program that
    takes input, which this program does not, and isn't the name you claim
    you compiled as. I would assume the bug is somewhere in testindex.

    --
    __________________________________________________ ______________________
    Alan Coopersmith [email]alancalum.calberkeley.org[/email]
    [url]http://www.CSUA.Berkeley.EDU/~alanc/[/url] aka: [email]Alan.CoopersmithSun.COM[/email]
    Working for, but definitely not speaking for, Sun Microsystems, Inc.
    Alan Coopersmith Guest

  3. #3

    Default Re: 64 bit binary and 32 bit binary have different result. Is itlibrary bug or compiler bug?

    On 24 Jun 2003, newdaily wrote:

    [...]

    We answered this question a week or two ago. The answer is
    the same now as it was then. :-)

    --
    Rich Teer, SCNA, SCSA

    President,
    Rite Online Inc.

    Voice: +1 (250) 979-1638
    URL: [url]http://www.rite-online.net[/url]

    Rich Teer Guest

  4. #4

    Default Re: 64 bit binary and 32 bit binary have different result. Is itlibrarybug or compiler bug?

    How long is he suppose to wait for this to change? :)

    Rich Teer wrote:
    > On 24 Jun 2003, newdaily wrote:
    >
    > [...]
    >
    > We answered this question a week or two ago. The answer is
    > the same now as it was then. :-)
    >
    > --
    > Rich Teer, SCNA, SCSA
    >
    > President,
    > Rite Online Inc.
    >
    > Voice: +1 (250) 979-1638
    > URL: [url]http://www.rite-online.net[/url]
    Wayne Rasmussen Guest

  5. #5

    Default Re: 64 bit binary and 32 bit binary have different result. Isitlibrary bug or compiler bug?

    On 25 Jun 2003, Wayne Rasmussen wrote:
    > How long is he suppose to wait for this to change? :)
    At least until the time_t's rolls over. And on a 64-bit OS,
    that will be some time... :-)

    --
    Rich Teer, SCNA, SCSA

    President,
    Rite Online Inc.

    Voice: +1 (250) 979-1638
    URL: [url]http://www.rite-online.net[/url]

    Rich Teer Guest

  6. #6

    Default Re: 64 bit binary and 32 bit binary have different result. Is it library bug or compiler bug?

    #include <errno.h>
    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>
    #include <dirent.h>
    #include <assert.h>

    int main(int argc, char *argv[])
    {
    DIR *s_pDIR;
    struct dirent *s_pDirEnt;
    struct dirent *s_pResDirEnt;
    char s_backupDir[1024];
    int s_rc;

    s_pDirEnt = NULL;
    s_pDirEnt = (struct dirent*)malloc(sizeof(struct dirent) + 1024);

    if(s_pDirEnt == NULL)
    {
    printf("malloc error\n");
    exit(1);
    }

    strcpy(s_backupDir, argv[1]);

    /* I omit a fflush */
    fflush(NULL); <<-------------------- The Problem
    s_pDIR = opendir(s_backupDir);

    s_pResDirEnt = NULL;
    s_rc = readdir_r(s_pDIR, s_pDirEnt, &s_pResDirEnt);

    while(s_pResDirEnt != NULL)
    {
    s_pResDirEnt = NULL;
    s_rc = readdir_r(s_pDIR, s_pDirEnt, &s_pResDirEnt);

    assert(s_rc == 0);
    }//while

    closedir(s_pDIR);
    free(s_pDirEnt);
    return 0;
    }

    I am sorry that i omit a "fflush".
    CC -D_POSIX_PTHREAD_SEMANTICS testindex.cpp -mt -xarch=v9 -o
    testindex.
    echo "y" | ./testindex ./

    if I remove fflush, this test case runs well. but If I insert a
    fflush, this case fails.

    why does fflush influence a testindex?
    newdaily Guest

Similar Threads

  1. binary data
    By Lo Dolce Pesca in forum PHP Development
    Replies: 1
    Last Post: April 16th, 08:12 AM
  2. binary libphp4.so
    By Richard Jonker in forum PHP Development
    Replies: 0
    Last Post: January 11th, 09:46 AM
  3. CGI php Binary
    By Jan Fure in forum PHP Development
    Replies: 0
    Last Post: September 23rd, 06:13 PM
  4. awk, sed etc on binary files
    By John Leslie in forum AIX
    Replies: 1
    Last Post: September 1st, 06:00 PM
  5. Binary Compatibility
    By C in forum ASP Components
    Replies: 2
    Last Post: July 2nd, 09:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139