News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Problem with Help

Started by gd_on, April 19, 2021, 07:56:47 PM

Previous topic - Next topic

gd_on

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 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

oBFusCATed

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!]

gd_on

for me, it crashes in svn 12312, so the very last svn.
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

oBFusCATed

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!]

Miguel Gimenez

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)?

gd_on

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.

Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Miguel Gimenez

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.

gd_on

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 ?
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Miguel Gimenez

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.

Miguel Gimenez

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);


gd_on

With if(false) and your last  proposal (DWORD_PTR), it works too.
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Miguel Gimenez

Just to clarify, if (false) works and the casting to DWORD_PTR (with the original if()) also works?

gd_on

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 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Miguel Gimenez

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

gd_on

Patch tested. OK for me ... 8)
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.2, Msys2 Compilers 16.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).