Lazarus

Free Pascal => Beginners => Topic started by: JLWest on September 04, 2019, 12:05:15 am

Title: Disk Full Message Possible BUG
Post by: JLWest on September 04, 2019, 12:05:15 am
I'm trying to write a file out and I get a message

X Disk Full
   
     Press OK to Ignore and risk data corruption.
     Press Abort to kill program.

No matter what I press the program appears locked.

 Explorer say I have 950 GB free out of 953 GB.

Willing to post data and program

Thanks



 
Title: Re: Disk Full Message Possible BUG
Post by: winni on September 04, 2019, 12:25:08 am
Just gor test reasons if your SDD has gone wild:

Close Lazarus. Open Gimp/Photoshop/whatever. Open a big image. Save it with a new name. And now: Any problems?

Otherwise you might have a problem in your code.

Winni
Title: Re: Disk Full Message Possible BUG
Post by: JLWest on September 04, 2019, 12:29:58 am
Just gor test reasons if your SDD has gone wild:

Close Lazarus. Open Gimp/Photoshop/whatever. Open a big image. Save it with a new name. And now: Any problems?

Otherwise you might have a problem in your code.

Winni

Say What? "Open a big image. Save it with a new name."   Save What?

It's Not a Code Problem.

I re-booted the system, Wrote to different drive.
Worked fine.

 


Title: Re: Disk Full Message Possible BUG
Post by: winni on September 04, 2019, 12:59:35 am
Ahh - one of those reboot Operating Systems.
Title: Re: Disk Full Message Possible BUG
Post by: jamie on September 04, 2019, 01:09:03 am
maybe you wrote to a write protected drive?

Also if memory serves at one time there are some folders on the user system in windows that has a limited size set to them, it's possible you hit the limit but I am guessing this isn't the case.

 The message you are getting sounds very suspicious, please show us minimum code where you are doing the file open and writing attempts.


Title: Re: Disk Full Message Possible BUG
Post by: JLWest on September 04, 2019, 05:55:06 am
maybe you wrote to a write protected drive?

Also if memory serves at one time there are some folders on the user system in windows that has a limited size set to them, it's possible you hit the limit but I am guessing this isn't the case.

 The message you are getting sounds very suspicious, please show us minimum code where you are doing the file open and writing attempts.

Code: Pascal  [Select]
  1. procedure TForm1.SaveMstData(AFILENAME : String);
  2.  Var i : integer = -1;
  3.   OutFile  : Textfile;
  4.   Line     : String = '';
  5.   Bit1     : String = '';
  6.   Bit2     : String = 'BDX0.txt';
  7.   FileName : String = '';
  8.  begin
  9.   ListBox5.ItemIndex := 0;
  10.   LevelUpperBoxes(0);
  11.   Bit1 := AFileName;
  12.   FileName := C_BasePath + Bit2;
  13.   if OneDirectory then begin FileName := LOC + Bit2; end;
  14.   AssignFile(OutFile, FILENAME);
  15.  Try
  16.   Rewrite(OutFile);
  17.   for i := 0 to High(Data) do begin
  18.       SetLine(i);
  19.       if SLOW then begin Application.ProcessMessages; end;
  20.       Line := GetLine;
  21.       if SLOW then begin Application.ProcessMessages; end;
  22.       WriteLn (Outfile,Line);
  23.       if SLOW then begin Application.ProcessMessages; end;
  24.    end;
  25.    finally
  26.     CloseFile(OutFile);
  27.   end;
  28.    ListBox5.ItemIndex := 0;
  29.    LevelUpperBoxes(0);
  30.  end;
  31.  
  32. procedure TForm1.SetLine(AINDEX : Integer);
  33.   begin
  34.    Edit5.Text  := Data[AINDEX].IATACode;
  35.    Edit4.Text  := Data[AINDEX].ICAO;
  36.    Edit6.Text  := Data[AINDEX].FAACode;
  37.    Edit7.Text  := Data[AINDEX].Region;
  38.    Edit8.Text  := Data[AINDEX].Name;
  39.    Edit9.Text  := Data[AINDEX].City;
  40.    Edit20.Text := Data[AINDEX].State;
  41.    Edit10.Text := Data[AINDEX].Country;
  42.    Edit11.Text := Data[AINDEX].Lat;
  43.    Edit12.Text := Data[AINDEX].Lon;
  44.   end;      

