?
Solved

access violation at address in module ntdll.dll

Posted on 2014-04-03
15
Medium Priority
?
3,153 Views
Last Modified: 2014-04-08
Hi Experts, I got one of these errors during a run of my app while processing a large datafile. Oddly enough, during a similar run with same file 10 minutes prior, this error did not occur and my app ran clean. I rebooted after this error and ran my app again on this same large datafile (5 or 6 times) and the error did not happen again. Should I be concerned about my app, or does it look like just some kind of OS glitch that was cleared up upon reboot?

Also, regarding these "access violation" errors (and similar errors causing crashes), would there happen to be some sort of magical Delphi component that I can add to my project which would output some sort of log file indicating where in my app (source code line number?) the crash occurred?

Thanks
    Shawn
0
Comment
Question by:shawn857
  • 7
  • 5
  • 3
15 Comments
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 1200 total points
ID: 39977317
magic ?
try madExcept from madshi ...  http://www.madshi.net/
or eurekalog ...

both have the capability of producing a stack trace and mailing a bug report when an access violcation happens

after installing madExcept recompile your project
> check next to options in the delphi IDE project  menu for the madexcept options
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39977336
Seem that you have a memory leak - when os is run long enough and a resources are little come out - maybe this error occurre. Maybe possible collision with some other process.

There is EurekaLog:
http://edn.embarcadero.com/article/39115
http://delphi.about.com/od/productreviews/ss/eurekalog.htm
https://www.eurekalog.com/

or madExcept:
http://madshi.net/

... tools/components/unit to help you out.
Personally, think that madExcept is a very good option - and do exactly you want.

How do you access/process large file? Did you access exclusive to other process?

---------

EDITED: seem that I was little late....
0
 

Author Comment

by:shawn857
ID: 39977407
Thanks guys! I already use FastMM4 in my project - would using madExcept as well be okay, or would they "compete" with each other?

Sinisa: I read and process my large data file exclusively. No other process accesses the datafile.

Thanks!
    Shawn
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39977438
You never know who want to access... (virus, anti-virus, fbi... :-)
FastMM is good for memory leak + speed string manipulation, but for exceptions is madExcept. Few times I have problem with FastMM and externall dlls. (both needs FastMM) - use latest version.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 39977533
are you loading the complete (very large) file ?
how ? in a stringlist ?
0
 

Author Comment

by:shawn857
ID: 39980825
Geert: To read in the very large file, I just read one record at a time into a normal string variable, process that record, then read another record in. No stringlist. Very plain vanilla.

Guys: I am trying madExcept and I think it will be what I need to catch exceptions... but when I have it enabled, it seems to slow down quite a lot the process of reading my large datafile. Is this normal?

Thanks
   Shawn
0
 

Author Comment

by:shawn857
ID: 39982287
Geert - update to what I wrote earlier. After more testing, it seems my program runs about 10% slower when madExcept is enabled. Not the end of the world, but strange that it slows it down at all.

Thanks
   Shawn
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 39982305
i never leave it on for long. just initially  to find bugs and av

i don't really have mission critical software
and if something slow, the process gets chopped up and spread across app servers

whenever i need to process large amounts of data
> check if the writer of the large file can create a secondary file with only the items i'm interested in
> check if i can extract the data i need myself

fwiw, there is no point in analyzing a log file
the logfile was written based on processed data > read the processed data instead
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39982307
Maybe you can run faster. How you read file? With Readln or you use allocated memory as buffer? Second one is a right direction.
0
 

Author Comment

by:shawn857
ID: 39982324
Sinisa - I read a file of variable-length text lines (ie. a CSV file), so I think I have to use Readln, no?

Shawn
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39982338
Not necessarily. Read buffer (let say 10k), parse csv and do the job, when you analyze all buffer read another portion and so on until all file is readed. When you detect CRLF chars - you have one record (calculated form previous CRLF).
0
 
LVL 28

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 800 total points
ID: 39982817
I made (not so simple to understand) example (but working :-) using buffered reading:

function TForm1.AnalzyeBuffer(const pText: PChar; const iBufSz: Cardinal;
  var iAnalyzed: Cardinal): Boolean;
const
  DELIMIT_CHAR = ';';
var
  {s,} sFields: String;
  pFieldStart, p: PChar;
  i, iLineLen: Cardinal;
