Skip to main content
VSimu.1
Associate III
January 15, 2021
Solved

Bug found (and fixed) in touchgfx 4.15 and 4.16, AbstractDataGraph.cpp

  • January 15, 2021
  • 11 replies
  • 4086 views

Hi,

So far in AbstractDataGraph.cpp the library had:

namespace touchgfx
{
AbstractDataGraph::AbstractDataGraph(int16_t capacity)
 : dataScale(1), alpha(255), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0),
 maxCapacity(capacity), usedCapacity(0), gapBeforeIndex(0), clickAction()

but it should be:

namespace touchgfx
{
AbstractDataGraph::AbstractDataGraph(int16_t capacity)
 : dataScale(1), alpha(255), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0),
 maxCapacity(capacity), usedCapacity(0), gapBeforeIndex(0), clickAction(), dragAction()

i.e. the problem was that "dragAction" was never initialized and our application would crash. But not every time you dragged a Graph widget, but only sometimes (when you enter that screen and everything is initialized for maybe the 2nd or 3rd time, then with the wrong garbage data, it would crash)

Here is our stacktrack where it would always crash. dragAction->isValid() would be called, even though dragAction was never initialized. i.e. you are dereferencing an invalid pointer. The reason why the "!dragAction" check passed, was because dragAction had garbage data (i.e. it was not set to nullptr upon initialization i.e. it was never initialized).

Cheers

This topic has been closed for replies.
Best answer by Romain DIELEMAN

Hi,

Thank you very much for reporting this !

/Romain

11 replies

VSimu.1
VSimu.1Author
Associate III
January 15, 2021

Also everywhere in this code, at least our linter, is saying there is no virtual destructor declared anywhere for any *Graph classes, but it has not caused trouble for us yet, so we have not done anything regarding this...

Soren Pingel DALSGAARD
Visitor II
January 20, 2021

Dear VSimu.1

Can you please be more specific. When I check the source code for TouchGFX I find that

class DataGraphWrapAndClear : public AbstractDataGraphWithY : public AbstractDataGraph : public Container : public Drawable which has a virtual destructor.

class GraphElementDots : public AbstractGraphElement : public CanvasWidget : public Widget : public Drawable which has a virtual destructor.

Since we might roll out a 4.16.1 soon, if you can be more specific, we might be able to look into this and include a fix in 4.16.1.

1) Which specific class is reported to have the problem?

2) Which linter are you using?

3) Are you actually casting a pointer to a base class before deleting it - otherwise it should not cause any problems. TouchGFX does not use dynamic allocation, so there is no problem there.

Thanks for taking the time to report these problems to us.

Regards,

Søren

VSimu.1
VSimu.1Author
Associate III
January 20, 2021

Dear Søren,

Okay thank you for the information.

Answers to your questions:

1) GraphScroll

2) I do not know this. I do not even know where to find this. We use Eclipse and the code linter that checks the source files there shows this. See screenshot:

0693W000007Bzm1QAC.png0693W000007BzobQAC.png 

0693W000007BzwpQAC.pngTouchGFX only had "Warnings". Nothing was in "Errors" tab. 

3) Okay. I do not think that we are for this case. But maybe that may change? We are also not dynamically allocating anything either, we are trying to avoid using "new" if possible.

Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee
January 18, 2021

Hi,

Thank you very much for reporting this !

/Romain