Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#14690 closed defect (fixed)

wxStackWalker doesn't list the function it is within

Reported by: jbbbms Owned by:
Priority: normal Milestone:
Component: wxGTK Version: 2.8.12
Keywords: wxStackWalker Cc:
Blocked By: Blocking:
Patch: yes

Description

If obj is a local wxStackWalker object within function foo, then obj.Walk(no_mater_what) won't include foo in the list reported.
The stable manual says "Walk() frame itself is not included if skip >= 1", which kind of implies "Walk frame itself is included if skip is equal to zero", but it never happened.
After applying this simple patch, the list reported by obj.Walk() will now contain foo as the first item, and obj.Walk(0) will contain Walk as well.

Attachments (2)

stackwalker.diff download (581 bytes) - added by jbbbms 2 years ago.
a.cpp download (563 bytes) - added by jbbbms 2 years ago.
a demo app

Download all attachments as: .zip

Change History (8)

Changed 2 years ago by jbbbms

Changed 2 years ago by jbbbms

a demo app

comment:1 Changed 2 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [72546]) Really fix stack dumps for asserts and wxStackWalker::Walk() calls.

The code apparently tried to compensate for the wrong "skip" values used in
the calls to wxStackWalker::Walk() by skipping too much in Walk() itself which
was wrong as it dropped the frames that should have been shown.

Fix this by skipping only the one extra (compared to Walk() itself) frame we
add in wxStackWalker Unix implementation and not 3 of them and do skip more
frames when calling Walk() from assert failure handlers.

Also fix the wrong number of frames used in ProcessFrames(): we must not
subtract the number of skipped frames, they were already skipped.

Closes #14690.

comment:2 Changed 2 years ago by pcor

  • Resolution fixed deleted
  • Status changed from closed to reopened

After r72546 the assert dialog backtrace is skipping one too many frames for me with wxGTK on Linux x64. It seems static functions do not appear in the wxStackWalker backtrace. Here is the result of ProcessFrames(0)

[1] wxGUIAppTraits::ShowAssertDialog(wxString const&)
[2] wxAppConsoleBase::OnAssertFailure(wchar_t const*, int, wchar_t const*, wchar_t const*, wchar_t const*)
[3] wxApp::OnAssertFailure(wchar_t const*, int, wchar_t const*, wchar_t const*, wchar_t const*)
[4] wxOnAssert(char const*, int, char const*, char const*, char const*)
[5] MyFrame::OnAbout(wxCommandEvent&) /home/paul/wxgtk3/o3/samples/minimal/../../../samples/minimal/minimal.cpp:188

And a GDB backtrace of the same thing

#0  wxGUIAppTraits::ShowAssertDialog (this=0x6df790, msg=...) at ../src/gtk/utilsgtk.cpp:330
#1  0x00007ffff71b3916 in ShowAssertDialog (file=..., line=188, func=..., cond=..., msgUser=..., traits=0x6df790)
    at ../src/common/appbase.cpp:1283
#2  0x00007ffff71b1f87 in wxAppConsoleBase::OnAssertFailure (this=0x668b90, file=0x7dd150 L"../../../samples/minimal/minimal.cpp", line=
    188, func=0x8b4dd0 L"OnAbout", cond=0x87c2d0 L"\"Assert failure\"", msg=0x8b7530 L"") at ../src/common/appbase.cpp:762
#3  0x00007ffff7309cbd in wxApp::OnAssertFailure (this=0x668b90, file=0x7dd150 L"../../../samples/minimal/minimal.cpp", line=188, func=
    0x8b4dd0 L"OnAbout", cond=0x87c2d0 L"\"Assert failure\"", msg=0x8b7530 L"") at ../src/gtk/app.cpp:369
#4  0x00007ffff71b2b91 in wxDefaultAssertHandler (file=..., line=188, func=..., cond=..., msg=...) at ../src/common/appbase.cpp:1074
#5  0x00007ffff71b3304 in wxOnAssert (file=0x40e5a0 "../../../samples/minimal/minimal.cpp", line=188, func=0x40ec26 "OnAbout", cond=
    0x40e589 "\"Assert failure\"", msg=0x0) at ../src/common/appbase.cpp:1150
#6  0x000000000040aae9 in MyFrame::OnAbout (this=0x6e9d80) at ../../../samples/minimal/minimal.cpp:188

comment:3 Changed 2 years ago by vadz

  • Status changed from reopened to infoneeded_new

I don't really see how could this commit result in some frames missing in the middle, it only adjusted the number of frames skipped on the top. Also, the assert test in the except sample (press Ctrl-A there) works fine for me, does it work correctly for you? Perhaps it's a x86/x64 difference (I'm using the latter)?

comment:4 Changed 2 years ago by pcor

I didn't say r72546 caused the missing static function frames. I just thought the missing frames might explain why I was seeing different output. But now that I know what you used to test with, I see what is different. Yes, I see the backtrace starting at the "correct" frame with the except sample. But the MyApp class in that sample overrides OnAssertFailure(), so that backtrace does not represent the minimum number of frames that might be above the actual assert.

comment:5 Changed 2 years ago by PC

  • Resolution set to fixed
  • Status changed from infoneeded_new to closed

(In [73178]) decrease number of skipped frames in assert dialog backtrace, 7 is not the minimum, closes #14690

comment:6 Changed 2 years ago by vadz

We really ought to do something similar to r73124... i.e. not skip anything but really trap directly inside the assert.

Note: See TracTickets for help on using tickets.