hanslub42 / rlwrap

A readline wrapper
GNU General Public License v2.0
2.59k stars 151 forks source link

main_loop: Assertion `!always_readline' failed #179

Closed irisjae closed 11 months ago

irisjae commented 1 year ago

Hi, I've run into this error recently on my M1 machine, when wrapping my node script in rlwrap. Wrapping the same script with rlwrap works on Darwin but fails on Linux for some reason.

rlwrap: main.c:477: main_loop: Assertion `!always_readline' failed.

rlwrap: Oops, crashed (caught SIGABRT) - this should not have happened!
If you need a core dump, re-configure with --enable-debug and rebuild

I'll investigate this problem in a bit. Have you got any pointers for me to look at? Thanks.

hanslub42 commented 1 year ago

What is your exact rlwrap command line? And, while we're at it, what is the output of rlwrap -v and ldd $(which rlwrap) ?

I see one possibility for this to happen (although I cannot provoke the crash that way) : if you specify '-a' ('--always-readline') and '-N' ('--no-children'), and "waiting for a child" is the first thing rlwrap encounters after startup

hanslub42 commented 1 year ago

I can indeed reproduce the bug this way: (rlwrap -a -N -tdumb bash and then man man inside the rlwrapped bash)

irisjae commented 1 year ago

rlwrap -vgives rlwrap 0.46, and ldd $(which rlwrap) gives the following:

        linux-vdso.so.1 (0x0000fffff7ffb000)
        libutil.so.1 => /nix/store/jxjy8r4k8pf7v0hasi37qgva9va81kj2-glibc-2.37-8/lib/libutil.so.1 (0x0000fffff7fa7000)
        libreadline.so.8 => /nix/store/2883bbi2bjd6rw7djmc07saym8shpla2-readline-8.2p1/lib/libreadline.so.8 (0x0000fffff7f40000)
        libncursesw.so.6 => /nix/store/krkgdpvfrzq723ndy7mmkcr0wb7f7qqy-ncurses-6.4/lib/libncursesw.so.6 (0x0000fffff7ebf000)
        libc.so.6 => /nix/store/jxjy8r4k8pf7v0hasi37qgva9va81kj2-glibc-2.37-8/lib/libc.so.6 (0x0000fffff7d11000)
        /nix/store/jxjy8r4k8pf7v0hasi37qgva9va81kj2-glibc-2.37-8/lib/ld-linux-aarch64.so.1 => /nix/store/lyirwifzfwjxsqal7dzcx6dbn1i4v50a-glibc-2.34-115/lib/ld-linux-aarch64.so.1 (0x0000fffff7fc8000)

As you can see, I'm using the Nix package manager. My version of node is v16.15.0.

My exact command is rlwrap -S '>' -w 40 -a -N ./my-script.

I've managed to reproduce the problem independent of my code running within node. Using the same form of rlwrap invocation, rlwrap -S '>' -w 40 -a -N node works, however if you put a single line containing node in a some file my-script like echo node > my-script; chmod +x my-script, rlwrap -S '>' -w 40 -a -N ./my-script gives the reported bug.

When I try rlwrap -a -N -tdumb bash and man man, it does indeed seem to provoke a crash with the same assertion error (after messing up my terminal while I'm typing man man).