May look odd but the data I'm trying to write to disk is in a Dynamic Array of records. And I want it to look like this:

"|1CA|Nil|Nil|K2|Rio Vista Municipal|Rio Vista|CA|United States|38.19333333|-121.70361111| "

Because this performs IO to the screen I have a global Boolean VAR SLOW : Boolean = False; set. Therefore, Application.ProcessMessages; can be turned off.


Title: Re: Disk Full Message Possible BUG
Post by: Zvoni on September 04, 2019, 09:18:08 am
What's the Value of "FileName" in your Line 14?
Because right now i can't make heads or tails from your code in Line 12 and Line 13
In Line 12, you construct your local var "FileName" from something called "C-BasePath" and "Bit2" (which you seem to use as a constant).
What's C_BasePath (Yes, i can guess what it is!)?
In the next Line you check a (boolean)-Variable from somewhere, and if True, you overwrite the Value in "FileName" with something called "LOC" and Bit2 again.
Title: Re: Disk Full Message Possible BUG
Post by: Bart on September 04, 2019, 10:18:21 am
Can you verify that Filename is what you expect it to be?
Put a ShowMessage('Filename="'+Filename+'"') in your code, just before the call to AssignFile.
IIRC DiskFull errors sometimes get raised on filenames windows cannot digest.

Bart
Title: Re: Disk Full Message Possible BUG
Post by: Zvoni on September 04, 2019, 10:55:34 am
Can you verify that Filename is what you expect it to be?
Put a ShowMessage('Filename="'+Filename+'"') in your code, just before the call to AssignFile.
IIRC DiskFull errors sometimes get raised on filenames windows cannot digest.

Bart
Exactly my thoughts.
Another suspicion i have is that thing with C_BasePath+SomeThing: looks like the C-Rootfolder, and that's a big no no
Title: Re: Disk Full Message Possible BUG
Post by: jamie on September 04, 2019, 04:20:43 pm
Prior to Assigning the file name do this..

