Bug 52787 - Segmentation fault on MinGW
Summary: Segmentation fault on MinGW
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libitm (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-30 03:39 UTC by niXman
Modified: 2012-03-30 20:15 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description niXman 2012-03-30 03:39:28 UTC
This code successfully compiled but on run crashes:

// { dg-do run }

extern "C" void abort ();

int dothrow;
int g;

static void f1()
{
  g++;
  if (dothrow)
    throw 1;
}

static void f2()
{
  __transaction_atomic {
    f1();
  }
}

int main()
{
  dothrow = 0;
  f2();

  dothrow = 1;
  try {
    f2();
  } catch (...) {
  }

  if (g != 2)
    abort ();
  return 0;
}

-------------------------------------------------------------------------

Coompiler:
$ g++ -v

Using built-in specs.
COLLECT_GCC=e:\mingw32\bin\g++.exe
COLLECT_LTO_WRAPPER=e:/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.7.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../mingw-src/gcc-4.7.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --enable-targets=all --enable-multilib --prefix=/./mingw-x32 --with-sysroot=/./mingw-x32 --with-tune=generic --enable-languages=c,c++,lto,fortran --enable-libstdcxx-time=yes --with-host-libstdcxx='-static -lstdc++' --enable-shared --enable-static --enable-threads=posix --enable-libgomp --enable-lto --enable-graphite --enable-cloog-backend=isl --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-sjlj-exceptions --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-debug --disable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-gmp=/./mingw-libs-x32 --with-mpfr=/./mingw-libs-x32 --with-mpc=/./mingw-libs-x32 --with-ppl=/./mingw-libs-x32 --with-cloog=/./mingw-libs-x32 CFLAGS='-O3 -pipe -fomit-frame-pointer -momit-leaf-frame-pointer -I/./mingw-libs-x32/include' CXXFLAGS='-O3 -pipe -fomit-frame-pointer -momit-leaf-frame-pointer' CPPFLAGS= LDFLAGS='-pipe -s -L/./mingw-libs-x32/lib'
Thread model: posix
gcc version 4.7.0

-------------------------------------------------------------------------

Output log from gdb:

Program received signal SIGSEGV, Segmentation fault.
(anonymous namespace)::serialirr_dispatch::ITM_RU4 (this=0x81c0d8, ptr=0x1)
    at E:/msys/mingw-src/gcc-4.7.0/libitm/method-serial.cc:90
90	  CREATE_DISPATCH_METHODS(virtual, )


-------------------------------------------------------------------------
Comment 1 Ian Lance Taylor 2012-03-30 14:38:57 UTC
Based to your e-mail on gcc-help, you left out a very important piece of information.  This is using a build with the following patch:

> Moreover, if I replace line 134 in file gccroot/libitm/configure.tgt [1] from:
> >   | *-*-darwin* | *-*-aix*)
> to:
> >   | *-*-darwin* | *-*-aix* | *-w64-mingw32)

As far as I know libitm is not expected to work on MinGW.
Comment 2 niXman 2012-03-30 19:55:51 UTC
>Based to your e-mail on gcc-help, you left out a very important piece of
information.
Yes, Ian. I had to mention it.
And yes, I'm not saying that libitm is supported by MinGW. And yes, as libitm is not supported by MinGW - it's not a bug. I hurried with the creation of the bug report.

I'd really like to make libitm work with MinGW. I would like to understand why SIGSEGV occurs...

Thanks.
Comment 3 Kai Tietz 2012-03-30 20:15:13 UTC
(In reply to comment #2)
> >Based to your e-mail on gcc-help, you left out a very important piece of
> information.
> Yes, Ian. I had to mention it.
> And yes, I'm not saying that libitm is supported by MinGW. And yes, as libitm
> is not supported by MinGW - it's not a bug. I hurried with the creation of the
> bug report.
> 
> I'd really like to make libitm work with MinGW. I would like to understand why
> SIGSEGV occurs...
> 
> Thanks.

Well, the configure patch required for this bug-report misses an important part AFAICS.  You have to make sure that pthread-API is present, as libitm depends on pthread.
This report is btw invalid, as this feature isn't supported for mingw targets right now. So I close it.  Please keep discussion about adding support for libitm on gcc's patches ML.