I have configured the help to access some files as man files or .chm files. Until now it worked, but recently it crashes C::B. I don't know with which svn version it began.
Generally, I right click on on word in the editor, then I try to locate it in the help files through the popup obtained with a right clic and choose in which file to search.
For example I have "wxWidgets" configured with "C:\wxWidgets-3.1.5\docs\wxWidgets-3.1.5.chm". But this also happen on other .chm files.
When I have made my choice, C::B crashes after a while.
Here is the RPT file obtained.
I tried to compile C::B with -g and launch C::B with gdb. Nevertheless, the backtrace (gdb_out.txt) does not give many more informations.
Looks like it is crashing inside some HtmlHelp COM component.
Does it crash in 20.03 or the latest official night build?
for me, it crashes in svn 12312, so the very last svn.
I'm asking about official builds specifically to rule out problematic self-builds.
Can you change fp_htmlHelp to false in the first if() in this code (help_plugin.cpp:121) and try again?
wxThread::ExitCode LaunchCHMThread::Entry()
{
if (fp_htmlHelp) // do it our way if we can
{
cbHH_AKLINK link;
link.cbStruct = sizeof(cbHH_AKLINK);
link.fReserved = FALSE;
link.pszKeywords = m_keyword.c_str();
link.pszUrl = NULL;
link.pszMsgText = NULL;
link.pszMsgTitle = NULL;
link.pszWindow = NULL;
link.fIndexOnFail = TRUE;
#if defined(_WIN64) | defined(WIN64)
fp_htmlHelp(0L, (const wxChar*)m_filename, cbHH_KEYWORD_LOOKUP, (DWORDLONG)&link);
#else
fp_htmlHelp(0L, (const wxChar*)m_filename, cbHH_KEYWORD_LOOKUP, (DWORD)&link);
#endif
}
else // do it the wx way then (which is the same thing, except for the 0L in the call to fp_htmlHelp)
{
m_helpctl.KeywordSearch(m_keyword);
}
return 0;
}
BTW, shouldn't #if defined(_WIN64) | defined(WIN64) be #if defined(_WIN64) || defined(WIN64)?
Effectively, il I change
if (fp_htmlHelp)
by
if (!fp_htmlHelp)
At line 82, fp_htmlHelp is already set to 0 (<=> false) and setting it to 1 is not correct.
and
#if defined(_WIN64) | defined(WIN64)
by
#if defined(_WIN64) || defined(WIN64)
it works again.
It is a problem quite similar to the one described in https://forums.next.codeblocks.org/index.php/topic,24363.msg166592.html#msg166592, a pointer to an address with the wrong length on Windows 64 bits, which seems to be a problem on very recent gcc versions.
My intention was writing if (false) so the else part was always executed, sorry for the bad wording.
So, changing only the #if defined() line fixes the issue?. I am using wx3.1.5 but on 32 bits, so I can not test.
QuoteSo, changing only the #if defined() line fixes the issue?
surprisingly, it works also with the old code (only one |), which is certainly wrong ! (but always with the !fp_htmlHelp test)
Finally, doiing if(false) or if(!fp_htmlHelp) do the same thing, I suppose, because fp_htmlHelp is volatile and created each time, no ?
Quotefp_htmlHelp is volatile and created each time, no ?
No, it is the address of a procedure in HHCTRL.OCX and it is assigned once in the plugin constructor:
ocx_module = LoadLibrary(_T("HHCTRL.OCX"));
if (ocx_module)
fp_htmlHelp = (HTMLHELP)GetProcAddress(ocx_module, HTMLHELP_NAME);
with HTMLHELP_NAME = "HtmlHelpW".
If the OCX can't be opened or the procedure is not found then the code on line 121 uses wxWidgets' wxCHMHelpController (m_helpctl).
I wanted to force the use of m_helpctl in order to discard (or blame) the other code.
Probably
#if defined(_WIN64) | defined(WIN64)
fp_htmlHelp(0L, (const wxChar*)m_filename, cbHH_KEYWORD_LOOKUP, (DWORDLONG)&link);
#else
fp_htmlHelp(0L, (const wxChar*)m_filename, cbHH_KEYWORD_LOOKUP, (DWORD)&link);
#endif
can be just
fp_htmlHelp(0L, (const wxChar*)m_filename, cbHH_KEYWORD_LOOKUP, (DWORD_PTR)&link);
With if(false) and your last proposal (DWORD_PTR), it works too.
Just to clarify, if (false) works and the casting to DWORD_PTR (with the original if()) also works?
OK, I finally don't clearly understand what happens.
if i use if(false) it works.
if I use the original if(fp_htmlhelp) with DWORD_PTR, it does not work.
if I use the original if(fp_htmlhelp) with the modified conditionnal #if (|| instead of |), it does not work.
if I totally delete the condition if(fp_htmlhelp), but keep, of course, the original call to wx help (line with m_helpctl.KeywordSearch(m_keyword); ), it works.
I think that it was what happens with my try to if(!fp_htmlhelp) or if(false), because as you told, fp_htmlhelp is initialized to 0, but finally set to an address in the help plugin constructor.
I don't see the point for duplicating the funcionality of wxCHMHelpController, even more if duplication is buggy.
This patch removes all traces of direct calls to HHCTRL.OCX
Patch tested. OK for me ... 8)
QuotePatch tested. OK for me ...
Thank you for testing. I have just created ticket 1089 (https://sourceforge.net/p/codeblocks/tickets/1089/)