Author Topic: Problem with Help  (Read 2212 times)

Offline gd_on

  • Lives here!
  • ****
  • Posts: 652
Problem with Help
« 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.
Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13326
    • Travis build status
Re: Problem with Help
« Reply #1 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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline gd_on

  • Lives here!
  • ****
  • Posts: 652
Re: Problem with Help
« Reply #2 on: April 19, 2021, 11:54:44 pm »
for me, it crashes in svn 12312, so the very last svn.
Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13326
    • Travis build status
Re: Problem with Help
« Reply #3 on: April 20, 2021, 12:43:51 am »
I'm asking about official builds specifically to rule out problematic self-builds.

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 717
Re: Problem with Help
« Reply #4 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)
?

Offline gd_on

  • Lives here!
  • ****
  • Posts: 652
Re: Problem with Help
« Reply #5 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.

Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 717
Re: Problem with Help
« Reply #6 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.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 652
Re: Problem with Help
« Reply #7 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 ?
Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 717
Re: Problem with Help
« Reply #8 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.

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 717
Re: Problem with Help
« Reply #9 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);

Offline gd_on

  • Lives here!
  • ****
  • Posts: 652
Re: Problem with Help
« Reply #10 on: April 20, 2021, 02:40:25 pm »
With if(false) and your last  proposal (DWORD_PTR), it works too.
Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 717
Re: Problem with Help
« Reply #11 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?

Offline gd_on

  • Lives here!
  • ****
  • Posts: 652
Re: Problem with Help
« Reply #12 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.
Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 717
Re: Problem with Help
« Reply #13 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

Offline gd_on

  • Lives here!
  • ****
  • Posts: 652
Re: Problem with Help
« Reply #14 on: April 20, 2021, 06:03:47 pm »
Patch tested. OK for me ... 8)
Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 717
Re: Problem with Help
« Reply #15 on: April 20, 2021, 06:17:26 pm »
Quote
Patch tested. OK for me ...

Thank you for testing. I have just created ticket 1089