lnav
                                
                                 lnav copied to clipboard
                                
                                    lnav copied to clipboard
                            
                            
                            
                        require fail for files with long lines
lnav version github master
Describe the bug lnav assertion failure for some files with long lines.
2022-05-19T16:45:47.877 E t0 line_buffer.cc:392 failed precondition `this->lb_bz_file || this->lb_gz_file || new_max <= MAX_LINE_BUFFER_SIZE'
2022-05-19T16:45:47.878 E t0 lnav_log.cc:414 Received signal: 6
I found lnav rejects some files but accept some other files.
To Reproduce Steps to reproduce the behavior:
python3 -c 'print("", "-"*130000, "-"*140000, "-"*6100000, sep="\n")' > long.txt
lnav long.txt
But this works
python3 -c 'print("", "-"*130000, "-"*130000, "-"*6200000, sep="\n")'' > long.txt
lnav long.txt
I suspect there are memory issues.
Can you attach the crash file, I can't seem to replicate the issue with the provided steps.
How about this?
python3 -c 'print("-"*375, "-"*142448, "-"*142233, "-"*7182753, sep="\n")' > long.txt
lnav long.txt
This is the crash file. crash-2022-05-20-17-29-20.1620112.log
Here are gdb log
Thread 1 "lnav" received signal SIGABRT, Aborted.
                                                 raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:49
49      in ../sysdeps/unix/sysv/linux/raise.c
(gdb) up
#1  0x00000000009807ee in log_abort () at lnav_log.cc:611                                                                                                                                                                                            ?:View Help
611         raise(SIGABRT);
(gdb) up
#2  0x000000000066a521 in line_buffer::resize_buffer (this=0x7fffe0000f00, new_max=4325376) at line_buffer.cc:392
392         require(this->lb_bz_file || this->lb_gz_file
(gdb) l
392         require(this->lb_bz_file || this->lb_gz_file
393                 || new_max <= MAX_LINE_BUFFER_SIZE);
(gdb) p new_max
$6 = 4325376
(gdb) p MAX_LINE_BUFFER_SIZE
$7 = 4194304
(gdb) up
#3  0x000000000066a97f in line_buffer::ensure_available (this=0x7fffe0000f00, start=285059, max_length=4194304) at line_buffer.cc:480
480                 this->resize_buffer(roundup_size(max_length, DEFAULT_INCREMENT));
(gdb) p max_length
$8 = 4194304
(gdb) p DEFAULT_INCREMENT
$9 = 131072
(gdb) p *this
$16 = (line_buffer) {
  _vptr$line_buffer = 0xa20240 <vtable for line_buffer+16>,
  static DEFAULT_LINE_BUFFER_SIZE = 262144,
  static MAX_LINE_BUFFER_SIZE = 4194304,
  lb_share_manager = {
    sb_refs = std::vector of length 0, capacity 4
  },
  lb_fd = {
    af_fd = 17
  },
  lb_gz_file = {
    strm = {
      next_in = 0x0,
      avail_in = 0,
      total_in = 0,
      next_out = 0x0,
      avail_out = 0,
      total_out = 0,
      msg = 0x0,
      state = 0x0,
      zalloc = 0x0,
      zfree = 0x0,
      opaque = 0x0,
      data_type = 0,
      adler = 0,
      reserved = 0
    },
    syncpoints = std::vector of length 0, capacity 0,
    inbuf = {
      am_ptr = 0x7fffe0001140 "",
      am_free_func = 0x4128f0 <free@plt>
    },
    gz_fd = -1
  },
  lb_bz_file = false,
  lb_compressed_offset = 0,
  lb_buffer = {
    am_ptr = 0x7fffe72dc010 '-' <repeats 200 times>...,
    am_free_func = 0x4128f0 <free@plt>
  },
  lb_file_size = -1,
  lb_file_offset = 285059,
  lb_file_time = 0,
  lb_buffer_size = 4063232,
  lb_buffer_max = 4063232,
  lb_seekable = true,
  lb_last_line_offset = 285059
}
(gdb) up
#4  0x000000000066aa72 in line_buffer::fill_range (this=0x7fffe0000f00, start=285059, max_length=4194304) at line_buffer.cc:499
499             this->ensure_available(start, max_length);
(gdb) up
#5  0x000000000066b715 in line_buffer::load_next_line[abi:cxx11](file_range) (this=0x7fffe0000f00, prev_line=...) at line_buffer.cc:757
757             if (!done && !this->fill_range(offset, request_size)) {
(gdb) p retval
$13 = {
  li_file_range = {
    fr_offset = 285059,
    fr_size = 4063232
  },
  li_partial = true,
  li_valid_utf = true
}
(gdb) up
#6  0x00000000007ba291 in logfile::rebuild_index (this=0x7fffe0000c50, deadline=...) at logfile.cc:458
458                 auto load_result = this->lf_line_buffer.load_next_line(prev_range);
(gdb) p prev_range
$10 = {
  fr_offset = 142825,
  fr_size = 142234
}
Hope this helps.
Could you reproduce this issue?