Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A debugging check in this application has Failed #4806

Closed
LezheGao opened this issue Jun 22, 2022 · 15 comments
Closed

A debugging check in this application has Failed #4806

LezheGao opened this issue Jun 22, 2022 · 15 comments

Comments

@LezheGao
Copy link

LezheGao commented Jun 22, 2022

I had try to go to Simple View,but:
1

@AenBleidd
Copy link
Member

Closed as a duplicate of #4783

@LezheGao
Copy link
Author

如# 4783的副本关闭

but my OS is Windows11

@AenBleidd
Copy link
Member

如# 4783的副本关闭

but my OS is Windows11

This happens on any OS and is already fixed.
Fixed version will be provided soon. Please stay tuned

@LezheGao
Copy link
Author

#4783的副本关闭

但我的操作系统是 Windows11

这发生在任何操作系统上并且已经修复。 固定版本将很快提供。敬请期待

OK,Waiting...

@wangqr
Copy link

wangqr commented Jun 26, 2022

Came here from microsoft/vcpkg#25437.
I can see the debug alert dialog using the binary installer from 7.20.0 release. But cannot see the alert if I build boincmgr from source f35e562 with MSVC, using win_build/boinc_vs2019.sln, in Release x64 mode. How is the binary installer built?

@AenBleidd
Copy link
Member

@wangqr, probably because you're using wxwidgets port with already set 'wxDEBUG_LEVEL=0' ?

@wangqr
Copy link

wangqr commented Jun 26, 2022

@wangqr, probably because you're using wxwidgets port with already set 'wxDEBUG_LEVEL=0' ?

Yes. Once I add git checkout dc6f878c0f49c3b0625d4f94217732fb3743b251 (one commit before microsoft/vcpkg#25240 was merged) after git pull, I can reproduce the issue.

The reason is that, wxWidgets is built withwxDEBUG_LEVEL=1, but boincmgr is built with wxDEBUG_LEVEL=0.


Here's how [NDEBUG disables asserts] works:

  • The entry point of a wxApp will call macro wxDISABLE_DEBUG_SUPPORT;(source)
  • wxDISABLE_DEBUG_SUPPORT has a call to wxDISABLE_ASSERTS_IN_RELEASE_BUILD;(source)
  • wxDISABLE_ASSERTS_IN_RELEASE_BUILD expands to wxDisableAsserts if NDEBUG is set;(source)
  • wxDisableAsserts sets AssertHandler to NULL, disabling asserts.(source)

So there are several cases:

  • a) If both wxWidgets and boincmgr are built with wxDEBUG_LEVEL=0, debugging related code is completely removed. This is the current approach
  • b) If both wxWidgets and boincmgr are built with wxDEBUG_LEVEL=1 (or left as default), and boincmgr defines NDEBUG, debugging (assertions, debug logging) will be disabled upon wxApp init. This is, in my opinion, the prefered approach.
  • c) If wxWidgets is built with wxDEBUG_LEVEL=1, but boincmgr is built with wxDEBUG_LEVEL=0. Then even if we define NDEBUG, debugging will not be disabled. This is because the header of wx assumes that there's no debugging functions present in wx, thus the wxDisableAsserts is a dummy function, not correctly disabling debugging. This is how this issue happens.

So my opinion here is to left wxDEBUG_LEVEL as default (1) for both wxWidgets and boincmgr, and define NDEBUG in Release build of boincmgr. In my test this does fix this issue.
Compared to current apporach, this will introduce an extra function call upon init, but should not introduce further runtime costs. The benefit is that we can use wx with its default compile options, and may allows us to use system provided wx on linux distros.

Edit: I just realized that boincmgr uses static-linked wx on Windows. In this case i guess it's fine to compile wx with whatever options we need, and wxDEBUG_LEVEL=0 may reduce binary size.

@AenBleidd
Copy link
Member

@wangqr, if you check, 'NDEBUG' is already set for release builds of BOINC:

<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;wxUSE_GUI=1;wxDEBUG_LEVEL=0</PreprocessorDefinitions>

But debug asserts are still there and shown in runtime

@AenBleidd
Copy link
Member

@wangqr, I assume, to keep asserts disabled, wxwidgets should be built with 'NDEBUG' also, but this flag is not supported by cmake build of wxwidgets.

@wangqr
Copy link

wangqr commented Jun 26, 2022

But debug asserts are still there and shown in runtime

Yes, it's because wxDEBUG_LEVEL is set to 0. If we remove that, i.e. changing that line to:

 <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;wxUSE_GUI=1</PreprocessorDefinitions> 

Then this issue will be fixed

@AenBleidd
Copy link
Member

@wangqr, so you want to say that these two flags contradict each other, and if I set 'wxDEBUG_LEVEL=0' in my app, then 'NDEBUG' flag will keep debug asserts enabled?
Either I don't understand smth or wxwidgets has broken logic.

@wangqr
Copy link

wangqr commented Jun 26, 2022

@wangqr, so you want to say that these two flags contradict each other, and if I set 'wxDEBUG_LEVEL=0' in my app, then 'NDEBUG' flag will keep debug asserts enabled?

It is not 'wxDEBUG_LEVEL=0' and 'NDEBUG' contradict each other. It's 'wxDEBUG_LEVEL=1' when building wx, and 'wxDEBUG_LEVEL=0' in boincmgr, contradict each other.

  • 'wxDEBUG_LEVEL=1' when building wx enables the debugging function in wx
  • 'wxDEBUG_LEVEL=0' in boincmgr means: "We are linking a wx library without debugging functions, therefore we should not call any debugging related function, and call dummy functions instead."
  • Normally when using wx in Release build, NDEBUG will set assertion handler to NULL, disabling assertions.
  • With 'wxDEBUG_LEVEL=0' in boincmgr, we are not calling any debugging related function, including the one that disables assertions, no matter NDEBUG present or not. So when wx internally encounters an assertion failure, the assertion handler is still the default one, and showing the pop up window.

To sum up, 'wxDEBUG_LEVEL' must be consistent when building and using wx.

@AenBleidd
Copy link
Member

@wangqr, then I suggest next: make this flag a port option. Then this will enable you to keep debug asserts dormant and I can completely remove them from my release builds.
What do you think?

@wangqr
Copy link

wangqr commented Jun 26, 2022

IIRC there is no "port option" in vcpkg. You may make it a "feature" that can be toggled on or off. This will work for my use case.

@AenBleidd
Copy link
Member

@wangqr, sorry, my bad. Saying 'option' I meant 'feature'. Thank you for correcting me.

@AenBleidd AenBleidd closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants