Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Problem with display destruction order

This thread is locked; no one can reply to it. rss feed Print
Problem with display destruction order
Vaelin
Member #15,896
March 2015

If I run the code below without the reversing I get an error:

 Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  159 (ATIFGLEXTENSION)
  Minor opcode of failed request:  73 ()
  Value in failed request:  0x1200004
  Serial number of failed request:  203
  Current serial number in output stream:  205

Is this a bug or am I missing something?
System: Linux 3.13.0-54-generic #91-Ubuntu SMP Tue May 26 19:15:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Allegro: 5.0.10

#SelectExpand
1#include <iostream> 2#include <vector> 3#include <allegro5/allegro.h> 4#include <algorithm> 5 6int main() 7{ 8 if(!al_init()) { 9 fprintf(stderr, "failed to initialize allegro!\n"); 10 return -1; 11 } 12 13 std::vector<ALLEGRO_DISPLAY*> v; 14 15 for (uint i = 0; i < 10; ++i) 16 { 17 v.push_back(al_create_display(320, 240)); 18 } 19 20 std::reverse(v.begin(), v.end()); 21 22 for (uint i = 0; i < 10; ++i) 23 { 24 al_set_target_bitmap(nullptr); 25 al_destroy_display(v[i]); 26 } 27 28 return 0; 29}

pkrcel
Member #14,001
February 2012

That's an error with the AMD video driver, following what google says.

It's kinda weird, looking from here, there would be no strict need to reverse the order of destruction of displays...

I don't think this strictly relates to Allegro, but a fellow Linux user mught try this out on a different platform

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

SiegeLord
Member #7,827
October 2006
avatar

I can reproduce this (also with an AMD card). The error message comes about after a call to XCloseDisplay in src/x/xystem.c:127. Not sure what the issue is just yet.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Thomas Fjellstrom
Member #476
June 2000
avatar

I'm curious if it happens with any number of displays? 2? 3? 5? 10? Maybe AMD has a stupid limit to the number of display contexts open?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

SiegeLord
Member #7,827
October 2006
avatar

I got it to happen with just two displays.

EDIT: I should note that, perhaps obviously, the real issue is whether or not the first display created is destroyed before any other display is destroyed. Something in the code makes the first display special, such that when it gets destroyed, it invalidates something somewhere. I don't really know where to start, however.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

beoran
Member #12,636
March 2011

Well then, the time being, let's document this limitation.

pkrcel
Member #14,001
February 2012

Is this related to linux only and AMD cards only maybe?

I'm sorry I can't be more helpful but I am unable to run anything Allegro related by now.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Thomas Fjellstrom
Member #476
June 2000
avatar

SiegeLord said:

I don't really know where to start, however.

If what you said is the case, maybe allegro is telling it to invalidate all contexts created by the app? Or if context sharing is enabled, the first one is probably the "parent" context, and manages the resources, where as the rest of them are sharing the resources of the main one (though I didn't think we supported that yet).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

J-Gamer
Member #12,491
January 2011
avatar

I can attest that it seems to be a Linux-only bug, tried on Windows with an AMD card, no crash.

" There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo
"If your body was a business, thought would be like micro-management and emotions would be like macro-management. If you primarily live your life with emotions, then you are prone to error on the details. If you over-think things all the time you tend to lose scope of priorities." - Mark Oates

pkrcel
Member #14,001
February 2012

Shoudl try forcing use of the OPENGL driver thou.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Thomas Fjellstrom
Member #476
June 2000
avatar

There is only one driver on linux. OpenGL. Unless of course you mean he should test with forcing opengl on windows... then never mind. ;D.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

SiegeLord
Member #7,827
October 2006
avatar

What'd really be useful is if someone tested this with anything but an AMD card on Linux :P.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Izual
Member #2,756
September 2002
avatar

Lubuntu Linux
Nvidia GeeForce 9600GT
Allegro 5.1.11
gcc 4.8.4

The program compiles, runs and exits without any errors.

SiegeLord
Member #7,827
October 2006
avatar

Izual, just to be sure, did you comment out the std::reverse call in that code? The code is set to work ok by default and you need to do that modification to trigger the issue (on AMD cards at least).

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Izual
Member #2,756
September 2002
avatar

Duh, so much for reading only the last post carefully. :-/

I have set-up allegro on my work notebook. It has some kind of Intel gen3 VGA.
Again on Lubuntu and gcc 4.8.4 and this time without the reverse. ;D

The results are the same, compiles, runs and exits without any error.

When i get home i will try it on my Nvidia card again.

EDIT:
The code with removed std::reverse also works and exits without any error on my Nvidia 9600GT.

SiegeLord
Member #7,827
October 2006
avatar

Awesome, thanks Izual. You're a very tedious boss in Diablo II btw.

NVidia is known to be more tolerant to garbage input, but at least this means we're not doing something so crazy that even NVidia rejects it. Since it works on Intel, however, it does seem like it might be AMD only... I'm not sure how to proceed though, hah. Ideally we'd find some workaround, since AMD is our #1 platform (because it's what I use on my desktop 8-)).

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Go to: