public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kai Tietz <ktietz70@googlemail.com>
To: Patrick Wollgast <patrick.wollgast@rub.de>
Cc: "cmtice@google.com >> Caroline Tice" <cmtice@google.com>,
	Benjamin De Kosnik <bkoz@gnu.org>,
		"jwakely@redhat.com >> Jonathan Wakely" <jwakely@redhat.com>,
	Ian Lance Taylor <iant@google.com>,
		GCC Patches <gcc-patches@gcc.gnu.org>,
	"libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: [Ping] Port of VTV for Cygwin and MinGW
Date: Wed, 12 Nov 2014 18:45:00 -0000	[thread overview]
Message-ID: <CAEwic4YUkQfCo+hZi5BrYyurWzZ7FxLBxaR=HL5TuBdB38ePuA@mail.gmail.com> (raw)
In-Reply-To: <54639CC5.4050508@rub.de>

2014-11-12 18:45 GMT+01:00 Patrick Wollgast <patrick.wollgast@rub.de>:
>>
>> I don't think you have addressed all of the comments I made in the
>> comment, do you?
>>
>> Regards,
>> Kai
>>
>
> I added the three checks, if TARGET_PECOFF is defined, and fixed the
> whitespace issues.
>
> For the questions regarding C-runtime/Win32 functions I haven't changed
> anything in the patch but explained why I used those functions.
>
>>> Why you use instead of C-runtime exit/abort-functions the
>>> platform-functions to terminate the process.  This looks to me like
>>> useless change.  For cygwin this might be even wrong in some aspects.
>>> What is the reasoning for this change?
>>>
>>
>> I haven't encountered crashes in obstack.c itself, but there were
>> problems in vtv_rts.cc with abort() on MinGW 32bit. The following stack
>> traces were taken at MinGW 32bit. Most of the time the process had to be
>> stopped in the process manager because a wrong process handle was passed
>> to NtTerminateProcess. This was tested and occurred on Windows 7 64bit
>> and Windows 8.1 64bit. To be sure to avoid this issue the calls have
>> also been exchanged in obstack.c.
>>
>> With abort(), correct process handle, postmortem debugger triggert.
>>
>> ffffffff 00000003 0028fe98 ntdll!NtTerminateProcess+0xc
>> 00000003 77e8f3b0 ffffffff ntdll!RtlExitUserProcess+0x6d
>> 00000003 0028f934 74f85472 KERNEL32!ExitProcessImplementation+0x12
>> 00000003 11e9bfd9 00409000 msvcrt!exit+0x32
>> 00000003 00000001 00000000 msvcrt!flushall+0x2e9
>> 00000003 00010001 00000065 msvcrt!exit+0x11
>> 6efcf294 00000080 0028ffcc msvcrt!abort+0xf3
>> 00560f70 0000000d 00000001 libvtv_0!Z14__fortify_failPKc+0x18
>> 7ffde000 0028ffdc 77568f8b test_std+0x13de
>> 7ffde000 138a1dee 00000000 KERNEL32!BaseThreadInitThunk+0xe
>> ffffffff 7755dad3 00000000 ntdll!__RtlUserThreadStart+0x20
>> 004014e0 7ffde000 00000000 ntdll!_RtlUserThreadStart+0x1b
>>
>> With abort(), wrong process handle, NtTerminateProcess returns instead
>> of ending the own process. This case happens most of the time.
>>
>> 00000000 00000003 0028fe98 ntdll!NtTerminateProcess+0x5
>> 00000003 77e8f3b0 ffffffff ntdll!RtlExitUserProcess+0x35
>> 00000003 0028f934 74f85472 KERNEL32!ExitProcessImplementation+0x12
>> 00000003 9f9f5ea3 00409000 msvcrt!exit+0x32
>> 00000003 00000001 00000000 msvcrt!flushall+0x2e9
>> 00000003 00010001 00000040 msvcrt!exit+0x11
>> 6efcf294 00000080 0028ffcc msvcrt!abort+0xf3
>> 00701060 0000001e 00000001 libvtv_0!Z14__fortify_failPKc+0x18
>> 7ffde000 0028ffdc 77568f8b image00400000+0x13de
>> 7ffde000 9defd39c 00000000 KERNEL32!BaseThreadInitThunk+0xe
>> ffffffff 7755dac5 00000000 ntdll!__RtlUserThreadStart+0x20
>> 004014e0 7ffde000 00000000 ntdll!_RtlUserThreadStart+0x1b
>>
>> TerminateProcess. Everything's fine on MinGW x86, x86-64 (both gcc 5.0),
>> Cygwin x86-64 (gcc 4.9.0).
>>
>> ffffffff 0000022f 0028feb8 ntdll!NtTerminateProcess+0x5
>> ffffffff 0000022f 00409000 KERNELBASE!TerminateProcess+0x27
>> 00731060 0000001e 00000001 libvtv_0!Z14__fortify_failPKc+0x2a
>> 7ffde000 0028ffdc 77568f8b image00400000+0x13de
>> 7ffde000 e2645ec6 00000000 KERNEL32!BaseThreadInitThunk+0xe
>> ffffffff 7755dae7 00000000 ntdll!__RtlUserThreadStart+0x20
>> 004014e0 7ffde000 00000000 ntdll!_RtlUserThreadStart+0x1b

