Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7879365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:53:04+00:00 2026-06-03T03:53:04+00:00

I have a function pointer void (*Draw)(WidgetVisualization *); in class WidgetVisualization, in WidgetVisualization.h. I’ve

  • 0

I have a function pointer void (*Draw)(WidgetVisualization *); in class WidgetVisualization, in WidgetVisualization.h.

I’ve got extern void GraphicVisualizationDraw(WidgetVisualization *w) in WidgetVisualization.cpp.

In WidgetVisualization’s constructor, I’m assigning Draw = GraphicVisualizationDraw;.

And here is the function from LCDGraphic.cpp:

void GraphicVisualizationDraw(WidgetVisualization *widget) {

}

When I try to assign the function pointer ‘Draw’ to the function GraphicVisualizationDraw, I get an invalid write. Any clue?

Here’s the output from valgrind:

==8281== Invalid write of size 4
==8281==    at 0x52D12C7: LCD::WidgetVisualization::WidgetVisualization(LCD::LCDCore*, std::string, Json::Value*, int, int, int) (WidgetVisualization.cpp:72)
==8281==    by 0x530F0C3: LCD::LCDCore::BuildLayouts() (LCDCore.cpp:342)
==8281==    by 0x5306A07: LCD::LCDControl::ConfigSetup() (LCDControl.cpp:213)
==8281==    by 0x53062EC: LCD::LCDControl::Start() (LCDControl.cpp:57)
==8281==    by 0x52D84E4: (anonymous namespace)::lcdcontrol_init(_VisPluginData*) (actor_lcdcontrol.cpp:115)
==8281==    by 0x40645FA: visual_plugin_realize (lv_plugin.cpp:207)
==8281==    by 0x405B1E7: visual_actor_realize (lv_actor.cpp:265)
==8281==    by 0x404C02B: visual_bin_realize (lv_bin.c:108)
==8281==    by 0x80507D1: main (lv-tool.cpp:378)


WidgetVisualization::WidgetVisualization(LCDCore *v, std::string n, Json::Value *section, int row, int col, int layer) : Widget(v, n, section, row, col, layer,
    WIDGET_TYPE_VISUALIZATION | WIDGET_TYPE_RC | WIDGET_TYPE_SPECIAL) {

    LCDError("widgetvisualization: layer: %d", layer_);

    if(lcd_type_ == LCD_TEXT)
        Draw = TextVisualizationDraw;
    else if(lcd_type_ == LCD_GRAPHIC)
        Draw = GraphicVisualizationDraw;// line 72
    else
        Draw = 0;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:53:05+00:00Added an answer on June 3, 2026 at 3:53 am

    This error does not seem to do with the code of the class itself, it seems to be something related with the memory position in which the object of the WidgetVisualization class is created.

    The problem is that when the initialization of Draw is carried out, is when the runtime realises that the object is in an incorrect position.

    Following the stack trace:

    ==8281== Invalid write of size 4
    ==8281==    at 0x52D12C7: LCD::WidgetVisualization::WidgetVisualization(LCD::LCDCore*, std::string, Json::Value*, int, int, int) (WidgetVisualization.cpp:72)
    ==8281==    by 0x530F0C3: LCD::LCDCore::BuildLayouts() (LCDCore.cpp:342)
    

    A member function called BuildLayouts() seems to be a good candidate to be the one that is doing a bad allocation of this object. You should double-check that code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a void pointer returned by dlsym(), I want to call the function
I have a problem with using a pointer to function in C++. Here is
I have got a problem with calling a global function, which takes a pointer
I have grep function in C( embedded programming ) that takes a void pointer
I can have a typedef function pointer in a class like this: template<typename T>
Say I have a function pointer in C- library int (*fptr)(void); And I have
Let's say I have a function that accepts a void (*)(void*) function pointer for
I have a function pointer defined by: typedef void (*EventFunction)(int nEvent); Is there a
I have a function that returns a pointer: static void *find_fit(size_t asize); I would
Here is what I'd like to do. I have a function pointer which wants

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.