Is there a way to detect debug/non-debug mismatch?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Is there a way to detect debug/non-debug mismatch?

Postby VadZ » Tue Dec 19, 2023 4:48 pm

I've just lost some time again due to the fact that I mixed up debug CEF build under Linux with a non-debug build of the application using it accidentally and I'd like to ask if there is any way to detect this and abort immediately if it does, instead of dying with weird errors later?

If it isn't already possible to do it, would it be possible to add some function to the library returning whether DCHECK_IS_ON is true or not, so that it could be used by the application to verify this?

TIA!
VadZ
Techie
 
Posts: 16
Joined: Wed Oct 18, 2023 7:02 pm

Re: Is there a way to detect debug/non-debug mismatch?

Postby magreenblatt » Tue Dec 19, 2023 5:04 pm

The way to avoid this problem is by building libcef_dll_wrapper along with your application Debug/Release build, so that they always match. That is how it's designed to be used.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Is there a way to detect debug/non-debug mismatch?

Postby VadZ » Tue Dec 19, 2023 7:45 pm

Yes, I understand that this is how it should be done, but sometimes I still make mistakes (I have 2 builds of CEF in different directories and then I need to specify the matching one when building the library in debug/release). It would be nice if this could be caught automatically, as is done by most other libraries whose ABI changes depending on NDEBUG.

A simple function like cef_is_debug_on() just returning DCHECK_IS_ON() would allow to add such a check once and never think about it again any more. Are there any drawbacks to adding it?
VadZ
Techie
 
Posts: 16
Joined: Wed Oct 18, 2023 7:02 pm

Re: Is there a way to detect debug/non-debug mismatch?

Postby ndesktop » Wed Dec 20, 2023 2:46 am

In my CEF fork, I added a cef_version(_ex) (C++: bool CefVersion(int component, int* value) and bool CefVersionEx(cef_version_info_t* version) ) with a set of constants (chrome major version, minor, patch, is fork etc.) for first version and all of them in a structure for the second "ex" version. Is pretty much similar with GetVersionEx or GetDllVersion functions.
Doing so, this can be called very early in the application startup and do various (D)CHECK, _ASSERTE (if you're on Windows), assert etc. if one of the expected values do not match.
ndesktop
Master
 
Posts: 756
Joined: Thu Dec 03, 2015 10:10 am

Re: Is there a way to detect debug/non-debug mismatch?

Postby VadZ » Wed Dec 20, 2023 11:49 am

ndesktop wrote:In my CEF fork, I added a cef_version(_ex) (C++: bool CefVersion(int component, int* value) and bool CefVersionEx(cef_version_info_t* version) ) with a set of constants (chrome major version, minor, patch, is fork etc.) for first version and all of them in a structure for the second "ex" version. Is pretty much similar with GetVersionEx or GetDllVersion functions.


Thanks, this looks (also) useful, but to check for debug/release mismatch (which can't happen under Windows, BTW, as you'd get linking errors there in this case), there should also be a parameter/struct field indicating whether the library was built in debug or not.

In fact, thinking more about this, it would also be possible to artificially introduce linking errors in Linux version too, by defining some cef_check_debug() only in debug builds and cef_check_release() only in release ones and calling one of them from the application depending on the value of NDEBUG it was compiled with (this could be hidden in a macro). This would be even simpler, although less flexible than calling a function during run-time.

Would it be possible to add something like this to CEF?
VadZ
Techie
 
Posts: 16
Joined: Wed Oct 18, 2023 7:02 pm

Re: Is there a way to detect debug/non-debug mismatch?

Postby magreenblatt » Wed Dec 20, 2023 1:40 pm

Would it be possible to add something like this to CEF?

You can always make local changes, but this is not something that we would be interested in upstream at this time.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 207 guests