On Wed, May 23, 2018 at 11:03 AM raf <[email protected]> wrote:

> Bram Moolenaar wrote:
>
> > > Bram Moolenaar wrote:
> > >
> > > > > Hi, Just reporting a few test failures.
> > > > > I don't know if they're important or not.
> > > > > The message about "ttype" is really about "ttytype".
> > > > > When I "set ttytype=xxx" manually, vim does accept it.
> > > > > And term does default to ansi when I don't have
> > > > > $TERM set and check it manually.
> > > > >
> > > > > cheers,
> > > > > raf
> > > > >
> > > > > vim-8.0.1806, macos-10.11.6, XQuartz-2.7.11 (xorg-server 1.18.4),
> openmotif-2.3.8 from macports:
> > > > >
> > > > > $ gcc --version
> > > > > Configured with:
> --prefix=/Applications/Xcode.app/Contents/Developer/usr
> --with-gxx-include-dir=/usr/include/c++/4.2.1
> > > > > Apple LLVM version 8.0.0 (clang-800.0.42.1)
> > > > > Target: x86_64-apple-darwin15.6.0
> > > > > Thread model: posix
> > > > > InstalledDir:
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
> > > > >
> > > > > $ ./configure \
> > > > >     --disable-darwin \
> > > > >     --with-x \
> > > > >     --enable-gui=motif \
> > > > >     --enable-multibyte \
> > > > >     --with-mac-arch=current \
> > > > >     --with-features=huge \
> > > > >     --disable-acl
> > > > >
> > > > > $ make
> > > > > [...]
> > > > > $ make test
> > > > > [...]
> > > > >
> > > > > Found errors in Test_default_term():
> > > > > function RunTheTest[38]..Test_default_term line 9: Pattern
> 'defaulting to ''ansi''' does not match 'E437: terminal capability "cm"
> required\r\nPress ENTER or type command to continue\r\r\n'
> > > > >
> > > > >
> > > > > >From test_options.vim:
> > > > > Found errors in Test_set_ttytype():
> > > > > function RunTheTest[38]..Test_set_ttytype line 22: set ttype=xxx
> did not fail
> > > > >
> > > > > >From test_startup.vim:
> > > > > Found errors in Test_default_term():
> > > > > function RunTheTest[38]..Test_default_term line 9: Pattern
> 'defaulting to ''ansi''' does not match 'E437: terminal capability "cm"
> required\r\nPress ENTER or type command to continue\r\r\n'
> > > >
> > > > That is strange.  Could you run a debugger and see what happens when
> you
> > > > do ":set ttytype=xxx"?  Why does it not produce an error?
> > >
> > > Hi Bram,
> > >
> > > Sorry for the delay. It is really strange.
> > > I've attached a script output of a debug session
> > > because what I'm seeing makes no sense.
> > >
> > > It looks like set_termname() calls term_is_builtin("xxx")
> > > which does: return (STRNCMP(name, "builtin_", (size_t)8) == 0).
> > > It does this a few times. The second time, the return value
> > > must be 1 because set_termname() then does term += 8 which
> > > leaves the term variable in a garbage state == "\x06".
> > > There end up being more calls to term_is_builtin() that I
> > > couldn't follow by reading the code. I guess the optimizer
> > > is reordering things. But I really can't see why it would be
> > > calling term_is_builtin() more than once. Maybe I'm doing
> > > something wrong in the debugger.
> > >
> > > So it looks like maybe some memory corruption that causes
> > > vim to think that "xxx" looks like "builtin_something" so
> > > it then tries to look up the "something" in find_builtin_term()
> > > but it can't find it because it's really "\x06". I don't know
> > > what happens after that.
> > >
> > > When replaying the script trace, there is some output that I didn't
> > > see (such as five lines of garbage after the "continue" command
> > > and the listing of environment variable names after exiting the
> > > debugger. So ignore that.
> > >
> > > I hope it helps.
> >
> > I don't know what to do with the attached script...
> >
> > It sounds like the optimizer is confusing you.  Can you reproduce the
> > problem when compiling without optimizing (remove -O2 from CFLAGS, or
> > add -O0 (letter O, zero), then "make reconfig".
> >
> > Obviously, when the name is "xxx" there is no match with "builtin_" and
> > the pointer should not be increased by 8.  If that happens it might be
> > an optimizer bug.
>
> The attached script output was created with the command:
>
>   script -r vim81-set-ttytype=xxx-debug.script
>
> and can be replayed with the command:
>
>   script -p vim81-set-ttytype=xxx-debug.script
>
> Hmm, my computer must have been hit by cosmic rays.
> To change the optimisation, I did:
>
>   make distclean
>   CFLAGS="-g -O0" configure ...
>   make
>
> And now "set ttytype=xxx" correctly issues an error message
> (regardless of the optimisation level) but configure can
> no longer find my macports openmotif includes or library.
> That's bizarre. It could find them a few days ago.
>

I had been ROMing 'cause I couldn't reproduce, and the Motif thing was one
of the things that made me wonder.

With MacPorts, openmotif is installed with the prefix /opt/local/ just like
other ports, and the configure script doesn't know about that unless
there's some help of pkg-config or scripts like ncurses6-config.   So, you
usually need to do either

$ ./configure --with-x-includes=/opt/local/include
--with-x-libraries=/opt/local/lib --enable-gui=motif <other options...>

or

$ CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' ./configure
--enable-gui=motif <other options...>

(Just like you install Motif in /usr/local/ on Linux or other UNIX-like
systems.)


> It's probably safe to ignore these test failures.
>

Using lldb, I disassembled term_is_builtin() which was inlined into
set_termname() by -O2.  What I saw there was as trivial as hand-written
assembly code and hence I easily found there was nothing wrong with it.
According to the disassembled code of set_termname(), I found it true that
the statement "term+=8;" is evaluated even for the case where term is not
in the form of "builtin_something", but the evaluation is done before "if
(term_is_builtin(term))".  IOW, the optimization changes the order of the
instructions.  Apparently, the resulting term points to a garbage, but the
original value of term is optimized away, or retained somewhere else, for
later use.

(BTW, I'm still not sure if the punctuation above is correct or not...
What should I do?)

Regards,
Kazunobu

Something wierd is going on here. :-)
>
> cheers,
> raf
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui