Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Issues of 64-bit code in real applications: and what about Linux?

, 12 Oct 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Today’s post is about a 64-bit error in the Linux kernel

While telling programmers about 64-bit issues they may encounter when porting their programs, I often hear reproaches: “Yes, surely - such is your Windows… How good it is that Linux has had no problems with 64-bit code for a long time!”.

“It is not so, my inquisitive readers”. Today’s post is about a 64-bit error in the Linux kernel. A wonderful site with bug tracking system by the kernel’s developers contains the description of bug 16603 (send of data > 4 GB fails on 64 bit systems). The issue is simple: “Send of data using the Linux-function send() leads to an error if the data’s size is too large”. This is how the function looks like in glibc:

ssize_t send(int sockfd, const void *buf, size_t len, int flags);

Everything is correct and the size is passed as a memsize-type size_t. But this argument is saved in the msgheader structure and after that, there are the following lines inside the tcp_sendmsg function:

while (--iovlen >= 0) {
                int seglen = iov->iov_len;
                unsigned char __user *from = iov->iov_base;

Here, the length is saved in int and it is certainly a bad thing. That is, if you send a block of 5 Gbytes using send(), only 1 Gbyte will be sent while sending a 4-Gbyte block will have no result (due to truncation to zero).

Of course, the workaround is clear - we should specify length not larger than 0×8000000, but it is an error and of course we should fix it.

Yes, by the way, it is not a sample from the nineties - the bug was discovered in August, 2010, and refers to the kernel of version 2.5. And it is still (October 11, 2010) not fixed. And you tell me that Linux does not have 64-bit issues…

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

viva64.com

Russian Federation Russian Federation

We develop the PVS-Studio static code analyzer for C/C++/C++11.

PVS-Studio is a static code analyzer for C/C++ (Visual Studio 2005/2008/2010) with a simple licensing and pricing policies which is easy to install and use without need to deploy a complex maintenance environment.

Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 1 PinmemberkLeZ-hAcK19-Oct-10 2:10 
GeneralMy vote of 5 Pinmemberbuyong13-Oct-10 15:16 
GeneralRe: My vote of 5 PinmemberkLeZ-hAcK19-Oct-10 2:12 
GeneralRe: My vote of 5 PinmemberEvgeniy Ryzhkov19-Oct-10 2:19 
GeneralRe: My vote of 5 PinmemberkLeZ-hAcK19-Oct-10 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141030.1 | Last Updated 12 Oct 2010
Article Copyright 2010 by viva64.com
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid