SFML community forums

Help => Graphics => Topic started by: Overlay on May 30, 2022, 10:57:28 pm

Title: SegFault in Texture.cpp (Intel Graphics)
Post by: Overlay on May 30, 2022, 10:57:28 pm
Hi, all! I just started to learn SFML and I got a SegFault when trying to run this little mandelbrot sample program (https://github.com/maxmmyron/mandelbrot-visualizer/blob/master/Fractal/main.cpp).
It runs well on my friend's PC (nVidia graphics) but not on my laptop (Intel graphics).

My specs:

Stack trace:

main.cpp:
// Line 43
mandelTexture = mandelbrot(width, height, oxmin, oxmax, oymin, oymax, 100);

mandelbrot func works ok and returns its value and we go to the operator= of the Texture class:
Texture.cpp:
// Line 816
Texture& Texture::operator =(const Texture& right)
// Line 818
    Texture temp(right);

then to the copy constructor:
Texture.cpp:
// Line 83
Texture::Texture(const Texture& copy) :
// Line 99
            update(copy);

then to the update func:
Texture.cpp:
// Line 439
void Texture::update(const Texture& texture)
// Line 441
    // Update the whole texture
// Line 442
    update(texture, {0, 0});

and another update:
Texture.cpp:
// Line 447
void Texture::update(const Texture& texture, const Vector2u& dest)
// Line 455
#ifndef SFML_OPENGL_ES
// Line 487
        // Link the destination texture to the destination frame buffer
// Line 488
        glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_DRAW_FRAMEBUFFER, destFrameBuffer));
// Line 489
        glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_DRAW_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0));

and I got a SegFault at line 489  :'(
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: eXpl0it3r on May 31, 2022, 10:01:57 am
Can you provide the segfault as reported directly in Code::Blocks?
Does it originate in the Intel driver?
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: Overlay on May 31, 2022, 10:10:28 am
Does it originate in the Intel driver?

Yes,

Program received signal SIGSEGV, Segmentation fault.
In ?? () (C:\Windows\system32\ig4icd64.dll)
#4  0x000000006d1ff570 in sf::Texture::update (this=0x22f230, texture=..., x=0, y=0) at C:\Dev\buildbot\windows-gcc-810-mingw-64\build\src\SFML\Graphics\Texture.cpp:489
C:\Dev\buildbot\windows-gcc-810-mingw-64\build\src\SFML\Graphics\Texture.cpp:489:15857:beg:0x6d1ff570
At C:\Dev\buildbot\windows-gcc-810-mingw-64\build\src\SFML\Graphics\Texture.cpp:489
#4  0x000000006d1ff570 in sf::Texture::update (this=0x22f230, texture=..., x=0, y=0) at C:\Dev\buildbot\windows-gcc-810-mingw-64\build\src\SFML\Graphics\Texture.cpp:489
C:\Dev\buildbot\windows-gcc-810-mingw-64\build\src\SFML\Graphics\Texture.cpp:489:15857:beg:0x6d1ff570


(https://i.imgur.com/cZ7pt2V.png)
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: eXpl0it3r on May 31, 2022, 04:30:59 pm
Can you try the driver from Intel itself instead of the one from DELL (assuming): https://www.intel.com/content/www/us/en/download/19534/intel-graphics-media-accelerator-driver-for-windows-7-64-exe.html

If you get the ContextSettings after creating the window, what OpenGL was exactly requested?
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Window.php#ae5b8065e92bbd0408e1fd8328e80d7d1
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: Overlay on May 31, 2022, 05:20:33 pm
Can you try the driver from Intel itself instead of the one from DELL (assuming): https://www.intel.com/content/www/us/en/download/19534/intel-graphics-media-accelerator-driver-for-windows-7-64-exe.html

I can't install it. I get the message "Error: This computer does not meet the minimum requirements for installing the software. Setup will exit.". And it is older (2009) than my current driver (2012). My previous driver was from the Acer site, but I downloaded the newer (current) driver from the Intel site in 2013.

If you get the ContextSettings after creating the window, what OpenGL was exactly requested?
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Window.php#ae5b8065e92bbd0408e1fd8328e80d7d1

(https://i.imgur.com/1FueGIP.png)
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: eXpl0it3r on May 31, 2022, 06:23:25 pm
Not sure there's much that SFML can do if there's a unfixed driver bug in a very old driver :\

You could try and avoid certain things, by changing the code and see if it works around the issue.
For example instead of copying the texture by returning it as value, you could pass in a reference instead.
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: Overlay on May 31, 2022, 06:33:15 pm
Not sure there's much that SFML can do if there's a unfixed driver bug in a very old driver :\

It's very strange, but I have no issues with other OpenGL software. I play Quake 3, SDL2 games, run Blender and Photoshop. But all SFML games with textures always crash on start (the only exception is Vagante 1.10 - it works ok, but crashes on exit). SFML games without textures work fine.
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: Overlay on May 31, 2022, 11:22:55 pm
I'm not an OpenGL guru, but it looks like glFramebufferTexture2D is not supported by OpenGL 2.1:

Khronos docs (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glFramebufferTexture.xhtml):
(https://i.imgur.com/p94ZopM.png)

SFML\Graphics\GLExtensions.hpp:
// Line 262
    // Core since 3.0 - EXT_framebuffer_object
// Line 272
    #define GLEXT_glFramebufferTexture2D              glFramebufferTexture2DEXT
 

So, does SFML require OpenGL 3.0? If no and if we have 2.1 in the ContextSettings, why does Texture::update() call the unsupported function?
Title: Re: SegFault in Texture.cpp (Intel Graphics)
Post by: eXpl0it3r on June 07, 2022, 11:47:41 am
The driver advertises what extensions are supported, which is checked in the Texture (https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Texture.cpp#L464), which seems to obviously pass. So the driver is telling SFML that it supports something, but then crashes when you actually try to use it.

Also if glGenFramebuffers and glBindFramebuffer cause no issue, then glFramebufferTexture2D should also work, because what else is one going to do with those framebuffers?

You could try patching SFML for your needs, but we usually don't want to implement bug fixes for broken and very old drivers.