0

I understand that my problem is multidimensional and I will probably get some independent advices, but thank you very much for all this and I am sorry if this is a newbie question.

I use a CEF (TChromium) browser in Delphi RAD 10. I regularly receive an error at the customer's production which I cannot replicate while working on the debugger. After displaying basic Win error information, the system (Win7) kills program, which ends with unsaved previous work. I checked each element of the code step by step, asked fellow programmers for analysis and it seems that this error applies only to the CEF browser. Every time, regardless of what i can manage to note in the program's work, the error is the same:

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: MyApp.exe
  Application version:  0.0.0.0
  Application timestamp:    5e36d888
  Module name with error:   libcef.dll
  Module version with error:    3.2454.1344.0
  Module timestamp with error:  562d8f27
  Exception Code:   c0000005
  Exception Offset: 001dea9b
  OS Version:   6.1.7601.2.1.0.256.1
  Locale ID:    1045
  Additional information 1: 0a9e
  Additional information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional information 3: 0a9e
  Additional information 4: 0a9e372d3b4ad19135b953a78882e789

Yes, I guess the problem may arise from a large number of different things, but I assume that since this only happens when using the browser (otherwise the program works perfectly), and every time the same problem is displayed, it may be a TChromium component.

Unfortunately, I was not able to understand what exactly causes this problem (libcef.dll c0000005 / 001dea9b exeption) and all threads found on various forums are terminated and/or unresolved.

I tried to program each page load by displaying a larger message instead of closing the program:

procedure LoadUrl(url: String);
begin
  try
  Form1.Chromium1.Load(url);
  except
    on E : Exception do
      ShowMessage('CEF: '+E.ClassName+' error raised, with message : '+E.Message);
  end;
end;

But when working on the debugger I do not get any error (again), and on production system just kills the application without any error message.

At first glance, I think I need an explanation:

  • TChromium component actually changes only when i call it with "Load (url)", so do I understand correctly that this place in code is where I should focus?
  • Can I program errors/exceptions of external libraries this way? Or maybe there is some other way to use them safely, so that the error will not be the reason for killing the app, but will be controlled on production?
  • Will this mentioned procedure calling TChromium component give me more information than the system that kills my app? (Of course, if this is error place, because it seems to be the surest shot)
  • I use the EurekaLog7 tool - but I can't understand how I should use it to track the browser library errors trace and where to call it, or even how to take it in code. Actually, I have absolutely no idea where to start using it on external library, I will gladly accept some documentation or a hint about what to read and where I will find an understandable example.

Thank you in advance and I apologize if this is too easy or a problem is stupid. Of course, I also know that since I do not provide the full code, it will be difficult to analyze the problem, but I want to learn such error analysis myself, so maybe you will forgive me. :)

~~Additional info

  • program got x32 structure, is runned in win 7 xs64;
  • program is a simple crawler whose task is to save selected elements of searched pages to a text file form;
  • optional: it is enough for me, if this error manages to trigger my own shutdown procedure allowing to save the results simply, the app can be killed after because the sheduler will resurrect it;
