f



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?
0
newdaily
6/25/2003 6:31:24 AM
comp.unix.solaris 26025 articles. 2 followers. Post Follow

5 Replies
1542 Views

Similar Articles

[PageSpeed] 42

newdaily@altibase.com (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                              alanc@alum.calberkeley.org
http://www.CSUA.Berkeley.EDU/~alanc/       aka: Alan.Coopersmith@Sun.COM
  Working for, but definitely not speaking for, Sun Microsystems, Inc.
0
Alan
6/25/2003 2:58:45 PM
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: http://www.rite-online.net

0
Rich
6/25/2003 3:51:40 PM
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: http://www.rite-online.net

0
Wayne
6/25/2003 8:26:10 PM
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: http://www.rite-online.net

0
Rich
6/25/2003 9:37:48 PM
#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?
0
newdaily
6/26/2003 12:31:26 AM
Reply:

Similar Artilces:

A 64-bit binary returning a value to a 32-bit binary?
I have a program that needs to be compiled as 64bit. I have another program that needs to be compiled as 32bit and will call that 64-bit binary. Is there a way for the 64-bit binary to return a string to the 32-bit? If so, how? The only way I could think of is to have the 32-bit binary call the 64- bit binary, then it writes to a text file and finally have the 32-bit binary read it off. Is there a better way to do this? spammenotplui31@yahoo.ca wrote: > I have a program that needs to be compiled as 64bit. I have another > program that needs to be compiled as 32bit and will call t...

Are 64-bit Binaries Really Slower than 32-bit Binaries?
http://www.osnews.com/story.php?news_id=5768&page=1 "Jean Marc BRUN" <jean-marc.brun _arobace/at_ tgcp.fr> wrote: > http://www.osnews.com/story.php?news_id=5768&page=1 hey dammit!! I just posted that a couple of days ago! :-) -nick e. -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. --Linus Torvalds "Nick E." <nicke@flyingpigs.com> a �crit dans le message de news: JYcRb.4749 --- > I just posted that a couple of days ago! > > :-) > OOOPSS... Let's say it's for ...

64 bit binary launching 32 bit binaries and LD_PRELOAD'ed shared lib
Hi, Platform information: Solaris 10 running on AMD64. I have a 32-bit pre-loaded shared library 'mysharedlib.so' running with a 64-bit binary 'bin_exec_64'. LD_PRELOAD=mysharedlib.so bin_exec_64 ... I am getting the following error: wrong ELF class: ELFCLASS64 I read about this problem on the web and found out about the specialized LD_PRELOAD_32/LD_FLAGS_32 (for pre-loading 32bit shared libs) and LD_PRELOAD_64/LD_FLAGS_64 (for pre-loading 64bit shared libs). However, if I set LD_PRELOAD_32=mysharedlib.so and execute 64-bit 'bin_exec_64', none of the functions in...

different binary output with 32- and 64-bit hosted compilers
--001a114093f4b9dd02051eb118b6 Content-Type: text/plain; charset=UTF-8 32-bit (i686-linux fedora-9) and 64-bit (x86_64-linux fedora-20) hosted djgpp-targeting compiler generates different output for some sources. This happens with djgpp source itself too, and it isn't a nice thing and was not an expected thing for me. Did the following with gcc-3.4.6: Compiled djgpp-cvs with a 32- and 64-bit hosted toolchain (gcc-3.4.6 and binutils-2.25.1), then did: diff -urp --exclude=*.d --exclude=id_*.o --exclude=stub* \ --exclude=*.tex --exclude=*.exe --exclude=djasm.c \ 32/src 64/s...

32-bit Number * 32-bit Number = 64-bit result
I need to do multiplication that mirrors how C handles integer multiplication. That is, one 32-bit number times another 32-bit number equals the least significant 32-bits of the 64-bit result. In theory, I could mimic that behavior like so: (x * x) & 0xFFFFFFFF But this doesn't work quite right because the initial multiplication can produce such a large result that JavaScript looses some precision. Any thoughts? Ideas? "Jeff.M" <Mott.Jeff@gmail.com> writes: > I need to do multiplication that mirrors how C handles integer > multiplication. That is, one 32-bit...

compiling on 32-bit vs. 64-bit (gcc fails on 64-bit)
On a 64-bit Scientific Linux 5.4 machine, I get the following when I try to compile the basic "Hello world" program: [root]# g++ -Wall hello.cc -o hello /tmp/ccglIDXK.s: Assembler messages: /tmp/ccglIDXK.s:10: Error: suffix or operands invalid for `push' /tmp/ccglIDXK.s:38: Error: suffix or operands invalid for `push' /tmp/ccglIDXK.s:55: Error: suffix or operands invalid for `push' /tmp/ccglIDXK.s:79: Error: suffix or operands invalid for `push' /tmp/ccglIDXK.s:81: Error: suffix or operands invalid for `push' /tmp/ccglIDXK.s:85: Error: suffix or operand...

Matlab 64 vs 32 bit benchmarking results (on Win XP 64 bit vs Win XP 32 bit SP2)
Recently I installed a new PC with dual boot, win XP 32 bit and win XP 64 bit. On the 32 bit OS I run 32 bit matlab, on the 64 bit OS I run 64 bit matlab. MATLAB Version 7.3.0.267 (R2006b) Intel core 2 duo 6700 @ 2.66GHz, 2GB RAM NVIDIA GeForce 7600 GS I benchmarked the systems in 2 ways (average over multiple runs): 1) with a benchmark from the file exchange MATLAB Central > File Exchange > Utilities > Miscellaneous > Benchmark http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11984&objectType=file 2) With my own benchmark (training of neural netwo...

Windows 7 64 bit
My server works under Windows 7 Professional 64 bits, my FileMaker Pro10 Advanced is 32 bits. FM has to connect to a MySQL-database, which driver should I use? The 64bits or the 32bits version? And if 64, can FM communicate via the 64bits driver with MySQL? Or should I better downgrade W7 to 32bits? Harry <a@b.c> wrote: > My server works under Windows 7 Professional 64 bits, my FileMaker > Pro10 Advanced is 32 bits. > FM has to connect to a MySQL-database, which driver should I use? > The 64bits or the 32bits version? I never used Filemaker. And I try to sta...

code to determine 64-bit vs 32-bit binaries?
Can anyone post sample code showing how to determine, within a Solaris process space, whether a program it's about to exec is a 64-bit or 32-bit executable? No use saying "man file"; I have to do it within the current process. And of course the next obvious response is "take a look at GNU or BSD file commands and see what they do". Unfortunately I've tried that and it's not working right. So if any of you have ever had to do this and have a few lines of C code to post, I'd appreciate it. -- Thanks, M.Biswas Mohun Biswas wrote: > > Can anyone ...

32 bit Matlab install on 64 bit linux -- missing 32 bit libXp.so.6 library?
I'm trying to install 32 bit Matlab on 64 bit linux I have seen the Technical Solution <http://www.mathworks.com/support/solutions/data/1-O7POO.html?1-O7POO> and some notes for fixing this problem on Fedora <http://forums.fedoraforum.org/archive/index.php/t-106502.html> However, I'm running Ubuntu 2.6.12-9-amd64-generic, and neither of these takes me all the way to a solution. I'm at the point where I can run the installer with the following: root@lanczos:/usr/local/matlab71_sv# /usr/local/install/install_unix.sh -glnx86 -t -nocp /usr/local/install/unix/install...

reading binary data from a 32 bit machine on 64 bit machine
Hi I am very confused with the use of the struct module to read binary data from a file. ( I have only worked with ascii files so far) I have a file spec for a Data-logger (http://www.dataq.com/support/ techinfo/ff.htm) I am collecting some voltage , time traces on one channel and they are written to the binary file on a 32 bit windows machine The file spec says that the number of header bytes in the data file header is stored as a 16 bit eye "I" at bits 6-7 Now I want to get at that number. When I try format !h I get a meaningful number If f is my file handle opened with "...

Reading binary file generated from 32-bit machine using 64-bit machine
Hi all, I am sorry if i come up with elementary question but i spend two days trying to figure out how to read a binary file generated by gfortran on a 32 bit i386 machine using a 64 bit x86_64 machine. i tried to use the flag -frecord-marker=4 to change the default from 8 to 4 bytes on 64 bits machine. However, this still doesn't seem to work. I just can't read the binary file despite so many different trial. Can you please help me what to do? Thanks all, Yonas On 2007-11-25, yonas_kassa@hotmail.com <yonas_kassa@hotmail.com> wrote: > I am sorry if i come up with elementa...

Advanced Compiler Request: 8 bit, 16 bit, 32 bit, 64 bit code path/instruction generation and selection !
Hello, It would be very handy if Delphi could somehow generate code paths for 8 bit, 16 bit, 32 bit and 64 bit integers and possible even structures etc. So maybe with some compiler magic multiple instruction code paths can be generated AND SELECTED based on a "code path selection" variable. Here some ideas: Idea 1: Delphi could introduce a new "code path selection type" TcodePathSelection = ( cps_8_bit, cps_16_bit, cps_32_bit, cps_64_bit ); // the Delphi programmers can then use: var vCodePathSelection : TcodePathSelection; // Then somehow the Delphi program...

32 bit or 64 bit Oracle on 64 bit OS?
Hello, Currently our environment is on 10g Release 2, OS windows 2000/2003 standard edition 32 bit. We use shared server to take advantage of scalability and connecting maximum no of simultaneous connections to the database. Now we take advantage of memory beyond 4GB we are planning to check following. 64 bit Windows 2003 standard edition on AMD64/EM64T Servers. Do we need to install 64 bit Oracle as well? Do we need to reinstall Oracle clients with 64 bit installable if Oracle Server is upgraded to 64 bit? Is 32 bit Oracle is certified on 64 bit OS? Do we need to take care of any other ...

64-bit / 32-bit compilation
Hi Everyone, Many a times, while trying to compile software from source, I face the situation where the 32-bit based code tries to access a 64-bit library of 64-bit executable. In such a situation, I get an "Wrong ELF class" error. Is there anyway I can compile that 64-bit library or executable so that my 32-bit code can also use it. Is this what is known as cross- compilation? My environment is: Solaris 10 5/08 s10x_u5wos_10 X86. CC: Sun C++ 5.8 Patch 121018-15 2008/05/14 GNU Make 3.81 ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.489 Thanks & Regards, dot...

What is the difference between 32 and 64 bit Python on Windows 7 64 bit?
--001a11c22568ee6c3a04f91a5298 Content-Type: text/plain; charset=UTF-8 Hi, I want to install Python on a PC with 16GB of RAM and the 64 bit version of Windows 7. I want Python to be able to use as much as possible of the RAM. When I install the 64 bit version of Python I find that sys.maxint == 2**31 - 1 Whereas the Pythpon installed on my 64 bit linux system returns sys.maxint == 2**63 - 1. It looks to me as though 32 and 64 bit versions of Python on 64 bit Windows are both really 32 bit Python, differing only in how they interact with Windows. So I wouldn't expect ...

Progress with 32-bit compiles with 64-bit compiler and related GLADE issues
Hi all! Progress so far... I have been using the x86_64 GNAT, version 4.1.0 to compile 32-bit and 64-bit code. (I'm on Fedora Core 5 at the moment!) The "-m32" option didn't work for GNAT without a bit of messing around. First I had to install a 32-bit libgnat.a, but that didn't work until I put in a link from libgnat-4.1.a into /usr/lib (it should get it from a separate x86_64-redhat-linux/4.1.0/32 directory, but doesn't. Running "gnatmake -m32 ..." now builds working 32-bit executables, but I am left with the warning: /usr/bin/ld: skipping incompati...

How to tell if a program compiled as 32-bit or 64-bit? (Windows Vista 64)
I think I have finally gotten my Visual C++ Express 2008 to use the 64-bit compiler in the Windows 7 SDK. I THINK! But I want to make sure. I've compiled some programs with the 'target platform' set to x64 in VC Express, but how do I tell if they really compiled into AMD64 code? Thanks, Roy "Bad Roy" <AlaBadRoy@yahoo.com> wrote in message news:e1t5e51mvn3hd721l4or8l1qr2vjiff069@4ax.com... > I think I have finally gotten my Visual C++ Express 2008 to > use the 64-bit compiler in the Windows 7 SDK. I THINK! But I want to > make sure. I've co...

shared library in 32 bit and 64 bit
I was loading something on 32 bit and 64 bit platform. There are some shared libraries loaded for 32 bit are different from those loaded on 64 bit platform. My question is are shared libraries platform dependent. And why there is mismatch in the .so being loaded for 32 bit and 64 bit platform. Thanks. sandeep.gond@gmail.com wrote: > I was loading something on 32 bit and 64 bit platform. > There are some shared libraries loaded for 32 bit are different from > those loaded on 64 bit platform. > My question is are shared libraries platform dependent. > And why there is mismatch ...

Compile to 64-bit on 32-bit OS
Apparently my Mac Mini will run 64-bit code transparently even thought I'm on a 32-bit OS. What I want to know is, how can I compile my code to 64-bit? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?u In article <13l2sktancigaa7@corp.supernews.com>, Jon Harrop <usenet@jdh30.plus.com> wrote: > Apparently my Mac Mini will run 64-bit code transparently even thought I'm > on a 32-bit OS. What I want to know is, how can I compile my code to > 64-bit? You get Intel's Just released C++ Compiler Update with the newer 64bi...

Compiling 32 bit on a 64 bit system
Hi, a small local team of our engineers developts their own applications. They need to compile applications in 32 bit,using their own 32 bit libs, on this new system they have... which is 64 bit. Is there any help available on using a 64 bit gcc to compile in 32 bit? -- Any time things appear to be going better, you have overlooked something. Rikishi42 <skunkworks@rikishi42.net> writes: > Hi, > a small local team of our engineers developts their own applications. > > They need to compile applications in 32 bit,using their own 32 bit libs, on ...

32 bits *.dll for 64 bits compiling
Hello, I use 64 bits AIX 5.3 and all programs compiled on it are compiled as 64 bits mode using xlC and I've got a *.dll library which is 32 bits mode. Is it possible to use this dll library compiling it in 64 bit mode? In other way I want to use this library adding it to code, which is compiled in 64 bits mode (xlC -q64 ...). Have any idea how to do this or maybe it is no possible? Tom tomej@tlen.pl wrote: > I use 64 bits AIX 5.3 and all programs compiled on it are compiled as > 64 bits mode using xlC and I've got a *.dll library which is 32 bits > mode. Is it possible t...

installing both 32-bit and 64-bit libraries
I have RedHat EL smp x86_64 system, and now I want to additionally install the 32-bit version of the xorg-x11-libs for some programs that are expecting the file /usr/X11R6/lib/libXpm.so.4 to exist. (I have the 64-bit version in the lib64 subdirectory and I don't think there will be any conflict problem.) Is there an up2date incantation that will get me the 32-bit libraries? I think the answer is: up2date <whatever> --arch=i386 ...

32 bit dll to 64 bit compilation?
Hi I have a simple com dll build with Visual Studio 6. Now I want it to be compatible on 64 bit OS also. for that what i need to do? On net i found that i need to recompile with 64 bit compiler..but i am sorry for my ignorance...i do not know what does it mean by 64 bit compiler? If i directly build in VS .net then will it work? or do i need to change some compiler settings? Thanks in advance for your help. regards, Anu anu.mishra@gmail.com wrote: > Hi > I have a simple com dll build with Visual Studio 6. Now I want it to be > compatible on 64 bit OS also. for that w...

Web resources about - 64 bit binary and 32 bit binary have different result. Is it library bug or compiler bug? - comp.unix.solaris

Florench Welch is Pretty in Pink for Grammy Awards 2016
Florence Welch is all about the stars and bows while stepping out at the 2016 Grammy Awards held at the Staples Center on Monday (February 15) ...

At-Risk GOP Senators Back Party on Court Nomination
Most Republican senators facing tough re-election races support Majority Leader Mitch McConnell’s call to hold off on confirming a Supreme Court ...

'Just Nuts': The Death of Scalia and the Insanity of Saturday's SC GOP Debate: 'BradCast' 2/15/2016
As you may suspect, it's a very busy program on today's BradCast for some reason. Heather Digby Parton of Salon and Digby's Hullabaloo and Joshua ...

Kanye West Says New Album Will 'Never' Be Available Through Apple Music
Kanye West's latest album, "The Life of Pablo," is available exclusively on Tidal , the Apple Music rival service created by Jay Z. According ...

Former Russian Anti-Doping Chief Dead At 52
Nikita Kamayev, the former head of the Russian anti-doping agency RUSADA, died on Monday at the age of 52. “Presumably, the cause of death was ...

This New ‘Games of Thrones’ Teaser Might Dash Your Hopes About Jon Snow’s Fate – WATCH
A new trailer for season 6 of HBO’s Game of Thrones could dash some theories circulating about the fate of fan favorite Jon Snow (Kit Harrington). ...

You can now watch Hulu on your Windows 10 device
You could always watch Hulu on your PC or Mac, or for that matter, on multiple other mobile devices. Now the streaming service wants to integrate ...

Honor 7 In Europe To Receive Marshmallow Update
Better late than never is the mantra to go when it comes to receiving software updates for your mobile devices, and when it comes to Huawei’s ...

Star Wars Episode VIII teaser launched after first day of shooting
For those who've not yet seen Star Wars: Episode VII – The Force Awakens , spoilers will follow. We've seen teaser trailers for teasers trailers ...

Kids Are Never Safe on The Walking Dead
Some people died in the midseason premiere of The Walking Dead. Read more...

Resources last updated: 2/16/2016 1:23:40 AM