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…


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


About the Author

Comments and Discussions

GeneralMy vote of 1 PinmemberkLeZ-hAcK19-Oct-10 3:10 
GeneralMy vote of 5 Pinmemberbuyong13-Oct-10 16:16 
GeneralRe: My vote of 5 PinmemberkLeZ-hAcK19-Oct-10 3:12 
GeneralRe: My vote of 5 PinmemberEvgeniy Ryzhkov19-Oct-10 3:19 
GeneralRe: My vote of 5 PinmemberkLeZ-hAcK19-Oct-10 3: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
Web03 | 2.8.150414.1 | Last Updated 12 Oct 2010
Article Copyright 2010 by
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid