Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: X Error of failed request: BadMatch (invalid parameter attributes)  (Read 9397 times)

0 Members and 2 Guests are viewing this topic.

rnentjes

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Hi,

When I compile & run the following example (on linux 64 bit) it runs without a problem:

#include <stdio.h>
#include <stdlib.h>

/* VideoMode */
typedef struct {
/* width */   int var_6;
/* height */   int var_7;
/* bitsPerPixel */   int var_8;
} *object_2;

/* RenderWindow */
typedef struct {
} *object_3;

typedef struct
{
    unsigned int depthBits;         ///< Bits of the depth buffer
    unsigned int stencilBits;       ///< Bits of the stencil buffer
    unsigned int antialiasingLevel; ///< Level of antialiasing
    unsigned int majorVersion;      ///< Major number of the context version to create
    unsigned int minorVersion;      ///< Minor number of the context version to create
} *sfContextSettings;

/* createRenderWindow */ /* RenderWindow */ object_3 sfRenderWindow_create(/* VideoMode */ object_2 var_10, /* string */ char* var_11, /* int */ int var_12, sfContextSettings* var_13);
/* getDesktopMode */ /* VideoMode */ object_2 sfVideoMode_getDesktopMode();

main() {

  object_2 vm = sfVideoMode_getDesktopMode();

  printf("vm %p \n\n", vm);

  object_3 var_17 = sfRenderWindow_create(vm, "SFML!", 0 , 0 );
}
 

But when I remove the printf statement I get this:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  78 (X_CreateColormap)
  Serial number of failed request:  59
  Current serial number in output stream:  61
 

Anyone has any idea what is going on? It looks like a timing issue to me but I have no idea where it's coming from and what I can do about it.

Fun fact; the failing code works fine in gdb.

Cheers,

Rien
« Last Edit: April 27, 2015, 12:52:55 pm by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: X Error of failed request: BadMatch (invalid parameter attributes)
« Reply #1 on: April 27, 2015, 02:39:34 pm »
My guess is that your context settings is not initialized so you get random data which X then rejects.

Also why did you copy the sfContextSettings struct? ???

Btw. when posting code you should use the code-tags.
« Last Edit: April 27, 2015, 03:28:54 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: X Error of failed request: BadMatch (invalid parameter attributes)
« Reply #2 on: April 27, 2015, 03:26:17 pm »
Why do you redeclare the SFML functions like sfRenderWindow_create() with a different signature? That's undefined behavior (in C++ it wouldn't link).

What's the point in having members called var_6, with their actual names written in comments? Is this generated code?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

rnentjes

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: X Error of failed request: BadMatch (invalid parameter attributes)
« Reply #3 on: April 27, 2015, 03:58:19 pm »
Yes, the code is generated. It's a hobby compiler project and I am trying to call csfml methods from the generated code, that's why it's all re-declared.

I think I see now what the problem is because of your remark about the signature, which indeed doesn't seem to mach (details, details...).

So thank you very much!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: X Error of failed request: BadMatch (invalid parameter attributes)
« Reply #4 on: April 27, 2015, 07:52:18 pm »
[...] I am trying to call csfml methods from the generated code, that's why it's all re-declared.
That's an overly error-prone way to do it, as you've just noticed with this very issue. In order to make the declarations visible, include the header files, that's what they are for.

I think I see now what the problem is because of your remark about the signature, which indeed doesn't seem to mach (details, details...).
It's not a minor detail... You have different structure types with different object layouts. The fact that C is less strict when it comes to function declarations than C++ doesn't mean exploiting this "feature" is recommended. After all, there's a reason why C++ requires function signatures to match exactly: it saves you from UB at runtime.

What exactly is the reason why you can't use the original SFML headers? If you want to "fake" the SFML types, you have to duplicate everything, be overly careful and make sure that no version breaks your code. In short, it's rather pointless...
« Last Edit: April 27, 2015, 07:54:51 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

rnentjes

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: X Error of failed request: BadMatch (invalid parameter attributes)
« Reply #5 on: April 28, 2015, 07:54:08 pm »
The c code is coming out of a compiler. Including the c header doesn't give me any type information in the original language, so that's the reason it looks like this.

Cheers, Rien