Project

General

Profile

Bug #8349

[mingw] adding -mfpmath=sse -msse2 causes segv on Windows 7

Added by h.shirosaki (Hiroshi Shirosaki) about 5 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.1.0dev (2013-04-30 trunk 40528) [i386-mingw32]
[ruby-core:54716]

Description

I tried -mfpmath=sse -msse2 with mingw on Windows 7 and got 2 segv while make test-all.

Here is the detail.
https://gist.github.com/anonymous/5487498

I don't know why these options causes segv, but adding volatile seems to fix this.
Is this ok to commit?

diff --git a/re.c b/re.c
index fe7e390..5c96276 100644
--- a/re.c
+++ b/re.c
@@ -154,7 +154,8 @@ rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n
{
const unsigned char *x = xs, *xe = xs + m;
const unsigned char *y = ys;

  • VALUE i, qstable[256];
  • volatile VALUE i;
  • VALUE qstable[256];

    /* Preprocessing /
    for (i = 0; i < 256; ++i)
    diff --git a/regcomp.c b/regcomp.c
    index 1373ff2..8c0e2b5 100644
    --- a/regcomp.c
    +++ b/regcomp.c
    @@ -5306,7 +5306,7 @@ set_optimize_exact_info(regex_t
    reg, OptExactInfo* e)
    static void
    set_optimize_map_info(regex_t* reg, OptMapInfo* m)
    {

  • int i;

  • volatile int i;

for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
reg->map[i] = m->map[i];

Associated revisions

Revision b5faf430
Added by nobu (Nobuyoshi Nakada) over 4 years ago

configure.in: -mstackrealign

  • configure.in: -mstackrealign is necessary for -msse2 working. [Bug #8349]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 44539
Added by nobu (Nobuyoshi Nakada) over 4 years ago

configure.in: -mstackrealign

  • configure.in: -mstackrealign is necessary for -msse2 working. [Bug #8349]

Revision 44539
Added by nobu (Nobuyoshi Nakada) over 4 years ago

configure.in: -mstackrealign

  • configure.in: -mstackrealign is necessary for -msse2 working. [Bug #8349]

Revision 44539
Added by nobu (Nobuyoshi Nakada) over 4 years ago

configure.in: -mstackrealign

  • configure.in: -mstackrealign is necessary for -msse2 working. [Bug #8349]

Revision 44539
Added by nobu (Nobuyoshi Nakada) over 4 years ago

configure.in: -mstackrealign

  • configure.in: -mstackrealign is necessary for -msse2 working. [Bug #8349]

Revision 44539
Added by nobu (Nobuyoshi Nakada) over 4 years ago

configure.in: -mstackrealign

  • configure.in: -mstackrealign is necessary for -msse2 working. [Bug #8349]

Revision c83ad9aa
Added by naruse (Yui NARUSE) over 4 years ago

merge revision(s) 44474,44538,44539,44890,44896: [Backport #9495]

* configure.in: use SSE2 instructions for drop unexpected
  precisions.   [Bug #8358]

* configure.in: use SSE2 instructions to drop unexpected precisions on
  other than mingw.   [Bug #8358]

* configure.in: -mstackrealign is necessary for -msse2 working.
   [Bug #8349]

* configure.in: -mstackrealign is necessary for -msse2 working.
   [Bug #8349]

* configure.in: add qouting brackets and append wildcard for the
  rest after target_cpu, to properly detect platform for SSE2
  instructions.   [Bug #8358]

* configure.in: Fix compilation error.
  https://bugs.ruby-lang.org/issues/8358#note-16

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 712da8a8
Added by usa (Usaku NAKAMURA) almost 4 years ago

merge revision(s) 44474,44538,44539,44890,44896,45954: [Backport #8358]

* configure.in: use SSE2 instructions for drop unexpected
  precisions.   [Bug #8358]

* configure.in: use SSE2 instructions to drop unexpected precisions on
  other than mingw.   [Bug #8358]

* configure.in: -mstackrealign is necessary for -msse2 working.
   [Bug #8349]

* configure.in: -mstackrealign is necessary for -msse2 working.
   [Bug #8349]

* configure.in: add qouting brackets and append wildcard for the
  rest after target_cpu, to properly detect platform for SSE2
  instructions.   [Bug #8358]

* configure.in: Fix compilation error.
  https://bugs.ruby-lang.org/issues/8358#note-16

* configure.in: enable SSE2 on mingw. target='i386-pc-mingw32'.
   [Bug #8358]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 46514
Added by usa (Usaku NAKAMURA) almost 4 years ago

merge revision(s) 44474,44538,44539,44890,44896,45954: [Backport #8358]

* configure.in: use SSE2 instructions for drop unexpected
  precisions.   [Bug #8358]

* configure.in: use SSE2 instructions to drop unexpected precisions on
  other than mingw.   [Bug #8358]

* configure.in: -mstackrealign is necessary for -msse2 working.
   [Bug #8349]

* configure.in: -mstackrealign is necessary for -msse2 working.
   [Bug #8349]

* configure.in: add qouting brackets and append wildcard for the
  rest after target_cpu, to properly detect platform for SSE2
  instructions.   [Bug #8358]

* configure.in: Fix compilation error.
  https://bugs.ruby-lang.org/issues/8358#note-16

* configure.in: enable SSE2 on mingw. target='i386-pc-mingw32'.
   [Bug #8358]

History

#1 [ruby-core:54717] Updated by naruse (Yui NARUSE) about 5 years ago

うーん、SSE を使って自動ベクトル化するときに何かバグを踏んでいるんですかねぇ。
objdump か何かでそれぞれの関数を逆アセンブルして貼って頂けませんか。

#3 [ruby-core:54720] Updated by h.shirosaki (Hiroshi Shirosaki) about 5 years ago

  • Status changed from Assigned to Closed

phasis68 (Heesob Park) wrote:

I think -mstackrealign flag is the proper solution of this issue.

Refer to
http://www.peterstock.co.uk/games/mingw_sse/
http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html#index-mpc80-1472

Thank you. I'll use -mstackrealign with sse.

I've confirmed that with disassemble.
https://gist.github.com/shirosaki/5488699

#4 [ruby-core:63249] Updated by nagachika (Tomoyuki Chikanaga) about 4 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: UNKNOWN, 2.0.0: DONE

r44539 was already backported into ruby_2_1 at r44993.

Also available in: Atom PDF