[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

access violation at address in module ntdll.dll

Posted on 2014-04-03
15
Medium Priority
?
3,054 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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