freehdl's /usr/bin/freehdl-v2cc crashes with sigsegv

Bug #1781054 reported by Davorin Vlahović
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
freehdl (Gentoo Linux)
Expired
Medium
freehdl (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

When running freehdl-v2cc[1] on Bionic[2] it crashes with segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b7c078 in m_vaul_compute_static_level(IIR_ConstantInterfaceDeclaration*) () from /usr/lib/libfreehdl-vaul.so.0

Before that it complains about improper memory access:
__GI__IO_file_open (is32not64=1, read_write=8, prot=438, posix_mode=<optimized out>,
    filename=0x8 <error: Cannot access memory at address 0x8>, fp=0x5555558629f0) at fileops.c:190

It looks like this:

$gvhdl test.vhd
gvhdl: FreeHDL root path is '/usr'.
gvhdl: executing '/usr/bin/freehdl-v2cc -m test._main_.cc -L /usr/share/freehdl/lib -o test.cc test.vhd'
gvhdl: Compilation failed!
Died at /usr/bin/gvhdl line 211.

[1] freehdl:
  Installed: 0.0.8-2.2ubuntu2
libfreehdl0:
  Installed: 0.0.8-2.2ubuntu2
libfreehdl0-dev:
  Installed: 0.0.8-2.2ubuntu2

[2] $lsb_release -rd
Description: Ubuntu 18.04 LTS
Release: 18.04

Tags: bionic patch
Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 522474
freehdl-0.0.8-declerative_region.patch

With sci-electronics/freehdl-0.0.8 the freehdl-v2cc command returns Segmentation fault even for the simplest VHDL demo (https://ghdl.readthedocs.io/en/latest/using/QuickStartGuide.html). It also does for any schematic I tried in Qucs.

I did some backtrace and suggest a patch which seems to fix this issue.

As the source file 'v2cc/v2cc-chunk.t' states,

    ;; respect to the entity). Note that the value is set to NULL if
    ;; the object/declaration/expression is not static at all!
    (IIR_DeclarativeRegion static_declarative_region (= "NULL"))

so my patch provides a simple check of the NULL pointer. I am not sure my solution is correct, but at least, it allows me to use freehdl-v2cc.

Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 522476
freehdl-0.0.8-la.patch

sci-electronics/freehdl-0.0.8 installs the .la files.
This patch is to remove the references to these files, and substitute them by the correct values.

The fix is taken from these posts:
https://bugzilla.redhat.com/show_bug.cgi?id=1207310#c3
https://bugzilla.redhat.com/show_bug.cgi?id=1207310#c6

Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 522478
freehdl-0.0.8-r1.ebuild

This ebuild incorporates the two patches suggested above, and also fixes these problems:

1. undefined reference to L4ieee_Q14std_logic_1164_Y0y0_i51 and several other symbols in libieee.so

This issue is fixed by removing all the .cc files in 'ieee' subdirectory prior to build. These .cc files are generated during the build process, but they are shipped in the package archive for some reason. Probably, it was the developer's mistake. So I simply delete them, and everything builds correctly.

2. Since the .la files are deleted, in order for the later use of the libieee.so library, the '/etc/ld.so.conf.d/freehdl.conf' file is created. This was also grabbed from here: https://bugzilla.redhat.com/show_bug.cgi?id=1207310#c3

tags: added: bionic
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in freehdl (Ubuntu):
status: New → Confirmed
Revision history for this message
v_2e (v-2e) wrote :

My patch suggested in the corresponding Gentoo Bug (also attached here) allows to avoid the reported segfault. However, this solution is highly questionable, since I do not know what actually has this piece of code look like.

After fixing this segfault I encountered the following problem:

  undefined reference to L4ieee_Q14std_logic_1164_Y0y0_i51 libieee.so

This is because the wrong (and unnecessary) files shipped in the source tarball. They may be simply deleted before building the package (as I described here https://bugs.gentoo.org/649700#c2).

This being said and "fixed", now I experience another problem at the simulation stage -- another segfault, but in different place.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "freehdl-0.0.8-declerative_region.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in freehdl (Gentoo Linux):
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
v_2e (v-2e) wrote :

I had to apply several patches from Gentoo Portage, also from the mentioned Gentoo bug, and make numerous edits to the code by myself. And eventually I was able to build the DEB-package for Ubuntu Bionic using the set of patches attached here.
Please note however, that I am not a programmer, and therefore my "fixes" may be rather stupid. But as far as I tested thus built FreeHDL package with some simple schematics in Qucs, everything worked fine. So I hope my patches will be useful to somebody, and preferably be reviewed by someone more competent.

Revision history for this message
v_2e (v-2e) wrote :

I cleaned the patches a little and added a couple of minor fixes.

Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 634540
freehdl-0.0.8-r2.ebuild

An updated ebuild incorporating all the newly added patches. I am not sure about setting the CXXFLAGS variable inside the ebuild, but I had to add this flag in order to build FreeHDL on relatively modern system.

Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 634542
freehdl-0.0.8-cpp-modern.patch

An updated patch for modern GCC versions in place of the previously used "fix-c++14.patch".

Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 634544
freehdl-0.0.8-acl-NULL-check.patch

This new patch finally fixes a long-lasting problem with segfault because of the NULL pointer.

Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 634546
freehdl-0.0.8-declarative_region.patch

Just fixed the file name (here and in new ebuild too).

Revision history for this message
In , v_2e (v2e-gentoo-bugs) wrote :

Created attachment 634548
freehdl-0.0.8-gvhdl_tag_command.patch

I have no idea what this patch actually fixes, but I found in in Ubuntu package. So I suggest it for the developers' review.

Changed in freehdl (Gentoo Linux):
status: New → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.