kwadratens
  • 187
  • 15
  • If you're using MadExcept, you should have a stack trace in your error report. This is where you need to start. If you can show a stack trace, we can possibly help. – J... Feb 03 '20 at 13:50
  • 2
    Your application is using a very old CEF library. The 3.2454.1344.0 version was released several years ago. Consider switching to the latest CEF4Delphi version and read this guide to debug CEF issues : https://www.briskbard.com/forum/viewtopic.php?f=10&t=1050 – Salvador Díaz Fau Feb 03 '20 at 17:17
  • Dear @SalvadorDíazFau. This old version was easily installed in my Delphi Rad 10 Seattle. However, I have not been able to install this new ver for some time. Of course, I used the instructions here: https://www.briskbard.com/index.php?lang=en&pageid=cef but every time I try to install or build - the compiler goes to uCEFbufferPannel, line 107 and indicates that [dcc32 Error] uCEFBufferPanel.pas(107): E2003 Undeclared identifier: 'WM_POINTERDOWN' :( I don't know what the problem is and I haven't found information about this problem. Do you think this is a separate topic or leave it here? – kwadratens Feb 03 '20 at 23:51
  • 2
    I just uploaded a new version of CEF4Delphi with the fix for that issue. Please, download it again from GitHub. You can use stackoverflow or our forum to talk about CEF4Delphi. – Salvador Díaz Fau Feb 04 '20 at 10:55
  • Dear @SalvadorDíazFau I downloaded again, this time there is an error in the unit file uCEFMiscFunctions on line 2119 "[dcc32 Error] uCEFMiscFunctions.pas (2119): E2003 Undeclared identifier: 'GetSystemMetricsForDpi'" During the tests 4 now, I "muted" this line and managed to compile and then install the module, but I do not know how critical this function is. Again, I did not find information about this error on the network. – kwadratens Feb 05 '20 at 20:39
  • 1
    @kwadratens Thanks again for reporting that issue!. That function is not currently used but it might be handy for those using a touch screen or a pen. I didn't realize GetSystemMetricsForDpi was only available in the latest Delphi version. I updated CEF4Delphi again with this information. – Salvador Díaz Fau Feb 06 '20 at 09:41
  • Dear @J... I used MadExcept, but I noticed that it doesn't support exceptions (tested for example on "raise Exception.Create ('Testing madExcept');"). I changed it to EurekaLog7 and uploaded two sample reports of this exception: https://drive.google.com/drive/folders/1ejj5nbVZqJHJZ5d3wwgjc1ILMj8jnkV2?usp=sharing Where should I start now? Which elements of the exception of the report are key and should be included in my question here? Thank You in advance. – kwadratens Feb 06 '20 at 17:56
  • 1
    @kwadratens Ideally you should [edit] all new information directly into the question - this helps people have immediate access to it (no dead links, etc) and aids with search and so on. From the two traces you posted it looks like the full stack trace of the faulting thread is entirely being called inside libcef.dll directly from kernel32, so this does look like a bug in CEF. The exception is AV reading an address of zero, so this is a null pointer dereference in CEF that isn't being caught. The affected method in the DLL seems to be `GetHandleVerifier`. – J... Feb 06 '20 at 18:17
  • Dear @J... Because I do not know yet which way to go - try to fight the bug of the project that (unfortunately) was abandoned, or according to Salvators advice change the component at all and rebuild the form. At the moment I do not know what the answer will be, but I will try to edit the question soon. Meanwhile, I searched a bit and GetHandleVerifier error with CEF suggested exceeding the memory limit for 32bit application (out of memory). Not sure if correct, cause app when crashes was about 0,9 gb, but i added LARGEADDRESSAWARE flag and will se what's next. Did i understand You? – kwadratens Feb 07 '20 at 21:26
  • 1
    @kwadratens Yes, I think you did. I don't really have much to suggest at this point, to be honest. CEF should not be internally faulting on a null pointer AV like that, so I consider that a defect in the DLL. Whether you want to submit a bug report to CEF or whether you want to try to debug CEF yourself, I think the problem is likely there. Producing a proper [mcve] would be my next step. – J... Feb 07 '20 at 21:30

1 Answers1

0

Thanks to @J... i think i figured it out and here's solution.

The indicated error results only from the "work" of the libcef.dll library which (unfortunately) is probably no longer supported. Although this is not a problem solved anywhere - most indications of this error in various forums appear when there is a problem of referring to the wrong address in memory, and then following this lead is basically about out of memory error in various versions.

The libcef library has some fatal way of allocating memory and in itself leads to constant memory leaks. These leaks and misallocation quickly lead to the use of virtually all available memory... and it's easy to get a similar problem. First of all, adding a directive

{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}

after

uses WinApi.Windows

to the dpr form solves the problem for a while, because the program has more memory available and it takes longer to exhaust resources. This, of course, does not end the matter, because the suspension of the program will simply take longer.

But! It is enough when every few dozen scans (crawls) one will relocate memory for the form, which will automatically allocate memory, kills leaks - also in terms of the libcef library. I found and used such code that is called from time to time. It was enough for me to do what every 20 turns of the browser, but it may look different for everyone. You need to try trigger.

 procedure TrimAppMemorySize;
 var
   MainHandle : THandle;
 begin
   try
     MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID) ;
     SetProcessWorkingSetSize(MainHandle, $FFFFFFFF, $FFFFFFFF) ;
     CloseHandle(MainHandle) ;
   except
    on E : Exception do
     // inform me about problem 
   end;
   Application.ProcessMessages;
 end;

This is probably not the best solution, but it makes the unstable form with CEF3 stable and ready to work. For several days, working on several copies of the same form, no error appeared at all, so it can be a good solution maybe for everyone who has memory leaks with CEF3, has unknown errors similar to mine, or out of memory error caused by CEF3.

However - my question was how to debug libcef.dll and how to get more information about bugs of CEF3 library - and J... has finished the topic, thank you very much.

As for SalvadorDíazFau's offer - I really appreciate your involvement in the project, people like you are the foundation of our community; however, while CEF3 is still working it is less work for me than discovering new elements and possibilities of CEF4 which would require me to rebuild the form. There will be time for that. :)

Thank You Guys! Case closed already!

kwadratens
  • 187
  • 15