Skip to content

macOS reports 'attempt to index a nil value' and hangs when installed with wrong lpeg #1366

Description

@erf

Problem

Even though vis seemed to install OK after the fix #1323 using the brew install lpeg version, i later i saw the following error message each time i opened vis whenever i had a non-empty visrc.lua.

 attempt to index a nil value

I also experienced if i tried to open vis again that it would crash and hang using 100% CPU.

If i install vis using luarocks install lpeg it seem to work OK. (eventhough lua and luarocks is installed via homebrew and seem to install lpeg via homebrew)

 luarocks install lpeg
Installing https://luarocks.org/lpeg-1.1.0-2.src.rock


lpeg 1.1.0-2 depends on lua >= 5.1 (5.5-1 provided by VM: success)
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/lua/include/lua5.5 -c lpcap.c -o lpcap.o
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/lua/include/lua5.5 -c lpcode.c -o lpcode.o
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/lua/include/lua5.5 -c lpcset.c -o lpcset.o
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/lua/include/lua5.5 -c lpprint.c -o lpprint.o
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/lua/include/lua5.5 -c lptree.c -o lptree.o
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/opt/lua/include/lua5.5 -c lpvm.c -o lpvm.o
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc  -bundle -undefined dynamic_lookup -all_load -o /var/folders/t9/78zrvz453mx1rp9zcwxwrmz40000gn/T/luarocks_build-LPeg-1.1.0-2-7489700/lpeg.so lpcap.o lpcode.o lpcset.o lpprint.o lptree.o lpvm.o
lpeg 1.1.0-2 is now installed in /opt/homebrew (license: MIT/X11)

I'm not sure what causes this or how i should debug this, but maybe a good idea to revert my previous PR.

Here is the output when i run configure and make after installing via luarocks:

./configure
checking for C compiler... cc
checking whether C compiler works... yes
checking whether compiler accepts -Werror=unknown-warning-option... yes
checking whether compiler accepts -Werror=unused-command-line-argument... yes
checking whether linker accepts -Werror=unknown-warning-option... no
checking whether linker accepts -Werror=unused-command-line-argument... no
checking whether compiler accepts -Wall... yes
checking whether compiler accepts -pipe... yes
checking whether compiler accepts -Wno-initializer-overrides... yes
checking whether compiler accepts -O2... yes
checking whether compiler accepts -ffunction-sections... yes
checking whether compiler accepts -fdata-sections... yes
checking whether linker accepts -Wl,--gc-sections... no
checking whether compiler accepts -fPIE... yes
checking whether compiler accepts -fstack-protector-all... yes
checking whether linker accepts -Wl,-z,now... no
checking whether linker accepts -Wl,-z,relro... no
checking whether linker accepts -pie... no
creating config.mk... done
checking for pkg-config... yes
checking for libcurses...
 checking for ncursesw... yes
checking for libtre... yes
checking for liblua >= 5.2 ...
 checking for lua... yes
checking for Lua statically linked liblpeg...
 checking for static lpeg... no
 checking for static lua5.5-lpeg... no
 checking for static lua5.4-lpeg... no
 checking for static lua5.3-lpeg... no
 checking for static lua5.2-lpeg... no
completing config.mk... done

sudo make
Password:
cc -Wall -pipe -Wno-initializer-overrides -O2 -ffunction-sections -fdata-sections -fPIE -fstack-protector-all -DTERMINFO='"/usr/share/terminfo"' -DTERMINFO_DIRS='"/etc/terminfo:/lib/terminfo:/usr/share/terminfo:/usr/lib/terminfo:/usr/local/share/terminfo:/usr/local/lib/terminfo"' -D_DARWIN_C_SOURCE -DCONFIG_CURSES=1   -I/opt/homebrew/Cellar/tre/0.9.0/include -DCONFIG_TRE=1 -I/opt/homebrew/include/lua -DCONFIG_LUA=1  -std=c99 -DNDEBUG -D_DARWIN_C_SOURCE -DVERSION=\"v0.9-468-geacbb217\" -DVIS_EXPORT=static -DVIS_PATH=\"/usr/local/share/vis\"  main.c   -lncurses   -L/opt/homebrew/Cellar/tre/0.9.0/lib -ltre -L/opt/homebrew/lib -llua -lm  -lc  -o vis

Here is the output if i run configure and make after installing lpeg via brew directly:

./configure
checking for C compiler... cc
checking whether C compiler works... yes
checking whether compiler accepts -Werror=unknown-warning-option... yes
checking whether compiler accepts -Werror=unused-command-line-argument... yes
checking whether linker accepts -Werror=unknown-warning-option... no
checking whether linker accepts -Werror=unused-command-line-argument... no
checking whether compiler accepts -Wall... yes
checking whether compiler accepts -pipe... yes
checking whether compiler accepts -Wno-initializer-overrides... yes
checking whether compiler accepts -O2... yes
checking whether compiler accepts -ffunction-sections... yes
checking whether compiler accepts -fdata-sections... yes
checking whether linker accepts -Wl,--gc-sections... no
checking whether compiler accepts -fPIE... yes
checking whether compiler accepts -fstack-protector-all... yes
checking whether linker accepts -Wl,-z,now... no
checking whether linker accepts -Wl,-z,relro... no
checking whether linker accepts -pie... no
creating config.mk... done
checking for pkg-config... yes
checking for libcurses...
 checking for ncursesw... yes
checking for libtre... yes
checking for liblua >= 5.2 ...
 checking for lua... yes
checking for Lua statically linked liblpeg...
 checking for static lpeg... yes
completing config.mk... done

sudo make install
cc -Wall -pipe -Wno-initializer-overrides -O2 -ffunction-sections -fdata-sections -fPIE -fstack-protector-all -DTERMINFO='"/usr/share/terminfo"' -DTERMINFO_DIRS='"/etc/terminfo:/lib/terminfo:/usr/share/terminfo:/usr/lib/terminfo:/usr/local/share/terminfo:/usr/local/lib/terminfo"' -D_DARWIN_C_SOURCE -DCONFIG_CURSES=1   -I/opt/homebrew/Cellar/tre/0.9.0/include -DCONFIG_TRE=1 -I/opt/homebrew/include/lua -DCONFIG_LUA=1 -DCONFIG_LPEG=1 -std=c99 -DNDEBUG -D_DARWIN_C_SOURCE -DVERSION=\"v0.9-468-geacbb217\" -DVIS_EXPORT=static -DVIS_PATH=\"/usr/local/share/vis\"  main.c   -lncurses   -L/opt/homebrew/Cellar/tre/0.9.0/lib -ltre -L/opt/homebrew/lib -llua -lm -llpeg -lc  -o vis

Steps to reproduce

try install lpeg via homebrew and open it.

vis version (vis -v)

vis v0.9-468-geacbb217 +curses +lua +tre

Terminal name/version

ghostty 2ba5e6b92

TERM environment variable

xterm-ghostty

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions