Page 1 of 1

CefGlue Mono NullReference exception

PostPosted: Tue Mar 16, 2021 4:39 am
by ElterRitter
I have an issue with .NET managed exceptions when working with Cef Glue on my Linux system (Debian 9.0) with mono. I have changed some code to make Cef Glue GTK# Demo work. Unfortunatelly, I use some old CEF releases (the latest that could work for me is 3359). Everything works fine, but since CefRuntime.Initialize() returns 1, any casual NullReferenceException (in any thread) leads my application to failure. This means, I cannot handle the following exception:
Code: Select all
try
{
    object o = null;
    o.ToString();
}
catch (Exception e)
{
    Console.WriteLine(e.Message); // this output will not be written
}

Instead, my program will abort with Segmentation fault evaluating "o.ToString()".

This is my environment:

Debian 9.0
Mono 6.4.0.198 (also tried on 4.8.1)
CefGlue from tag 3359 (also tried 3029 and 3163)

Do you have any ideas, why such behavior is possible?

Re: CefGlue Mono NullReference exception

PostPosted: Tue Mar 16, 2021 7:16 am
by fddima
Hello.

CefRuntime.Initialize() calls chromium's code, which non-conditionally will set various global handlers (for crash handling setup).

Somewhere I'm already discuss about, but did not remember where it was exactly.... so it is most likely override mono's exception handling handlers.

You should be fine if do:
1. Get handler
2. CefRuntime.Initialize()
3. Restore handler

Note, that, this is platform dependent. For example, on windows you rarely need care about something similar.

Re: CefGlue Mono NullReference exception

PostPosted: Tue Mar 16, 2021 9:48 am
by fddima
ElterRitter wrote:Do you have any ideas, why such behavior is possible?


Please, read this issue: https://gitlab.com/xiliumhq/chromiumemb ... /issues/29 it actually holds one of possible solution.

Re: CefGlue Mono NullReference exception

PostPosted: Tue Mar 16, 2021 12:05 pm
by ElterRitter
fddima wrote:
ElterRitter wrote:Do you have any ideas, why such behavior is possible?


Please, read this issue: https://gitlab.com/xiliumhq/chromiumemb ... /issues/29 it actually holds one of possible solution.


Super! Many thank's for this link!