Assert(DirectoryExists(FileName),'Oops, don't see directory '+FILENAME);

and turn on Asserts in your debugging panel for project options.
Title: Re: Disk Full Message Possible BUG
Post by: JLWest on September 05, 2019, 09:51:19 pm
What's the Value of "FileName" in your Line 14?
Because right now i can't make heads or tails from your code in Line 12 and Line 13
In Line 12, you construct your local var "FileName" from something called "C-BasePath" and "Bit2" (which you seem to use as a constant).
What's C_BasePath (Yes, i can guess what it is!)?
In the next Line you check a (boolean)-Variable from somewhere, and if True, you overwrite the Value in "FileName" with something called "LOC" and Bit2 again.

Heads or Tails;
    Var
Line 6    Bit2     : String = 'BDX0.txt';

Line 9    ListBox5.ItemIndex := 0;             <-- Setting focus
Line 10  LevelUpperBoxes(0);                    <-- procedure which  set focus on 9 other listboxes
Line 11  Bit1 := AFileName;                       <-- Contains AFILENAME (Passed to the Write proc
Line 12  FileName := C_BasePath + Bit2;    <-- Explained below
Line 13  if OneDirectory then begin FileName := LOC + Bit2; end;  <-- Explained below
Line 14  AssignFile(OutFile, FILENAME);                                        <-- Explained below

 
I work with really large files, 8,9 and 11 million lines of Text files.

I keep all of these files on X:\FAAFiles\ . Which is declared:
Const  C_BasePath = 'X:\FAAFiles\';
In FormCreate I do a LOC := Application.Location;

So the procedure is called:

 SaveMstData('BDX0.txt');

 Bit1 := 'BDX0.txt';
 FileName := C_BasePath + Bit2; So  FileName = 'X:\FAAFiles\BDX0.txt' <--Normal file path

I have a GLOBAL software switch called OneDirectory : Boolean = False;

if OneDirectory is set to false the FileName at  Line 13  in the AssignFile(OutFile, FILENAME); will be  'X:\FAAFiles\BDX0.txt'.

if OneDirectory is set to True then the FILENAME at  Line 13  in the AssignFile(OutFile, FILENAME) will be 'D:\CurrentProject\ BDX0.txt';

I have this in all my read and write procedures for two reasons.

I can set up test data, throw the switch to True and work with a different set of data. And I do this where my program executable is loaded.

If I'm asked to post  a program, I can set the switch to True, zip the program and data and post. Whoever looks at it can build and run all in on directory. When there done delete the directory.

Hope this answer your questions.   
Title: Re: Disk Full Message Possible BUG
Post by: JLWest on September 05, 2019, 10:01:41 pm
Can you verify that Filename is what you expect it to be?
Put a ShowMessage('Filename="'+Filename+'"') in your code, just before the call to AssignFile.
IIRC DiskFull errors sometimes get raised on filenames windows cannot digest.

Bart

I think so Bart. I ran it under the Debugger and it was correctly set.

When I got the disk full message I was running the program in normal mode. I then ran it under the debugger and got the same message.

Filename was correctly set.

So I set the ONEDIRECTORY switch to true and wrote to another drive just fine. Turned off the ONEDIRECTORY  switch, Disk Full.

Rebooted the computer and everything seems to work, can't reproduce the problem now. So I don't know if it's Windows 10 Pro, my Intel SSD Drive or Free Pascal problem.

Title: Re: Disk Full Message Possible BUG
Post by: jamie on September 05, 2019, 10:06:24 pm
Back in older times, drive "X" was an invalid drive.

For example using the GetDir.

I don't know where it is these days
Title: Re: Disk Full Message Possible BUG
Post by: PascalDragon on September 09, 2019, 11:39:44 am
Back in older times, drive "X" was an invalid drive.
Since at least Windows NT that isn't the case anymore.
Title: Re: Disk Full Message Possible BUG
Post by: Zvoni on September 09, 2019, 12:04:04 pm
Can you verify that Filename is what you expect it to be?
Put a ShowMessage('Filename="'+Filename+'"') in your code, just before the call to AssignFile.
IIRC DiskFull errors sometimes get raised on filenames windows cannot digest.

Bart

I think so Bart. I ran it under the Debugger and it was correctly set.

When I got the disk full message I was running the program in normal mode. I then ran it under the debugger and got the same message.

Filename was correctly set.

So I set the ONEDIRECTORY switch to true and wrote to another drive just fine. Turned off the ONEDIRECTORY  switch, Disk Full.

Rebooted the computer and everything seems to work, can't reproduce the problem now. So I don't know if it's Windows 10 Pro, my Intel SSD Drive or Free Pascal problem.
Your drive 'X', is that an external Drive?
Title: Re: Disk Full Message Possible BUG
Post by: JLWest on September 10, 2019, 06:15:14 pm
The  X: drive is a 950 GB INTEL SSD drive.
Title: Re: Disk Full Message Possible BUG
Post by: Zvoni on September 10, 2019, 09:05:21 pm
That wasn't my question......
Is your X-Drive an EXTERNAL drive a.k.a plugged in your USB-Port?
Title: Re: Disk Full Message Possible BUG
Post by: JLWest on September 11, 2019, 03:56:36 pm
No It is inside my computer.
Title: Re: Disk Full Message Possible BUG
Post by: Zvoni on September 11, 2019, 04:04:19 pm
Have you tried a different Drive-Letter?
Title: Re: Disk Full Message Possible BUG (NOT Solved but Closed)
Post by: JLWest on September 11, 2019, 11:42:12 pm
At the time I tried a different drive. And it Worked. After I rebooted the system it hasn't happened again.

I should probly make this closed.
Title: Re: Disk Full Message Possible BUG
Post by: Zvoni on September 13, 2019, 12:35:04 pm
A different Drive (really a different, physical, Harddrive) or a different driveletter?
Title: Re: Disk Full Message Possible BUG
Post by: JLWest on September 13, 2019, 03:51:39 pm
A different drive.  I did not change the drive letter X: