Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Dialogs/Project Options    [ Add a report in this area ]  
Report #:  55183   Status: Closed
compiling with optimize option causes an error while running the exe
Project:  Delphi Build #:  11.0.2804.9245
Version:    11.1 Submitted By:   Reinhart Vollmer
Report Type:  Crash / Data loss / Total failure Date Reported:  11/23/2007 1:52:44 AM
Severity:    Serious / Highly visible problem Last Updated: 12/21/2007 12:38:20 AM
Platform:    All versions Internal Tracking #:  
Resolution: Test Case Error (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
see Steps
Steps to Reproduce:
1. compiling the project with compiler option 'optimize' = true: causes an error while clicking on a certain button while the program runs.
2. compiling the project without optimizing: The program runs without error.

The error occurs in the following function:

function TFHauptfenster.GetAktBereich: integer;
begin
Result := AktBereich;
end;

This function works some times before without errors (Aktbereich = 21). In the case the error occurs, the (private declared) variable AktBereich (which is not changed by the program in the meantime) seems to be unassigned (value > than the integer range, see attachment: screenshot).
Workarounds
None
Attachment
Screenshot.zip
Comments

Andreas Hausladen at 11/24/2007 2:00:20 AM -
This sounds more like a bug in your application where released or overwritten memory is accessed. Such bugs will appear at other locations. With Optimizations Off this bug might be go unseen because in this moment the memory is organized in a way that does not cause the error.

What is the exact error message?
Can you upload a small example application that reproduces this bug?

Reinhart Vollmer at 11/27/2007 1:00:27 AM -
The variable 'AktBereich' , declared private in a TForm-component, is assigned an only one time:

procedure TFHauptfenster.Filtern(const BE, Bereich: integer; const Abteilung: string);
var

Vertretung: boolean;
begin
AktBereich := Bereich;
...
end;

Running the program inside the ide, an acces violation is shown. Runnung the program outside the Ide, the program exits without any error message.
I do not believe that it is a bug in my application. Compiled in D7, the code runs without errors - even if it is optimized.

Reinhart Vollmer at 12/3/2007 12:25:09 AM -
I'am sorry! Maybe I did not locate the error correctly previously. Now I found that the access violation occurs immediately after clicking a button which should do some actions without closing the window - but the access violation occurs before the 'begin'-statement of this method. This is the reason that I cannot debug the error.

This is the code which causes the error:

procedure TFKonfig.BtnUebernehmenClick(Sender: TObject);
   begin  // In this line is set a breakpoint; but it gets not reached. The access violation occurs immediately after clicking the button
   if FHauptFenster.MDIChildCount > 0 then
      begin
      if MessageDlg(LoadStr(35), mtConfirmation, [mbYes, mbNo], 0) = mrNo then
         begin
         exit;
         end;
     end;
   SetRegistryWerte;
   with FHauptfenster do
     begin
     FHauptfenster.FilterBerechtigungSetzen(GetAktBENr, BENr, GetAktBereich, GetAktAbteilung);
     Filtern(GetAktBENr, GetAktBereich, GetAktAbteilung);
     ListeEinlesen(Sender);
     end;
   BtnUebernehmen.Enabled := false;
   Aenderung := BtnUebernehmen.Enabled;
   end;

Reinhart Vollmer at 12/20/2007 11:07:04 PM -
I found the ultimate cause of the error: a form was released twice under certain conditions. It's not a bug of Delphi.

Server Response from: ETNACODE01