none
Need Help With Error Message Produced During Debugging a Program RRS feed

  • Question

  • I got this error message when trying to turn a GUI program using FLTK in Visual Studio:

    Unhandled exception at 0x01461B19 in chapter13ex2.exe: 0xC000041D: An unhandled exception was encountered during a user callback. occurred

    The code in the FLTK library that triggered it seems to be:

    void Fl_Graphics_Driver::transformed_vertex0(COORD_T x, COORD_T y) {

    if (!n || x != p[n-1].x || y != p[n-1].y) {   

    if (n >= p_size) {     

    p_size = p ? 2*p_size : 16;      p = (XPOINT*)realloc((void*)p, p_size*sizeof(*p));    }    p[n].x = x;    p[n].y = y;    n++;  }}

    My own code uses FLTK indirectly through a user facility provided by the Dr. Stroustrup's website for his book Programming: Principles and Practice Using C++ 2nd Edition

    This is my code:

    // Osman Zakir // 5 / 21 / 2017 // Bjarne Stroustrup: Programming: Principles and Programming Using C++ 2nd Edition // Chapter 13 Exercise 2 // Exercise Specifications: /**  * Draw a box with rounded corners. Define a class Box, consisting of four  * lines and four arcs.  */ #include <iostream> #include "../../Graph.h" #include "../../Simple_window.h" struct Box : Graph_lib::Shape { 

    Box::Box(Graph_lib::Point tl, int side)  

    : m_tl{tl}, m_side{side} {} 

    void draw_lines() const; 

    int get_side() const { return m_side; }

    private: 

    Graph_lib::Point m_tl; 

    int m_side;

    };

    int main()

    using namespace std; 

    using namespace Graph_lib; 

    const Point tl{ 100, 100 }; 

    constexpr int win_width = 600, win_height = 400; 

    Simple_window win(tl, win_width, win_height, "Rounded-Corner Boxes"); 

    Point box_tl{ 250, 400 }; 

    int side = 50; 

    Box box1{ box_tl, side }; 

    box1.set_color(Color::black); 

    win.attach(box1); 

    win.wait_for_button();

    }

    void Box::draw_lines() const

    // make the points 

    Graph_lib::Point tr = m_tl; 

    tr.x += get_side(); // top-right corner 

    Graph_lib::Point br = tr; 

    br.y += get_side(); // bottom-right corner 

    Graph_lib::Point bl = br; bl.x -= get_side(); // bottom-left corner 

    // draw the lines const

    int space = get_side() / 10; // leave space for arcs 

    fl_line(m_tl.x + space, m_tl.y, tr.x - space, tr.y); 

    fl_line(tr.x, tr.y + space, br.x, br.y - space); 

    fl_line(br.x - space, br.y, bl.x + space, bl.y); 

    fl_line(bl.x, bl.y - space, m_tl.x, m_tl.y + space); 

    // draw the arcs 

    const double x1 = static_cast<double>(m_tl.x); 

    const double y1 = static_cast<double>(m_tl.y); 

    const double radius = static_cast<double>(get_side()); 

    const double start_deg = 0.0; 

    const double end_deg = 90.0; 

    fl_arc(x1, y1, radius, start_deg, end_deg); 

    const double x2 = static_cast<double>(tr.x); 

    const double y2 = static_cast<double>(tr.y); 

    fl_arc(x2, y2, radius, start_deg, end_deg); 

    const double x3 = static_cast<double>(br.x); 

    const double y3 = static_cast<double>(br.y); 

    fl_arc(x3, y3, radius, start_deg, end_deg); 

    const double x4 = static_cast<double>(bl.x); 

    const double y4 = static_cast<double>(bl.y); 

    fl_arc(x4, y4, radius, start_deg, end_deg);}


    I know this also has something from FLTK, but because it involves an error message given by the Local Windows Debugger in Visual Studio, I thought I'd ask here.  I hope someone on here is able to help me out.  Thanks in advance.



    Sunday, May 21, 2017 7:48 AM

Answers

  • Hi DragonOsman2,

    Thanks for your friendly response.

    Since this forum is just discuss the VS debugger tool issue, and I couldn't download the third party library and repro this issue in our side. Sorry for that I also have no direct solution for it.

    Like my previous suggestion, you could debug your app with Exception thrown, and make sure that which line code generated this issue, or debug it using "(Step Into)F11", at least, it could help you find that which line code impacts the app's running.

    And then you could share the code and discuss this issue with FLTK experts.

    Sincerely,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 24, 2017 6:02 AM

All replies

  • Have you tried to build this in debug configuration and run in the debugger? 

    And what is the VS version?

    -- pa

    Sunday, May 21, 2017 6:37 PM
  • Yes, that's what I did.  That's where I got the error message from. My VS version is Community 2017.
    Sunday, May 21, 2017 10:19 PM
  • Hi DragonOsman2,

    Do you get this error if you run your app using "start without debugging(Ctrl+F5)"?

    If it has this error during you run your app using "start without debugging(Ctrl+F5)", it would be not the VS debugger tool issue.

    In addition, if it just has this issue during debugging, you could debug your app using the step Into(F11), and enable the Exception settings under menu Debug->windows. Maybe it could provide you much more Exception messages and tell you which line code generated this issue.

    Since it was also related to third party libraries, if possible, I suggest you post this issue to the FLTK forum for detailed supports if we make sure that it is related to this specific project itself.

    http://www.fltk.org/newsgroups.php

    Sincerely,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 23, 2017 8:20 AM
  • The main problem right now seems to be an exception.  I've written a try-catch block to try to see what the exception message is, but the Text object I'm trying to show isn't appearing.  Maybe my math for calculating the points for drawing the Text object is wrong?  I'm not sure.

    Here's my try-catch block:

    try
     {
      Point box_tl{ 250, 300 };
      int side = 100;
      Box box1{ box_tl, side };
      box1.set_color(Color::black);
      win.attach(box1);
     }
     catch (runtime_error &e)
     {
      Text err_msg_start{ Point{ (win_width / 2) + 200, (win_height / 2) - 100 }, "Runtime_error: " };
      Text err_msg{ Point{ ((win_width / 2) + 200) + 10, (win_height / 2) - 100 }, e.what() };
      err_msg_start.set_color(Color::black);
      err_msg.set_color(Color::black);
      win.attach(err_msg_start);
      win.attach(err_msg);
     }
     catch (exception &e)
     {
      Text err_msg_start{ Point{(win_width / 2) + 200, (win_height / 2) - 100}, "Excepion: " };
      Text err_msg{ Point{ ((win_width / 2) + 200) + 10, (win_height / 2) - 100 }, e.what() };
      err_msg_start.set_color(Color::black);
      err_msg.set_color(Color::black);
      win.attach(err_msg_start);
      win.attach(err_msg);
     }
     catch (...)
     {
      Text err_msg{ Point{ (win_width / 2) + 200, (win_height / 2) - 100 }, "Unknown exception occurred." };
      err_msg.set_color(Color::black);
      win.attach(err_msg);
     }

    When I try to run it, all I get is an empty window. 


    Tuesday, May 23, 2017 11:12 AM
  • Hi DragonOsman2,

    Thanks for your friendly response.

    Since this forum is just discuss the VS debugger tool issue, and I couldn't download the third party library and repro this issue in our side. Sorry for that I also have no direct solution for it.

    Like my previous suggestion, you could debug your app with Exception thrown, and make sure that which line code generated this issue, or debug it using "(Step Into)F11", at least, it could help you find that which line code impacts the app's running.

    And then you could share the code and discuss this issue with FLTK experts.

    Sincerely,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 24, 2017 6:02 AM