Major Tools
Other Tools
General Info

Issue #1443

Calling $display with real %t argument causes segfault in _vl_vsformat

Added by Julien Margetts 6 days ago. Updated about 8 hours ago.

% Done:



Standalone minimal test case attached

Output running executable under GDB:

TestCase at 1 this is fine TestCase at 1 this is fine TestCase at 1 this is fine TestCase at 1 this is fine

Program received signal SIGSEGV, Segmentation fault. 0x000000000040510c in _vl_vsformat(std::string&, char const*, __va_list_tag*) () Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7_3.1.x86_64 libgcc-4.8.5-11.el7.x86_64 libstdc++-4.8.5-11.el7.x86_64 (gdb) bt #0 0x000000000040510c in _vl_vsformat(std::string&, char const*, __va_list_tag*) () #1 0x0000000000407b2f in VL_WRITEF(char const*, ...) () #2 0x0000000000414254 in VBUG::_sequent__TOP__1(VBUG__Syms*) () #3 0x00000000004142ca in VBUG::_eval(VBUG__Syms*) () #4 0x0000000000414088 in VBUG::eval() () #5 0x000000000040226b in main ()

BUG.cpp View - Testbench (579 Bytes) Julien Margetts, 05/16/2019 03:30 PM

BUG.v - Problem module (276 Bytes) Julien Margetts, 05/16/2019 03:30 PM

Makefile - Make file (231 Bytes) Julien Margetts, 05/16/2019 03:30 PM

time_format.patch View - __vl_vsformat patch (1.47 KB) Julien Margetts, 05/21/2019 02:13 PM


#1 Updated by Julien Margetts 6 days ago

The segfault seems to be dependent upon the %t time format output, and the call to $realtime also being present.

Without these, it works fine.

I was also surprised the time output by $display is always "1" in this case, even though I am incrementing time in the testbench, though I may be doing something wrong here ...

#2 Updated by Wilson Snyder 5 days ago

  • Subject changed from Calling $display with run-time dependent %s arguments causes segfault in _vl_vsformat to Calling $display with real %t argument causes segfault in _vl_vsformat
  • Category set to TranslationError
  • Status changed from New to Resolved
  • Assignee set to Wilson Snyder

Thanks for the test case.

Basically %t didn't support real numbers ($realtime).

Fixed in git towards 4.015.

#3 Updated by Julien Margetts about 19 hours ago

Great, fix confirmed, thanks.

One very minor observation. For consistency with other simulators, could we suffix %t output with "ns/us" to distinguish the value as a time?

Suggested patch attached

#4 Updated by Wilson Snyder about 8 hours ago

Re time format:

IEEE does not say to print "ns" by default. I suspect what you have is a call to $timeformat specifying that string. Verilator doesn't implement $timeformat (see e.g. test_regress/t/t_display_time.v). If you want to have this supported please file a new bug, and it would be great if you would consider a patch to implement it (e.g. parse it, then pass into C file, then verilated.c saves the values to affect printing). Thanks

Also available in: Atom