crystallabs/crysterm

Invalid memory access (signal 11) at address 0xdb8

Closed this issue ยท 4 comments

Hi,

I'm experiencing failures with this library:

$ crystal examples/hello.cr
[0x55f514c5a6a6] *Exception::CallStack::print_backtrace:(Int32 | Nil) +118
[0x55f514c2d82a] ~procProc(Int32, Pointer(LibC::SiginfoT), Pointer(Void), Nil) +330
[0x7f602f7aa6b0] ???
[0x7f602f976db0] ???
[0x55f514e0f41a] *Unibilium::Extensions#count_bool:UInt64 +10
[0x55f514e0f177] *Unibilium::Extensions#initialize<Pointer(Void)>:Nil +39
[0x55f514e0f141] *Unibilium::Extensions::new<Pointer(Void)>:Unibilium::Extensions +113
[0x55f514dc0835] *Unibilium::Terminfo#initialize<Pointer(Void)>:Unibilium::Extensions +21
[0x55f514dc0808] *Unibilium::Terminfo::new<Pointer(Void)>:Unibilium::Terminfo +104
[0x55f514dc079e] *Unibilium::Terminfo::from_env:Unibilium::Terminfo +14
[0x55f514d5a9d2] *Crysterm::Display#initialize:(Fiber | Nil) +354
[0x55f514d5a857] *Crysterm::Display::new:Crysterm::Display +3159
[0x55f514c17f08] __crystal_main +5240
[0x55f514fef5c6] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +6
[0x55f514fef43c] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +44
[0x55f514c234c6] main +6
[0x7f602f5747fd] __libc_start_main +205
[0x55f514c1699a] _start +42
[0x0] ???

I guess I'm missing some dependencies. What I checked so far:

$ crystal --version
Crystal 1.1.1 [6d9a1d583] (2021-07-26)

LLVM: 10.0.1
Default target: x86_64-unknown-linux-gnu
# Gentoo Linux
$ eix unibilium
[I] dev-libs/unibilium
     Available versions:  2.0.0(0/4) ~2.1.0(0/4) {static-libs}
     Installed versions:  2.0.0(0/4)(19:35:57 31/05/2021)(-static-libs)
     Homepage:            https://github.com/neovim/unibilium/
     Description:         A very basic terminfo library
$ tput -V       
ncurses 6.2.20200212

Heya,

Hm, I tried with 0.36.1, 1.0, 1.1, and 1.1.1 and it works.

Unibilium version I have is 2.1.0.
Ncurses/tput version is not important (crysterm doesn't link to ncurses, and the tput it uses is a crystal-native implementation).

From this line:

[0x55f514e0f41a] *Unibilium::Extensions#count_bool:UInt64 +10

It appears it was parsing the extended header of your terminfo definition, and was calling count_bool to report how many boolean capabilities are in the extended section. I'm not sure if this specifically was relevant for the crash or not.

To see if you can fix the issue, try upgrading to latest unibilium (https://github.com/neovim/unibilium/releases/tag/v2.1.1) or see if changing the value of your TERM would help.

Please report your results, thanks.

nin93 commented

I forgot to mention, but I did tweak TERM as well, with no luck.
Today I tried compiling the samples in my main machine and here everything is working. Even with my usual TERM=xterm-88color.

# Main
$ eix unibilium
[I] dev-libs/unibilium
     Available versions:  2.0.0(0/4) (~)2.1.0(0/4) {static-libs}
     Installed versions:  2.1.0(0/4)(09:27:30 19/05/2021)(static-libs)
     Homepage:            https://github.com/neovim/unibilium/
     Description:         A very basic terminfo library

Not sure if updating is enough to solve this, I'm going to check on my second machine soon and report. Sorry for my late responding, I did not have much time to investigate any futher.

Hi,
can confirm that updating on my second machine solved the issue. Hopefully this will get a mention in the README.md? Marking this as closed!

By the way, while checking the examples based on your report, I noticed some bugs in the rendering of hello.cr and hello2.cr.
(In hello, bold attribute is messing up the right border, and in hello2 focus doesn't work after typing the first line.)

This must be a regression from one of the latest commits, I'll check what it is and fix, thanks.