Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init_color makes BadAccess (opcode 88) in X11 #47

Closed
ghost opened this issue Dec 10, 2018 · 3 comments
Closed

init_color makes BadAccess (opcode 88) in X11 #47

ghost opened this issue Dec 10, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 10, 2018

When the first argument of init_color is more than 17, it will raise an error.

#include "curses.h"

int main(){
  initscr();
  start_color();
  init_color(17,0,0,0);
  endwin();
  return 0;
}

In X11 environment (I'm using debian9), I compiled above code with gcc like this:
gcc test.c -lXCurses -lX11 -lSM -lXaw -lXmu -lXt -lXpm -lICE
It successfully compiled.However, when I ran the executable, it fails with this error message:

X Error of failed request:  BadAccess (attempt to access private resource denied)
  Major opcode of failed request:  88 (X_FreeColors)
  Serial number of failed request:  1030
  Current serial number in output stream:  1082

COLORS is set to 256, therefore init_color should be able to change more than 16 color definitions.
init_color test is only done in a range of 0 to 16 in a demo file (testcurs.c), so the demo works fine.

@wmcbrine
Copy link
Owner

wmcbrine commented Dec 10, 2018

I'm unable to reproduce this error, although I think I can fix it easily enough. I'd be interested to know more about your test system (OS, etc.). (I tried macOS 10.14.1 and Ubuntu 18.10.) Edit: Oops, I see you did mention Debian 9.

BTW, init_color() doesn't necessarily let you redefine all colors -- though of course, it should return ERR rather than crashing. ;) In the Windows console, only the first 16 colors can be redefined. (I could do all 256, but it's more complicated... maybe later.) In this case, though, yes, all 256 colors should be redefinable.

wmcbrine added a commit that referenced this issue Dec 10, 2018
that it hadn't allocated. Since these are read-only cells, and
automatically freed on exit, it should be OK to omit this. Reported by
rin-kinokocan.
@wmcbrine
Copy link
Owner

OK, I committed a patch. Please let me know if this resolves your problem.

@ghost
Copy link
Author

ghost commented Dec 10, 2018

Yep! It fixed the crash! Thank you so much!

@ghost ghost closed this as completed Dec 16, 2018
polluks pushed a commit to polluks/PDCurses that referenced this issue Aug 3, 2019
…ee" colors

that it hadn't allocated. Since these are read-only cells, and
automatically freed on exit, it should be OK to omit this. Reported by
rin-kinokocan.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant