Code::Blocks Forums

User forums => Help => Topic started by: gd_on on April 19, 2021, 07:56:47 pm

Title: Problem with Help
Post by: gd_on on April 19, 2021, 07:56:47 pm
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.
Title: Re: Problem with Help
Post by: oBFusCATed on April 19, 2021, 09:45:40 pm
Looks like it is crashing inside some HtmlHelp COM component.

Does it crash in 20.03 or the latest official night build?
Title: Re: Problem with Help
Post by: gd_on on April 19, 2021, 11:54:44 pm
for me, it crashes in svn 12312, so the very last svn.
Title: Re: Problem with Help
Post by: oBFusCATed on April 20, 2021, 12:43:51 am
I'm asking about official builds specifically to rule out problematic self-builds.

Title: Re: Problem with Help
Post by: Miguel Gimenez on April 20, 2021, 09:41:50 am
Can you change fp_htmlHelp to false in the first if() in this code (help_plugin.cpp:121) and try again?

Code
  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
Code
#if defined(_WIN64) | defined(WIN64)
be
Code
#if defined(_WIN64) || defined(WIN64)
?
Title: Re: Problem with Help
Post by: gd_on on April 20, 2021, 10:38:18 am
Effectively, il I change
Code
if (fp_htmlHelp)
by
Code
if (!fp_htmlHelp)
At line 82, fp_htmlHelp is already set to 0 (<=> false) and setting it to 1 is not correct.
and
Code
#if defined(_WIN64) | defined(WIN64)
by
Code
#if defined(_WIN64) || defined(WIN64)
it works again.
It is a problem quite similar to the one described in https://forums.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.

Title: Re: Problem with Help
Post by: Miguel Gimenez on April 20, 2021, 11:30:13 am
My intention was writing
Code
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.
Title: Re: Problem with Help
Post by: gd_on on April 20, 2021, 11:43:16 am
Quote
So, 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 ?
Title: Re: Problem with Help
Post by: Miguel Gimenez on April 20, 2021, 12:05:34 pm
Quote
fp_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:

Code
  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.
Title: Re: Problem with Help
Post by: Miguel Gimenez on April 20, 2021, 12:50:26 pm
Probably
Code
      #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
Code
      fp_htmlHelp(0L, (const wxChar*)m_filename, cbHH_KEYWORD_LOOKUP, (DWORD_PTR)&link);
Title: Re: Problem with Help
Post by: gd_on on April 20, 2021, 02:40:25 pm
With if(false) and your last  proposal (DWORD_PTR), it works too.
Title: Re: Problem with Help
Post by: Miguel Gimenez on April 20, 2021, 02:59:27 pm
Just to clarify, if (false) works and the casting to DWORD_PTR (with the original if()) also works?
Title: Re: Problem with Help
Post by: gd_on on April 20, 2021, 03:25:11 pm
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.
Title: Re: Problem with Help
Post by: Miguel Gimenez on April 20, 2021, 03:53:33 pm
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
Title: Re: Problem with Help
Post by: gd_on on April 20, 2021, 06:03:47 pm
Patch tested. OK for me ... 8)
Title: Re: Problem with Help
Post by: Miguel Gimenez on April 20, 2021, 06:17:26 pm
Quote
Patch tested. OK for me ...

Thank you for testing. I have just created ticket 1089 (https://sourceforge.net/p/codeblocks/tickets/1089/)