TerminateProcess is actually bad, as it doesn't call any of the atexit
handlers.  You simply nuke the process off.  For cygwin this behavior
is inacceptable.  Why a classical abort, or a classical exit call
cause for you that issues?  It seems to me more related to some other
thing you try to paper over by this.


> Regarding the question, why I reimplemented mprotect, I also haven't
> changed anything in the patch but answered the question.

And this doesn't make it better.  It is present in the static part of
libgcc.  Have you tried to declare it with extern "C" (for C++ case)
and simply use it?
Cygwin provides its own version too.  So there seems to me no real
need to re-implement it.

>>> Another note I have about re-implementation of mprotect in ---
>>> libvtv/vtv_malloc.cc.  Why you need that?  it is already part of
>>> libgcc for mingw.  And for cygwin this function is part of cygwin's
>>> library itself.  So why re-implementing it here?
>>>
>>
>> It is already part of libgcc for MinGW, but it can neither be found in
>> the exports of the dll, nor can the function prototype be found in any
>> header files. Therefore I get unknown reference errors if I don't
>> re-implement it. I checked the exports of several compilations for this.
>>
>> * self compiled MinGW
>> * MinGW installed from the Arch Linux repositories
>> *
>>
> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/mingw-w64-bin_x86_64-linux_20131228.tar.bz2/download
>>
>> If I'm missing something here let me know.
>
> I think this was everything you addressed.
>
> Regards,
> Patrick

Regards,
Kai

  reply	other threads:[~2014-11-12 18:40 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 11:04 Patrick Wollgast
2014-09-11  4:12 ` [Ping] " Patrick Wollgast
     [not found]   ` <CABtf2+RU7frwOXOX2FF8Tmfc6ssrpfFVj1Vuue4cZt19FpSWtQ@mail.gmail.com>
2014-09-12 22:44     ` Caroline Tice
2014-09-18 22:24       ` Patrick Wollgast
2014-09-23  6:16         ` Caroline Tice
2014-09-23 10:22         ` Jonathan Wakely
2014-09-24 22:25           ` Patrick Wollgast
2014-09-27 10:50             ` Kai Tietz
2014-10-09 13:56               ` Patrick Wollgast
2014-10-09 14:47                 ` Kai Tietz
2014-10-16 10:23                   ` Patrick Wollgast
2014-10-30 14:51                     ` Patrick Wollgast
2014-11-12 16:23                       ` Patrick Wollgast
2014-11-12 17:05                         ` Kai Tietz
2014-11-12 17:47                           ` Patrick Wollgast
2014-11-12 18:45                             ` Kai Tietz [this message]
2014-11-27  9:59                               ` Patrick Wollgast
2014-12-10 16:37                                 ` Patrick Wollgast
2015-01-04 20:10                                   ` Patrick Wollgast
2015-01-08 20:34                                     ` Patrick Wollgast
2015-01-12 18:32                                       ` Caroline Tice
2015-01-14 19:28                                       ` Ian Lance Taylor
2015-01-14 21:23                                         ` Patrick Wollgast
2015-01-14 23:56                                           ` Ian Lance Taylor
2015-01-15  8:34                                             ` Patrick Wollgast
2015-01-15 16:14                                               ` Ian Lance Taylor
2015-01-15 22:13                                                 ` Patrick Wollgast
2015-01-28 14:04                                                   ` Patrick Wollgast
2015-01-29  1:58                                                     ` Caroline Tice
2015-01-29 18:16                                                       ` Matthias Klose
2015-01-29 18:26                                                         ` Matthias Klose
2015-01-29 18:28                                                           ` Jonathan Wakely
2015-01-29 18:34                                                             ` H.J. Lu
2015-01-29 18:59                                                               ` H.J. Lu
2015-01-29 19:27                                                                 ` H.J. Lu
2015-01-29 18:30                                                           ` H.J. Lu
2015-01-29 18:53                                                             ` Matthias Klose
2015-01-29 19:39                                                               ` Jakub Jelinek
2015-01-29 19:55                                                                 ` H.J. Lu
2015-01-29 20:01                                                                   ` Jakub Jelinek
2015-01-29 20:08                                                                     ` H.J. Lu
2015-01-29 19:28                                                             ` Jakub Jelinek
2015-01-29 18:16                                                       ` H.J. Lu
2015-01-29 18:22                                                         ` H.J. Lu
2015-01-29 18:23                                                         ` Caroline Tice
2015-02-09 12:32                                                       ` Thomas Schwinge
2015-02-02 19:56                                                     ` Patrick Wollgast

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEwic4YUkQfCo+hZi5BrYyurWzZ7FxLBxaR=HL5TuBdB38ePuA@mail.gmail.com' \
    --to=ktietz70@googlemail.com \
    --cc=bkoz@gnu.org \
    --cc=cmtice@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=patrick.wollgast@rub.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).