Skip to content

Logging cannot be used early #10937

@blueyed

Description

@blueyed

Trying to use ILOG in ui_attach_impl results in an assertion error:

nvim: ../src/nvim/os/env.c:737: vim_getenv: Assertion `get_vim_var_str(VV_PROGPATH)[0] != NUL' failed.

(gdb) bt
#0  0x00007f7e213d6755 in raise () from /usr/lib/libc.so.6
#1  0x00007f7e213c1851 in abort () from /usr/lib/libc.so.6
#2  0x00007f7e213c1727 in __assert_fail_base.cold () from /usr/lib/libc.so.6
#3  0x00007f7e213cf026 in __assert_fail () from /usr/lib/libc.so.6
#4  0x000055b93a6e4a8d in vim_getenv (name=0x55b93a8df4c0 <log_file_path> "")
    at ../src/nvim/os/env.c:737
#5  0x000055b93a6e4337 in expand_env_esc (srcp=0x55b93a827ba2 "$NVIM_LOG_FILE",
    dst=0x55b93a8df4c0 <log_file_path> "", dstlen=4095, esc=false, one=false,
    prefix=0x0) at ../src/nvim/os/env.c:482
#6  0x000055b93a6e4040 in expand_env (src=0x55b93a827ba2 "$NVIM_LOG_FILE",
    dst=0x55b93a8df4c0 <log_file_path> "", dstlen=4096) at ../src/nvim/os/env.c:397
#7  0x000055b93a669972 in log_path_init () at ../src/nvim/log.c:70
#8  0x000055b93a669d15 in open_log_file () at ../src/nvim/log.c:188
#9  0x000055b93a669b4b in logmsg (log_level=1, context=0x0,
    func_name=0x55b93a854468 <__func__.18603> "ui_attach_impl", line_num=282,
    eol=true, fmt=0x55b93a8543d1 "ui_attach_impl") at ../src/nvim/log.c:133
#10 0x000055b93a7b4317 in ui_attach_impl (ui=0x55b93ac4f480) at ../src/nvim/ui.c:282
#11 0x000055b93a7b7809 in ui_comp_init () at ../src/nvim/ui_compositor.c:86
#12 0x000055b93a7b3d42 in ui_init () at ../src/nvim/ui.c:109
#13 0x000055b93a672525 in event_init () at ../src/nvim/main.c:157
#14 0x000055b93a6726d8 in main (argc=11, argv=0x7ffc96522ac8)
    at ../src/nvim/main.c:260

Code: https://github.com/blueyed/neovim/blob/e867ac3e527e205416299faa28a74ca758cfc33b/src/nvim/os/env.c#L736-L737

From a quick look it seems like this could skip using VV_PROGPATH /
v:progpath then.

But of course there might be better ways to fix this ("logging should be usable as early as possible").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions