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

Ask a Question related to Sun Solaris, Design and Development.

  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. Similar Questions and Discussions

    1. Binary file IO
      Hi, What I would like to do is load a file's contents from a file on the server and put the contents into a record in a database. For this I...
    2. binary data
      Greets, Register globals are to OFF - however the files will not upload. Thanking all in advance. TR ............... <? if ($submit) {
    3. binary perl
      Is it possible to make a perl script/program a binary file? I have a few scripts some one wants but I don't want them to have the source. I tried...
    4. CGI php Binary
      Hi; I appologize in advance to purists who think the question is an appache one, or a mysql question. I have a virtual domain hosted by...
    5. awk, sed etc on binary files
      Can I use commands like sed, awk, tr etc on binary files? The file contains a string e.g. TESTSTRING=6 which I need to change to TESTSTRING=10 JL
  3. #2

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

    [email]newdaily@altibase.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]alanc@alum.calberkeley.org[/email]
    [url]http://www.CSUA.Berkeley.EDU/~alanc/[/url] aka: [email]Alan.Coopersmith@Sun.COM[/email]
    Working for, but definitely not speaking for, Sun Microsystems, Inc.
    Alan Coopersmith Guest

  4. #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

  5. #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

  6. #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

  7. #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

Posting Permissions

  • You may not post new threads
  • You may 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