begin
  Result := True; //keep going on
  iAnalyzed := 0;

  if iBufSz > 0  then
  begin
    sFields := '';
    iLineLen := 0;
    pFieldStart := nil; //first

    for i := 0 to (iBufSz-1) do
    begin
      p := PChar(Cardinal(pText) + i);
      Inc(iLineLen);

      //find next delimiter char
      if (p^ = DELIMIT_CHAR) or (p^ = #0) then //complete field? (delimeter or zero terminated from last time)
      begin
        //trick - replace delimt char with 0 - to make zero-terminated string
        p^ := #0;

        //get complete string value/field
        sFields := sFields + ' * ' + String(pFieldStart);
        pFieldStart := nil; //set for next
      end
      else if (p^ = #13) or (p^ = #10) then //CR / LF - is las field delimiter also
      begin
        //trick - replace delimt char with 0 - to make zero-terminated string
        p^ := #0;

        if pFieldStart<>nil then
        begin
          //get complete string value/field
          sFields := sFields + ' * ' + String(pFieldStart); //for debug purpose I concatenate field values
          //field can be storen in record/structure too
          pFieldStart := nil; //set for next
        end;

        //line finished
        if Length(sFields) > 0 then
        begin
          //sFields contains all fields ..... do additional processing here...
          //
          sFields := ''; //after CR next LF will not trigger - (eat LF)
        end;

        Inc(iAnalyzed, iLineLen); //calc whole line
        iLineLen := 0;  //reset line
      end
      else //just eat chars
      begin
        if pFieldStart = nil then //set new start
          pFieldStart := p;
      end;
    end;
  end;
end;

procedure TForm1.RunJob(iFileHandle: Integer);
const
  BUFSZ = 10000; //whole buffer size
var
  pText, pStartBuff: PChar;
  bGoOn: Boolean;
  iReaded, iRemainFromLastRead, iAnalyzed: Cardinal;
begin
  //allocate buffer
  GetMem(pText, BUFSZ);
  try
    GetMem(pStartBuff, BUFSZ);
    try
      ZeroMemory(pText, BUFSZ);
      iRemainFromLastRead := 0;
      repeat
        //read file and fill buffer not overriding old (remaining) text
        iReaded := FileRead(iFileHandle, PChar(Cardinal(pText)+iRemainFromLastRead)^, BUFSZ-iRemainFromLastRead);
        if iReaded > 0 then //readed buffer?
        begin
          Inc(iReaded, iRemainFromLastRead);
          bGoOn := AnalzyeBuffer(pText, iReaded, iAnalyzed);

          if not bGoOn then Break;

          iRemainFromLastRead := iReaded - iAnalyzed; //remain?
          if iRemainFromLastRead>0 then //shift remain part in memory to start position - and keep reading from that one
          begin
            CopyMemory(pStartBuff, PChar(Cardinal(pText)+iAnalyzed), iRemainFromLastRead); //temp buffer
            CopyMemory(pText, pStartBuff, iRemainFromLastRead); //working buffer
          end;
        end
        else
        begin
          if iRemainFromLastRead > 0 then //last line without CRLF?
          begin
            AnalzyeBuffer(pText, iRemainFromLastRead, iAnalyzed);
          end;
        end;
      until iReaded = 0;
    finally
      FreeMem(pStartBuff);
    end;
  finally
    FreeMem(pText);
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  sFile: String;
  iFileHandle: Integer;
begin
  sFile:='...';

  iFileHandle := FileOpen(sFile, fmOpenRead);
  if iFileHandle>=0 then
  begin
    try
      RunJob(iFileHandle);
    finally
      FileClose(iFileHandle);
    end;
  end;

  ShowMessage('end');
end;

Open in new window


This is partly answer to your another EE question.

Look for coments in code.
0
 

Author Comment

by:shawn857
ID: 39984841
Thank you for that example code Sinisa, I'm going to try to play around with it.

Right now in my parsing engine, the bottleneck appears to be string manipulating and concatenating... not so much the File I/O of reading and writing.

Shawn
0
 

Author Comment

by:shawn857
ID: 39985130
Guys, I think that this question and another I'm asking ("Faster string concatenation") has evolved away from the initial question I asked and have started to "overlap". As I just mentioned in that other question, when what I really should be doing is finding the fastest method to parse a CSV file and stop trying to split hairs like looking for faster string manipulation routines. I shall open a new question addressing just that and award points and wrap up this one (madExcept and EurekaLog were two very good answers to the original spirit of this question).

Thanks
    Shawn
0
 

Author Closing Comment

by:shawn857
ID: 39987713
Thank you Gentlemen!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month17 days, 4 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question