Project

General

Profile

Actions

Bug #13014

closed

Adding clang volatile fixes from FreeBSD and NetBSD

Added by _dim (Dimitry Andric) over 7 years ago. Updated about 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-12-08 trunk 57019) [i386-freebsd12.0]
[ruby-core:78531]

Description

Referring to bug #12893, where segfaults were observed when compiling with recent versions of clang. In particular in cont.c, about which Shugo Maeda noted that he could reproduce this on FreeBSD. These segfaults are most likely caused by missing volatile specifiers on certain variable declarations, in combination with the use of setjmp().

In https://bugs.freebsd.org/206111 (for ruby 2.3), we have applied a number of fixes for this, taken mostly from NetBSD's pkgsrc. These add a few volatile specifiers in critical places. I have also added one additional volatile specifier in cont_capture() in cont.c, and removed the special optnone handling for clang 3.8.0.

For me, on FreeBSD 12 with clang 3.9.1, and optimizing at -O3 for -march=haswell, this successfully completes "gmake test-all":

Finished tests in 461.890990s, 36.8312 tests/s, 4849.7937 assertions/s.
17012 tests, 2240076 assertions, 0 failures, 0 errors, 40 skips


Files

ruby-trunk-add-setjmp-volatile-1.diff (4.61 KB) ruby-trunk-add-setjmp-volatile-1.diff Patch adding several volatile specifiers, adapted from FreeBSD port _dim (Dimitry Andric), 12/07/2016 08:50 PM
ruby-trunk-add-setjmp-volatile-2.diff (5 KB) ruby-trunk-add-setjmp-volatile-2.diff Second revision of patch adding several volatile specifiers, adapted from FreeBSD port _dim (Dimitry Andric), 12/07/2016 10:00 PM

Updated by _dim (Dimitry Andric) over 7 years ago

Ok, I also tested this on x86_64-freebsd12, and there it still got a segfault in cont_capture(). This was caused by the stat parameter being a pointer to a volatile int, while it should have been a volatile pointer to an int.

Here is a second revision of the patch, including that change. I also updated the cont_capture() prototype to match.

Actions #2

Updated by shugo (Shugo Maeda) over 7 years ago

  • Status changed from Open to Closed

Applied in changeset r57020.


Add clang volatile fixes from FreeBSD and NetBSD.

Use volatile instead of optnone to avoid optimization which causes
segmentation faults.
Patch by Dimitry Andric. [ruby-core:78531] [Bug #13014]

Updated by _dim (Dimitry Andric) over 7 years ago

Can we please backport these fixes to 2.1, 2.2 and 2.3? I am willing to do the work for supplying the patches, as we already have them in the FreeBSD ports collection.

Does this require a new issue, or can we re-use this one?

Updated by usa (Usaku NAKAMURA) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED

Dimitry Andric wrote:

Can we please backport these fixes to 2.1, 2.2 and 2.3?

2.1 won't be fixed because it's in the phase of security maintenance.
But 2.2 and 2.3 will be fixed.

Does this require a new issue, or can we re-use this one?

You don't have to do anything now.
We stable branch maintainers are tracking this issue.
Thank you!

Updated by usa (Usaku NAKAMURA) about 7 years ago

  • Backport changed from 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: DONE, 2.3: REQUIRED

ruby_2_2 r57216 merged revision(s) 57020,57021.

Updated by nagachika (Tomoyuki Chikanaga) about 7 years ago

  • Backport changed from 2.1: WONTFIX, 2.2: DONE, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: DONE, 2.3: DONE

ruby_2_3 r57347 merged revision(s) 57020,57021.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0