From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Vim segv'ing
Date: Fri, 01 Jul 2011 08:36:00 -0000 [thread overview]
Message-ID: <20110701083603.GM9552@calimero.vinschen.de> (raw)
In-Reply-To: <20110630150502.GJ9552@calimero.vinschen.de>
On Jun 30 17:05, Corinna Vinschen wrote:
> On Jun 30 16:23, Corinna Vinschen wrote:
> > On Jun 30 07:30, Nellis, Kenneth wrote:
> > > > From: Corinna Vinschen
> > > > Works fine for me. If I'm admin, writing works, if I'm not admin,
> > > > writing fails with permission denied. Could you please send your
> > > > cygcheck output per http://cygwin.com/problems.html as well as an
> > > > strace which shows what happens, like this:
> > > >
> > > > $ strace -o vim.trace vim-nox /etc/hosts
> > > > :wq!
> > >
> > > FWIW, I see the same problem as the OP. The strace command interferes
> > > with vim so that it won't recognize ESC to allow the ":" to be
> > > recognized, so I can't ":wq!" as requested. strace output nevertheless
> > > attached as is cygcheck -svr output.
> >
> > You strace shows nothing, it just stops at one point. Are you running
> > from a console or from mintty? When running in a console in default
> > notty mode, :w! or :wq! works fine. Can you try again? Perhaps with
> > other strace flags?
> >
> > strace -o vim.trace -m 0xffff vim-nox /etc/hosts
>
> I suddenly can reproduce the problem. For some reason it occurs only if
> both, vim and the Cygwin DLL, are compiled with -O2. Darn. This does
> not make debugging exactly easier :-P All I can say at this point is
> that the stack gets overwritten at one point.
FYI, I tracked it down to the place where the stack overwrite occurs.
This is most puzzeling. When typing :wq!, the following chain of functions
is called:
nv_colon
do_cmdline
ex_exit
do_write
open <- Here it calls into the Cygwin DLL
fhandler_base::open_with_arch
fhandler_base::open_fs
fhandler_base::open
NtCreateFile <--Here it calls into NTDLL.DLL
The open call tries to open the backup file "/etc/hosts~", not the
symlink itself.
In the optimized version of vim, the local variable "cap" in the
function nv_colon is kept in register $esi. When do_cmdline is called,
$esi is pushed onto the stack. Then everything goes its normal ways,
until NtCreateFile is called.
And here's the puzzler: This call to NtCreateFile overwrites the 4 byte
stack slot in which the "cap" pointer is saved with the value 0x10c!
After return from do_cmdline, nv_colon uses cap in an expression and
since cap is a pointer value, when dereferencing the pointer, vim
crashes.
I checked this situation a couple of times in assembler. The cap
value is fine up to the "call NtCreateFile@44", and it's changed to
0x10c when NtCreateFile returns.
I don't understand that. Not only that NtCreateFile is not supposed to
change values on the stack in the stack frame 8 functions above, I also
don't know what the value 0x10c is. It's not the HANDLE returned by
NtCreateFile, that's 0x1e4.
Well, that's it. I just had to vent a bit since I have no idea how
to proceed at this point. I can see and prove that the NtCreateFile
call overwrites the stack, but it's totally unlikely that NtCreateFile
would ever do that. The OS would be broken.
Oh, and here's a last-minute surprise: It does not happen if you run
gvim, rather than vim. Maybe I should just give up to provide packages.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2011-07-01 8:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 19:35 Andrew DeFaria
2011-06-29 22:28 ` Jeremy Hetzler
2011-06-29 22:43 ` Jeremy Hetzler
2011-06-30 7:20 ` Corinna Vinschen
2011-06-30 12:32 ` Nellis, Kenneth
2011-06-30 14:24 ` Corinna Vinschen
2011-06-30 15:05 ` Corinna Vinschen
2011-07-01 8:36 ` Corinna Vinschen [this message]
2011-07-01 9:44 ` Corinna Vinschen
2011-07-01 10:09 ` Yaakov Selkowitz
2011-07-01 10:21 ` Corinna Vinschen
2011-07-01 10:21 ` Andy Koppe
2011-07-01 11:44 ` Corinna Vinschen
2011-07-01 19:36 ` Chris Sutcliffe
2011-07-02 5:31 ` Charles Wilson
2011-07-02 23:49 ` Christopher Faylor
2011-07-04 22:29 ` Yaakov (Cygwin/X)
2011-07-05 9:10 ` Corinna Vinschen
2011-07-06 8:28 ` Yaakov (Cygwin/X)
2011-07-06 8:53 ` Corinna Vinschen
2011-06-30 20:09 ` Warren Young
2011-07-01 1:43 ` Chris Sutcliffe
2011-07-01 8:37 ` Corinna Vinschen
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=20110701083603.GM9552@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
/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).