Bug 111596

Summary: cannot write files larger then 2048MB
Product: [Retired] Red Hat Linux Reporter: Need Real Name <yknot>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-03 22:28:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2003-12-05 21:02:30 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5)
Gecko/20031007 Firebird/0.7

Description of problem:
Code that needs to write a large file (greater then 2048) fails.



Version-Release number of selected component (if applicable):
gcc-c++-2.96-113 gcc-2.96-113

How reproducible:
Always

Steps to Reproduce:
1.Compile attached sample code
2.Run code with arg > 2048
3.Code crashes when file size reaches 2048MB

This sample code works fine in RedHat 7.3 with g++ 2.96
    

Actual Results:  Error message

"File size limit exceeded"

File is not written beyond 2048MB

Expected Results:  File of correct size is written 

Additional info:

#define _FILE_OFFSET_BITS 64
#include <iostream>
#include <fstream>
using namespace std;

#include <stdlib.h>

const char* const filename = "HUGEFILE";

int main(int argc, char** argv) {
  if (argc < 2) {
    cerr << "Syntax: " << argv[0] << " <nr_of_mbytes>" << endl;
    return 1;
  }
  int n = atoi(argv[1]);
  ofstream file(filename);
  if (n <= 0) return 0;

  const int BUFSIZE = 1 << 20;
  char* buf = new char[BUFSIZE];
  while (n > 0) {
    file.write(buf, BUFSIZE);
    --n;
    if (n % 64 == 0)
      cerr << n << " MB left, writing to " << filename << endl;
  }
}

Comment 1 Jakub Jelinek 2004-10-03 22:28:09 UTC
Works just fine with gcc-c++-3.4.2-2.