Bug #7059


When built with gcc-8 RelWithDebInfo, adds "display: block" to some elements with changed tag names

Added by Captain Crutches about 5 years ago. Updated almost 5 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


To reproduce:

  • Clone Wt into a subfolder wt of the location of bug.cpp and CMakeLists.txt (checkout tag 4.0.5)
  • mkdir build && cd build
  • cmake .. && make
  • ./bugdemo --docroot . --http-listen
  • Point a browser at localhost:8080
  • Inspect the text element

Expected result:

<nav id="someId" class="navbar>
  <span id="someOtherId">Bug demo</span>

Actual result:

<nav id="someId" class="navbar style="display: block;">
  <span id="someOtherId">Bug demo</span>

This only happens when built with gcc-8 in CMake's default RelWithDebInfo config. If you do cmake .. -DCMAKE_BUILD_TYPE=Debug so that it instead builds, the bug does not happen. If you build with gcc-9, the bug does not happen.

From my investigation, the root of the issue seems to be in DomElement.isDefaultInline. This is called from WWebWidget.updateDom and the extra display: block is added if it returns true. In the case of this <nav> element, its type is DomElementType::OTHER, whose ordinal is 51, and we look in defaultInline_ at that index for an answer, but that array has only 50 elements. When built in any of the "good" configurations, defaultInline_[51] evaluates to false. When built in the "bad" configuration, it evaluates (on my system) to 97, i.e. true.

Seems to me like two "easy" fixes would be

  1. Add two more false elements onto defaultInline_ to bring its size in line with the number of DomElementTypes
  2. In isDefaultInline, check if static_cast<unsigned int>(type) > 49 and just return false if so

But I'm not sure what the other implications of that might be.

Note: In my own project, I've seen this happen in 2 places: a WContainerWidget whose tag name was changed to "nav" (like in my example), and a WTemplateFormView whose tag name was changed to "form". Other elements have changed tag names but do not exhibit this behavior.


bug.cpp (636 Bytes) bug.cpp Minimal example Captain Crutches, 05/18/2019 05:51 AM
CMakeLists.txt (1.43 KB) CMakeLists.txt CMake config for minimal example Captain Crutches, 05/18/2019 05:51 AM
Actions #1

Updated by Roel Standaert about 5 years ago

  • Status changed from New to Resolved

That should indeed not cause an array out of bounds access.

I made it so it takes the default inline of the standard DOM element type of the widget (see commit 6bf929b)

Actions #2

Updated by Roel Standaert almost 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF