xbows-driver icon indicating copy to clipboard operation
xbows-driver copied to clipboard

Vendor rgb.txt or gracefully handle a missing rgb.txt

Open peterhoeg opened this issue 4 years ago • 6 comments

Just running kbdtest2 causes a segfault.

Backtrace from gdb:

Reading symbols from bin/kbdtest2...
(No debugging symbols found in bin/kbdtest2)
(gdb) run
Starting program: /nix/store/ackf67gjzqbiw12fhxkki7lbn4bqam5p-xbows-driver-unstable-20191030/bin/kbdtest2 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/libthread_db.so.1".
terminate called after throwing an instance of 'std::runtime_error'
  what():  Bad line format

Program received signal SIGABRT, Aborted.
0x00007ffff7a8e15a in raise () from /nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7a8e15a in raise () from /nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/libc.so.6
#1  0x00007ffff7a78548 in abort () from /nix/store/1ncwrl8bplq3xhmj8pxfkx4y0i90vmnx-glibc-2.30/lib/libc.so.6
#2  0x00007ffff7e12643 in ?? () from /nix/store/ikp2dbb5cwvr41yvx5anq8cf8ddifz12-gcc-9.2.0-lib/lib/libstdc++.so.6
#3  0x00007ffff7e1e066 in ?? () from /nix/store/ikp2dbb5cwvr41yvx5anq8cf8ddifz12-gcc-9.2.0-lib/lib/libstdc++.so.6
#4  0x00007ffff7e1e0b1 in std::terminate() () from /nix/store/ikp2dbb5cwvr41yvx5anq8cf8ddifz12-gcc-9.2.0-lib/lib/libstdc++.so.6
#5  0x00007ffff7e1e2e4 in __cxa_throw () from /nix/store/ikp2dbb5cwvr41yvx5anq8cf8ddifz12-gcc-9.2.0-lib/lib/libstdc++.so.6
#6  0x00007ffff7f77023 in load_colornames() [clone .cold] () from /nix/store/ackf67gjzqbiw12fhxkki7lbn4bqam5p-xbows-driver-unstable-20191030/lib/libxbows.so
#7  0x00007ffff7f7e103 in init_xbows() () from /nix/store/ackf67gjzqbiw12fhxkki7lbn4bqam5p-xbows-driver-unstable-20191030/lib/libxbows.so
#8  0x00000000004011c2 in main ()

peterhoeg avatar Feb 26 '20 07:02 peterhoeg

@peterhoeg Ah, sorry. The library is trying to load rgb.txt from the X11 installation. It was a source of color name to rgb codes I thought I could use. At the moment the path is hardcoded, which is a bad idea. I hadn't yet thought through the best way to provide this database. I don't know if it's ok to copy the file or not from a license perspective.

If you have thoughts on a good way to do this, please let me know. The loader is in src/driver_parse.cc.

jlquinn avatar Mar 31 '20 23:03 jlquinn

Ah, so it was close, but not actually the real problem. When building this on nixos, I simply patched out the path to use the file from netpbm instead but it turns out that that file is almost-but-not-quite the right format thus causing the crash. If instead I use the one distributed with neovim everything works again.

I think you can safely just vendor the file as it has been part of X11 since the eighties and is presumably distributed under the same license. Not legal advise and all that...

peterhoeg avatar Apr 01 '20 06:04 peterhoeg

You should be safe to vendor it:

# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
# X Window System is a trademark of X Consortium, Inc.

peterhoeg avatar Apr 01 '20 07:04 peterhoeg

Could anyone place the contents of the file? I would like to use the driver but currently I'm not able to due to this bug.

Icemole avatar Aug 04 '20 16:08 Icemole

@Icemole - https://gist.github.com/peterhoeg/a6780322d395d227d56a8d57e95c8aa9

peterhoeg avatar Aug 05 '20 04:08 peterhoeg

If it helps anyone, I was able to install this via the rgb package: https://repology.org/project/rgb/versions

3-w-c avatar Oct 13 '23 08:10 3-w-c