1.5.5-1: problem with read() on Athlon MP in WinXP

Jeff Gilchrist jsgilchrist@hotmail.com
Tue Dec 9 19:09:00 GMT 2003


I have a very strange problem using the 1.5.5-1 cygwin so I wanted to post 
the information in case someone has seen this before on another system.

I have a simple C program that reads in a file using the read() function, 
then outputs the data to stdout so if you redirect stdout to a file, the end 
result is that you have made a copy of the original.  For some reason on 
certain files, it does not work on one of my systems.  I will attach the .c 
code that I used.  I also changed the malloc()/free to a new/delete and 
compiled with g++ to see if it made a difference but I get the same result.

The problem is that even though I ask read() to read in enough bytes to get 
the entire file, the function will always return that it read in one byte 
less than what I requested.  If I ask to read 100 bytes in a 1000 byte file, 
it will return that it read 99 bytes.  If I ask it to read 1000 bytes from 
the same 1000 byte file, it will return that it read 999 bytes, etc...
In my case, the test file I am working with is 99931 bytes long and read() 
returns that it read 99930 bytes.  If I then output that buffer to stdout, 
printing one character at a time to stdout, it will for some reason print 
out 100139 bytes instead of 99931 bytes (so an extra 208 bytes).  Looking at 
the stream, the extra 208 bytes are repeated from the last 208 bytes of the 
file and a few other characters throughout are different so the buffer is 
obviously getting corrupted somehow.

I tried compiling with several different gcc switches to see if it made a 
difference but I get the same result every time.  I used:
gcc test.c -o test
gcc -O3 test.c -o test
gcc -g test.c -o test

The system I am running this on is a dual processor AMD Athlon MP-2600+ 
machine with 1GB of RAM on Windows XP Pro (with all security patches).

Now it gets even stranger.  Taking two other machines a P4-1.8GHz running 
Win2k and a P4-1.4GHZ also running Win2k, the program will compile and run 
just fine with the exact same cygwin install (I used the same files to 
install cygwin on all 3 machines).  The program works as expected on these 
single processor P4 machines.  I can take the program compiled on the Athlon 
and run it on the P4 and it works fine.  I can take the program compiled no 
the P4 but when I run it on the Athlon it behaves the exact same way as 
listed above, it does not output the correct data.

So it seems that cygwin on my Athlon is compiling the C code fine because I 
can run it without any problems on my P4/Win2k boxes.  The only time I have 
had problems is when I run it on the Athlon.

So are we seeing a cygwin problem with the Athlon processor? Is it a 
dual-processor problem?  Is it a WinXP problem?   Since it seems the 
memory/buffer gets corrupted I ran memtest86 and the GIMPS torture test on 
my Athlon machine but both checked out ok.  I haven't had any other problems 
with software not working properly or things getting corrupted.  The cygwin 
tools that get bundled seem to work fine (ie: bzip2) so I really don't know 
what is going on.  Any ideas?

If you need more info, let me know and I will provide.

Thanks in advance,
Jeff.

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*   
http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: application/octet-stream
Size: 660 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20031209/208f7046/attachment.obj>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list