Skip to content
New issue

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

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

Already on GitHub? # to your account

Exception: (while loading libncurses.so) /lib/x86_64-linux-gnu/libncurses.so: file too short #26

Closed
gallais opened this issue Dec 20, 2022 · 7 comments · Fixed by #27
Closed

Comments

@gallais
Copy link
Contributor

gallais commented Dec 20, 2022

No matter how I compile the library (no option, NCURSES_VERSION=5, or NCURSES_VERSION=6),
I systematically get this error when I try to run one of the examples.

I can't remember whether we ever found a way to make it work or whether I ended up
always using my personal laptop rather than my work one when experimenting with this?

Anyway, I have a little project in mind so I'd welcome any hint as to how to get this going.

@mattpolzin
Copy link
Owner

Remind me what OS you’re using (at work, where you hit the error) and if you recall having installed anything related to ncurses by hand or just what the system shipped with and I’ll try to reproduce so I can offer actual help.

I’ve only got a Mac available, but I can attempt to repro your system via Docker or a vm.

@gallais
Copy link
Contributor Author

gallais commented Dec 20, 2022

I'm running Ubuntu jammy. This is what I have installed:

$$ dpkg -l '*ncurses*' | grep ^ii
ii  libncurses-dev:amd64  6.3-2        amd64        developer's libraries for ncurses
ii  libncurses5:amd64     6.3-2        amd64        shared libraries for terminal handling (legacy version)
ii  libncurses5-dev:amd64 6.3-2        amd64        transitional package for libncurses-dev
ii  libncurses6:amd64     6.3-2        amd64        shared libraries for terminal handling
ii  libncursesw6:amd64    6.3-2        amd64        shared libraries for terminal handling (wide character support)
ii  ncurses-base          6.3-2        all          basic terminal type definitions
ii  ncurses-bin           6.3-2        amd64        terminal-related programs and man pages

and what's in /lib/x86_64-linux-gnu:

$$ ls -lh | grep libncur
lrwxrwxrwx  1 root root    12 Jan 17  2022 libcurses.a -> libncurses.a
lrwxrwxrwx  1 root root    13 Jan 17  2022 libcurses.so -> libncurses.so
-rw-r--r--  1 root root  159K Jan 17  2022 libncurses++.a
-rw-r--r--  1 root root  310K Jan 17  2022 libncurses.a
-rw-r--r--  1 root root    31 Jan 17  2022 libncurses.so
lrwxrwxrwx  1 root root    17 Jan 17  2022 libncurses.so.5 -> libncurses.so.5.9
-rw-r--r--  1 root root  147K Jan 17  2022 libncurses.so.5.9
lrwxrwxrwx  1 root root    17 Jan 17  2022 libncurses.so.6 -> libncurses.so.6.3
-rw-r--r--  1 root root  155K Jan 17  2022 libncurses.so.6.3
-rw-r--r--  1 root root  159K Jan 17  2022 libncurses++w.a
-rw-r--r--  1 root root  430K Jan 17  2022 libncursesw.a
-rw-r--r--  1 root root    32 Jan 17  2022 libncursesw.so
lrwxrwxrwx  1 root root    18 Jan 17  2022 libncursesw.so.6 -> libncursesw.so.6.3
-rw-r--r--  1 root root  235K Jan 17  2022 libncursesw.so.6.3

libncurses.so is indeed really small:

$$ cat libncurses.so
INPUT(libncurses.so.6 -ltinfo)

It seems that one version is pulled in by ghc/ocaml, the other by erlang.
So can't really uninstall one or the other.

@gallais
Copy link
Contributor Author

gallais commented Dec 20, 2022

I've just tried on my personal laptop and I have the same problem.
Debian bullseye. Similar packages installed:

$$ dpkg -l '*ncurses*' | grep ^ii
ii  libncurses-dev:amd64  6.2+20201114-2 amd64        developer's libraries for ncurses
ii  libncurses5-dev:amd64 6.2+20201114-2 amd64        transitional package for libncurses-dev
ii  libncurses6:amd64     6.2+20201114-2 amd64        shared libraries for terminal handling
ii  libncursesw6:amd64    6.2+20201114-2 amd64        shared libraries for terminal handling (wide character support)
ii  ncurses-base          6.2+20201114-2 all          basic terminal type definitions
ii  ncurses-bin           6.2+20201114-2 amd64        terminal-related programs and man pages
ii  ncurses-term          6.2+20201114-2 all          additional terminal type definitions

@mattpolzin
Copy link
Owner

I haven’t had time to look into this yet today, but if your original comment meant you literally see an error about libncurses.so being too small no matter how you set the version then I think there may be something broken with my build scripts because setting the version should result in the runtime trying to load libncurses5.so (for example) when a version is set.

@gallais
Copy link
Contributor Author

gallais commented Dec 20, 2022

No rush!
Yep the error message does not change no matter what NCURSES_VERSION option I pass.

@mattpolzin
Copy link
Owner

mattpolzin commented Dec 21, 2022

Ok, there was definitely a problem with the Makefile's replacement of libncurses with libncurses x for some version x.

I fixed that problem and also made the Makefiles for the examples work without having installed idris-indexed or ncurses-idris (they are built into the local depends folder and ncurse's C lib is also copied into the example depends folder).

The fix is in PR here: #27

If you have the time to check that branch out and see if it works, I'd love to know I am on the right track. Otherwise, I'll probably merge it sometime tomorrow regardless.

In my testing in Docker on my mac, I actually hit an even scarier error after fixing the problem you encountered here. I'll be curious to hear if you hit the new error as well or if that's just because I was working in such a poor approximation of your full work setup. The error I hit was Exception: invalid memory reference. Some debugging context lost.

@mattpolzin
Copy link
Owner

The new exception I got fits the shape of at least one known issue for Idris 2 (idris-lang/Idris2#1974) but interestingly it is not an issue on my mac. I only hit the error in my Ubunutu docker environment.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants