User forums > Help

kernel freezes when watcing some variables

(1/2) > >>

Stauricus:
hello everybody
i'm having some strange behaviour when trying to watch some specific variables in codeblocks and GDB in Linux
to be honest, i didn't even knew in which forum post this  :(

I have this code in C++ and SFML (a lib):

--- Code: (cpp) ---#include <SFML/Graphics.hpp>

int main(){
    int a = 0;
    sf::VertexArray v(sf::Quads, 88);
    int b = 0;
    return 0;
}
--- End code ---
this runs fine and I can debug it and watch variables. BUT if I change the VertexArray to 89, when I start the debugger and try to open the watches window, the whole system freezes. not even the mouse or keyboard respond, and I have to hard reset. if I dont open the watches window, it runs ok.

this is what VertexArray looks like (its simple, actually): https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1VertexArray.php

OS: Linux Debian 64 Testing with Cinnamon

C::B is
Name             : Code::Blocks
Version          : 20.03-r11997
SDK Version      : 2.0.0
Scintilla Version: 3.7.5

gcc (Debian 9.3.0-15) 9.3.0
GNU gdb (Debian 9.2-1) 9.2

i tried rebuilding the whole project, doing make/install to the SFML files again, updating the system, reinstalling code::blocks and GDB, but the problem persists. if idebug it in command line, nothing seems to freeze and I can close the application.

any help ins this case is appreciated. thanks in advance :)

oBFusCATed:
Can you paste a code sample which doesn't depend on external libraries?

Stauricus:
unfortunately no... i could only get a smaller class that causes the problem, sf::Color


--- Code: (cpp) ---#include <SFML/Graphics.hpp>
#include <vector>

int main(){
    int a = 0;
    std::vector<sf::Color> v(200);
    int b = 0;
    return 0;
}
--- End code ---

https://www.sfml-dev.org/documentation/2.5.1/Color_8hpp_source.php
https://www.sfml-dev.org/documentation/2.5.1/Graphics_2Export_8hpp_source.php
https://www.sfml-dev.org/documentation/2.5.1/Config_8hpp_source.php

oBFusCATed:
You can run the preprocessor and start trimming the resulting code.

See an example here https://stackoverflow.com/questions/4900870/can-gcc-output-c-code-after-preprocessing

Stauricus:
right, I actually trimmed the results directly from the source code, which is avaliable at github: https://github.com/SFML/SFML
this is the simplest I could get to, and if i set a breakpoint at line 25, it freezes the whole system while trying to watch local variables:

--- Code: (cpp) ---typedef unsigned char Uint8;

class Color{
public:
    Color();
    Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);
    static const Color Black;       ///< Black predefined color
    static const Color White;       ///< White predefined color
    static const Color Red;         ///< Red predefined color
    static const Color Green;       ///< Green predefined color
    static const Color Blue;        ///< Blue predefined color
    static const Color Yellow;      ///< Yellow predefined color

    Uint8 r; ///< Red component
    Uint8 g; ///< Green component
    Uint8 b; ///< Blue component
    Uint8 a; ///< Alpha (opacity) component
};

#include <vector>

int main(){
    int a = 0;
    std::vector<Color> v(2);
    int b = 0;
    return 0;
}

const Color Color::Black(0, 0, 0);
const Color Color::White(255, 255, 255);
const Color Color::Red(255, 0, 0);
const Color Color::Green(0, 255, 0);
const Color Color::Blue(0, 0, 255);
const Color Color::Yellow(255, 255, 0);

Color::Color() : r(0), g(0), b(0), a(255) {
}

Color::Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha) : r(red), g(green), b(blue), a(alpha) {
}
--- End code ---

for some reason, if I remove one of the predefined colors, it works. now i'm thinking this may be a GDB problem, as running the same code in this site also makes the application unresponsive

Navigation

[0] Message Index

[#] Next page

Go to full version