Bug 982235 - C++ compiler has pointer control problems. Related to Bug ID 972876
C++ compiler has pointer control problems. Related to Bug ID 972876
Status: CLOSED INSUFFICIENT_DATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc (Show other bugs)
6.3
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Jakub Jelinek
qe-baseos-tools
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-08 08:44 EDT by David Comeau
Modified: 2013-07-08 09:02 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-08 09:02:27 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Comeau 2013-07-08 08:44:43 EDT
Description of problem:When I started writing this program, unexpected results were encountered.


Version-Release number of selected component (if applicable):
gcc version 4.4.6 (RedHat Version 4.4.6-4)
gnu make (version 3.81)

How reproducible:Very


Steps to Reproduce:
Running RedHat 6.* C++ Compiler, problems are encountered.
The following Program segments will best describe the problems I am having.
-----------------------------------------------------------------
The Data Buffer is declared as fillows:
--------------------------------------
// ----- Start Data Constants. -----
char  F2PastName[12];        // Used for Ticker ID Compare.
char  StockPrice[80];
char  FName[80];             // Input Floppy File Name.
char  F1Name[80];
char  F2Name[80];
char  DataIn[80];            // Input Data Buffer.
char  Junk[100];             // Junk or Pause Bucket.
unsigned char  DBuff[2];     // Floppy Read Buffer.
unsigned char  I_Buff[2000000];  
// ------------------------------------------------------

