排查vcd2fst段错误时调试信息不​​正确

Incorrect debugging information when troubleshooting vcd2fst segmentation fault

我正在使用 vcd2fst 工具(与 GTKwave 一起安装)使用以下命令将 .vcd 文件转换为 .fst

vcd2fst -v wave.vcd -f dummy.fst

这在我的主机 Ubuntu 18.04 机器上工作正常。

同时,当在 Ubuntu 16.04 虚拟机上启动相同的命令(和相同版本的工具)时,会产生 Segmentation Fault (core dumped).

尝试使用 GDB 调试结果如下,我猜这与内存分配有关,但即使我将分配的 RAM 从 2GB 增加到 8GB,同样的问题仍然存在。有什么想法吗?

gdb --args vcd2fst -v wave.vcd -f dummy.fst
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from vcd2fst...done.
(gdb) run
Starting program: /usr/local/bin/vcd2fst -v wave.vcd -f dummy.fst
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000403de3 in LZ4_hashSequence64 (tableType=<optimized out>, 
    sequence=<optimized out>) at ./fst/lz4.c:420
420 ./fst/lz4.c: No such file or directory.
(gdb) 

以下是段错误发生后的回溯:

(gdb) backtrace
#0  0x0000000000403de3 in LZ4_hashSequence64 (tableType=<optimized out>, 
    sequence=<optimized out>) at ./fst/lz4.c:420
#1  LZ4_hashSequenceT (tableType=<optimized out>, sequence=<optimized out>)
    at ./fst/lz4.c:403
#2  LZ4_hashPosition (tableType=byU32, p=0xffffffffffffffff) at ./fst/lz4.c:407
#3  LZ4_putPosition (
    p=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, tableBase=0x7fffffff1a40, tableType=byU32, 
    srcBase=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>) at ./fst/lz4.c:421
#4  0x00000000004049a2 in LZ4_compress_generic (acceleration=<optimized out>, 
    dictIssue=noDictIssue, dict=noDict, tableType=byU32, 
    outputLimited=notLimited, maxOutputSize=0, inputSize=741835, 
    dest=0x77b6a0 "x25Y5r37\f60K-WZ3Ό2ؖ2S2h'51i3;333͵56rȱ禽5[=12=]1<}2>C;}72[=12=]315j%3r2I34!/7@0[=12=]4@0", 
    source=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, ctx=0x7fffffff1a40) at ./fst/lz4.c:492
#5  LZ4_compress_fast_extState (state=state@entry=0x7fffffff1a40, 
    source=source@entry=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, 
    dest=dest@entry=0x77b6a0 "x25Y5r37\f60K-WZ3Ό2ؖ2S2h'51i3;333͵56rȱ禽5[=12=]1<}2>C;}72[=12=]315j%3r2I34!/7@0[=12=]4@0", 
    inputSize=<optimized out>, maxOutputSize=<optimized out>, 
    acceleration=<optimized out>, acceleration@entry=1) at ./fst/lz4.c:670
#6  0x0000000000405480 in LZ4_compress_fast (
    source=source@entry=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, 
    dest=dest@entry=0x77b6a0 "x25Y5r37\f60K-WZ3Ό2ؖ2S2h'51i3;333͵56rȱ禽5[=12=]1<}2>C;}72[=12=]315j%3r2I34!/7@0[=12=]4@0", 
    inputSize=<optimized out>, maxOutputSize=<optimized out>, 
    acceleration=acceleration@entry=1) at ./fst/lz4.c:691
---Type <return> to continue, or q <return> to quit---
#7  0x000000000040b183 in LZ4_compress_default (maxOutputSize=<optimized out>, 
    inputSize=<optimized out>, 
    dest=0x77b6a0 "x25Y5r37\f60K-WZ3Ό2ؖ2S2h'51i3;333͵56rȱ禽5[=12=]1<}2>C;}72[=12=]315j%3r2I34!/7@0[=12=]4@0", 
    source=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>) at ./fst/lz4.c:702
#8  LZ4_compress (
    source=source@entry=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, 
    dest=dest@entry=0x77b6a0 "x25Y5r37\f60K-WZ3Ό2ؖ2S2h'51i3;333͵56rȱ禽5[=12=]1<}2>C;}72[=12=]315j%3r2I34!/7@0[=12=]4@0", inputSize=<optimized out>)
    at ./fst/lz4.c:1459
#9  0x00000000004145a0 in fstWriterClose (ctx=ctx@entry=0x62e5f0)
    at ./fst/fstapi.c:2031
#10 0x00000000004029d6 in fst_main (vname=vname@entry=0x61e370 "wave.vcd", 
    fstname=fstname@entry=0x61e390 "dummy.fst") at vcd2fst.c:1580
#11 0x0000000000401fa2 in main (argc=5, argv=0x7fffffffdce8) at vcd2fst.c:1822

这是作者 Anthony Bybell 建议的对我有用的解决方案:

在 "mmap compatibility" 部分的第 311 行之前添加以下行。

#define __CYGWIN__