The Program is executed as follows; (void main() )
------------------------------
int main()
  {
  d=1;                       // Debug Code
  Dp = 0;                    // Data Pointer set to Start.
  Eq = 0;
  cout << "Start Yahoo File Import Program." << endl;
  cout << endl;
  cout << "OutPut Size Imp=" << sizeof(Imp) << endl;
  cout << endl;
  cout << "This is Program 1 of 2 to Import Data from Yahoo." << endl;
  cout << endl;
  // -------------------------------------------------
  for(i=0;i<80;i++)  {DataIn[i]=' ';}
  cout << "Do you want to Continue. (Y or N)" << endl;
  gets(DataIn);
  UpperCase();
  if(DataIn[0]=='N')  {return 0;}
  // ------------------------------------------------
  GetFileName();
  BuildFileName();
  F2OpenYahoo(); 
  // ------------------------------------------------
  F2LoadBig();               // All the InPut Data is Loaded.
  // ------------------------------------------------  
  for(i=0;i<12;i++)  {F2PastName[i] = ' ';}
  // -- PreScan Input Data. --
  PreScan();
---------------------------------------------------------------

The I/O Function to load the Buffer is:
----------------------------------------
void F2LoadBig()
  {
  fread(&I_Buff, sizeof(I_Buff), 1, fp2);
  }

The single Read is executed to read the file down loaded from Yahoo.
The following is a snipit of the Data that was loaded.
The Data checks out, no problems were encountered.
------------------------------------------------------
"A",40.94,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"AA",8.68,"12/31/2012","4:02pm",0.00,N/A,N/A,N/A,1450
"AAMRQ",0.795,"12/31/2012","3:59pm",0.00,N/A,N/A,N/A,0
"AAN",28.28,"12/31/2012","4:02pm",0.00,N/A,N/A,N/A,0
"AAON",20.87,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"AAP",72.35,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"AAPL",532.1729,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,23717
"AAV",3.24,"12/31/2012","4:02pm",0.00,N/A,N/A,N/A,0
"AAWW",44.32,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"AB",17.43,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABAX",37.10,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABB",20.79,"12/31/2012","4:05pm",0.00,N/A,N/A,N/A,0
"ABC",43.18,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABCO",46.79,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABIO",0.38,"12/31/2012","3:58pm",0.00,N/A,N/A,N/A,0
"ABM",19.95,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABMD",13.44,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABR",5.99,"12/31/2012","4:01pm",0.00,N/A,N/A,N/A,0
"ABT",65.50,"12/31/2012","4:05pm",0.00,N/A,N/A,N/A,0
"ABV",41.99,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABX",35.01,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ABX.TO",34.82,"12/31/2012","4:00pm",0.00,33.88,34.91,33.83,2198554
"ACAD",4.65,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ACAS",12.0205,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ACAT",33.39,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ACE",79.80,"12/31/2012","4:01pm",0.00,N/A,N/A,N/A,0
"ACFC",2.01,"12/31/2012","3:58pm",0.00,N/A,N/A,N/A,0
"ACG",8.10,"12/31/2012","4:04pm",0.00,N/A,N/A,N/A,0
"ACH",11.91,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ACHN",8.01,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ACI",7.32,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ACIW",43.69,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0
"ACM",23.80,"12/31/2012","4:04pm",0.00,N/A,N/A,N/A,0
"ACN",66.50,"12/31/2012","4:00pm",0.00,N/A,N/A,N/A,0

The (") character is the 1st character in the buffer that was loaded.
After that singe I/O, NO Other Read's were executed.

-----------------------------------------------------------------

When the Program is Executed in Terminal Mode; 
This Output was captured and illustrates my problem.
--------------------------------------------------------------------------
Start Yahoo File Import Program.

OutPut Size Imp=109

This is Program 1 of 2 to Import Data from Yahoo.

Do you want to Continue. (Y or N)
Input File Name to Import.
For Example, you can use - 
01JAN09.csv
File Name = 01JAN13.csv
Stock =>A           <
Stock =>AAMRQ       <
Stock =>AAP         <
Stock =>AAWW        <
Stock =>ABB         <
Stock =>ABIO        <
Stock =>ABR         <
L-213 The 1st Character is not a Quote
L-214 The abs Character is 65
L-215 The Character is A
Read Pointer = 1139
0-P=1139 - D=A
1-P=1141 - D=0
2-P=1142 - D=
3-P=1143 - D=

4-P=1144 - D="
5-P=1145 - D=A
6-P=1146 - D=B
7-P=1147 - D=X
8-P=1148 - D=.
9-P=1149 - D=T
10-P=1150 - D=O
11-P=1151 - D="
12-P=1152 - D=,
13-P=1153 - D=3
14-P=1154 - D=4
15-P=1155 - D=.
16-P=1156 - D=8
17-P=1157 - D=2
18-P=1158 - D=,
19-P=1159 - D="
20-P=1160 - D=1
Pause - Enter to Continue.
Pause - Before Abort. Enter to Continue.
-----------------------------------------------------------------------------

The end of this program has the error condition detected, and a SubRoutine
called "F2SnapShot();", and it's displayed here.  I wrote this routine to
help debug my software.

// -----------------------------------------------------------------------------
void F2SnapShot()
  {
  cout << "0-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1;
  // -----------------------------------------------------
  Dp = Dp +1; 
  cout << "1-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "2-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "3-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "4-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "5-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "6-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "7-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "8-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "9-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "10-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "11-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "12-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "13-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "14-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "15-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "16-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "17-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "18-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "19-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  Dp = Dp +1; 
  cout << "20-P=" << Dp << " - D=" << I_Buff[Dp] << endl;
  cout << "Pause - Enter to Continue." << endl;
  gets(Junk);
  }
// -----------------------------------------------------

At first the program will execute 7 passes in the software, error free.
Then for reasons unknown, the [Dp] pointer starts reflecting 
rather large numbers.

The moment this error occures, the [Dp] pointer has a value of 1139.
If you count the sharacters in the Buffer, this number is really out of line.

Then I did the Build and Make of this program, no errors were reported.
For the first few inerations of this process, all is well.

Then for some reason, the [Dp] Pointer becomes unreliable.

Does this look like a bug????

David Comeau  (Looking for an answer). 
----------------------------------------------------------------------------


Actual results:I executed a screen capture, results are posted above.


Expected results:I expected the pointer to be incremently increased to facilitate sequential reading of the file.  My program will verify every
comma, quotation mark and all the data fields.


Additional info:I tried to purchase a "Commercial Type or Copy" of the 
GNU C++ Compiler.  I was told that it was allready available in Red Hat 6 
Enterprize Server.  
If this not the case, I am still willing to purchase a copy.
Comment 2 Jakub Jelinek 2013-07-08 09:02:27 EDT
As you haven't provided a self-contained testcase, this is impossible to analyze, and there is no reason to believe there is a compiler bug involved, much more likely there is some bug in your program.
You need to analyze/debug your program yourself, ask on C++ forums etc., try some code analyzers (e.g. valgrind, -fsanitize=address (the latter is available e.g. from Red Hat Developer Toolset) and only if you after that still suspect a compiler bug, you need to provide a very small self-contained testcase and explain why exactly you think there is a compiler bug.  The above random uncompilable code-snippets are nowhere close to that.

Note You need to log in before you can comment on or make changes to this bug.