Patch updated (again).

Changes:

1. Fix non-FEAT_GUI build failure by adding the definition of GUI_FUNCTION2
to that case.

2. Suppress compiler warnings of -Wsign-compare (of gcc5) by using type
case.

The patch was tested with non-FEAT_GUI, Athena, GTK2, and GTK3 with/without
termguicolors.

2016-05-01 16:00 GMT+09:00 Kazunobu Kuriyama <[email protected]>:

> Patch updated.
>
> Changes:
>
> 1. Handle the case where gui.in_use is true and pixel is INVALCOLOR, which
> was not handled explicitly by the previous patch.
>
> 2. Remove the newly added IF statements in the previous patch and replace
> them with the newly defined macro GUI_MCH_GET_RGB2, in which the value of
> pixel is checked so that INVALCOLOR is not passed to gui_mch_get_rgb().
>
> 2016-05-01 3:39 GMT+09:00 Kazunobu Kuriyama <[email protected]>:
>
>> 2016-04-30 22:17 GMT+09:00 Bram Moolenaar <[email protected]>:
>>
>>>
>>> Kelvin Lee wrote:
>>>
>>> > Patch 7.4.1784 is problematic.
>>> >
>>> > On both FreeBSD (10.3) and Linux (Ubuntu 16.04), the follow error
>>> would happen upon starting gvim:
>>> >
>>> > X Error of failed request:  BadValue (integer parameter out of range
>>> for operation)
>>> >   Major opcode of failed request:  91 (X_QueryColors)
>>> >   Value in failed request:  0xffffd499
>>> >   Serial number of failed request:  1159
>>> >   Current serial number in output stream:  1159
>>> > E852: The child process failed to start the GUI
>>> > Press ENTER or type command to continue[xcb] Unknown sequence number
>>> while processing queue
>>> > [xcb] Most likely this is a multi-threaded client and XInitThreads has
>>> not been called
>>> > [xcb] Aborting, sorry about that.
>>> > Assertion failed: (! xcb_xlib_threads_sequence_lost), function
>>> poll_for_event, file xcb_io.c, line 274.
>>> > Vim: Caught deadly signal ABRT
>>> >
>>> > Vim: Finished.
>>> > Abort trap (core dumped)
>>> >
>>> > My gvim build version info:
>>> >
>>> > VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 30 2016 15:28:24)
>>> > Included patches: 1-1784
>>> > Compiled by kiyo@zion
>>> > Big version with X11-Athena GUI.  Features included (+) or not (-):
>>> > +acl             +farsi           +mouse_netterm   +tag_binary
>>> > +arabic          +file_in_path    +mouse_sgr       +tag_old_static
>>> > +autocmd         +find_in_path    +mouse_sysmouse  -tag_any_white
>>> > +balloon_eval    +float           +mouse_urxvt     -tcl
>>> > +browse          +folding         +mouse_xterm     +terminfo
>>> > ++builtin_terms  -footer          +multi_byte      +termresponse
>>> > +byte_offset     +fork()          +multi_lang      +termtruecolor
>>> > +channel         +gettext         -mzscheme        +textobjects
>>> > +cindent         -hangul_input    +netbeans_intg   +timers
>>> > +clientserver    +iconv           +packages        +title
>>> > +clipboard       +insert_expand   +path_extra      +toolbar
>>> > +cmdline_compl   +job             -perl            +user_commands
>>> > +cmdline_hist    +jumplist        +persistent_undo +vertsplit
>>> > +cmdline_info    +keymap          +postscript      +virtualedit
>>> > +comments        +langmap         +printer         +visual
>>> > +conceal         +libcall         -profile         +visualextra
>>> > +cryptv          +linebreak       -python          +viminfo
>>> > +cscope          +lispindent      -python3         +vreplace
>>> > +cursorbind      +listcmds        +quickfix        +wildignore
>>> > +cursorshape     +localmap        +reltime         +wildmenu
>>> > +dialog_con_gui  -lua             +rightleft       +windows
>>> > +diff            +menu            -ruby            +writebackup
>>> > +digraphs        +mksession       +scrollbind      +X11
>>> > -dnd             +modify_fname    +signs           +xfontset
>>> > -ebcdic          +mouse           +smartindent     +xim
>>> > +emacs_tags      +mouseshape      +startuptime     +xsmp_interact
>>> > +eval            +mouse_dec       +statusline      +xterm_clipboard
>>> > +ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
>>> > +extra_search    -mouse_jsbterm   +syntax          +xpm
>>> >    system vimrc file: "$VIM/vimrc"
>>> >      user vimrc file: "$HOME/.vimrc"
>>> >  2nd user vimrc file: "~/.vim/vimrc"
>>> >       user exrc file: "$HOME/.exrc"
>>> >   system gvimrc file: "$VIM/gvimrc"
>>> >     user gvimrc file: "$HOME/.gvimrc"
>>> > 2nd user gvimrc file: "~/.vim/gvimrc"
>>> >     system menu file: "$VIMRUNTIME/menu.vim"
>>> >   fall-back for $VIM: "/usr/local/share/vim"
>>> > Compilation: /usr/local/libexec/ccache/clang -c -I. -Iproto
>>> -DHAVE_CONFIG_H -DFEAT_GUI_ATHENA   -I/usr/local/include  -g -O2
>>> -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
>>> > Linking: /usr/local/libexec/ccache/clang   -L/usr/local/lib
>>> -Wl,--as-needed -o vim -lXaw -lXmu -lXext -lXt -lSM -lICE -lXpm -lXt -lX11
>>>  -lm -ltinfo  -liconv -lintl
>>>
>>> I can reproduce it when building with Athena.
>>>
>>
>> As indicated in the report above, the direct cause of the problem is to
>> pass, `INVALCOLOR` (= -11111 = 0xffffd499) to `XQueryColor()` via the
>> structure `XColor` in `gui_mch_get_rgb()` at gui_x11.c:3214.
>>
>> Although the type of the field `pixel` of `XColor` is unsigned long, the
>> valid range of pixel values is supposed to be from 0 to 65535, inclusive.
>>
>> Obviously, `INVALCOLOR` is out of the range, thus the BadValue error.
>>
>> The problematic `INVALCOLOR` comes from the macro `GUI_MCH_GET_RGB()`
>> which is used in `set_hl_attr()` at syntax.c:9194.
>>
>> `GUI_MCH_GET_RGB()` flips between `termgui_mch_get_rgb()` and
>> `gui_mch_get_rgb()`, depending on the value of the boolean `gui.in_use` at
>> runtime.
>>
>> Hence the trouble happens when `gui.in_use` is true (thus
>> `gui_mch_get_rgb()` is selected) and the given pixel value is `INVALCOLOR`.
>>
>> The proposed patch is to prevent `INVALCOLOR` from being passed to
>> `gui_mch_get_rgb()` by adding appropriate conditions when the function is
>> invoked.
>>
>> N.B. This bug potensially affects the GTK+2 GUI because its
>> `gui_mch_get_rgb()` uses `gdk_colorpmap_query_color()` and the latter calls
>> `XQueryColor()` directly under certain conditions.
>>
>> Best regards,
>> Kazunobu Kuriyama
>>
>>>
>>> --
>>> BRIDGEKEEPER: What is your favorite colour?
>>> LAUNCELOT:    Blue.
>>> BRIDGEKEEPER: Right.  Off you go.
>>>                  "Monty Python and the Holy Grail" PYTHON (MONTY)
>>> PICTURES LTD
>>>
>>>  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net
>>>  \\\
>>> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/
>>> \\\
>>> \\\  an exciting new programming language -- http://www.Zimbu.org
>>>   ///
>>>  \\\            help me help AIDS victims -- http://ICCF-Holland.org
>>> ///
>>>
>>> --
>>> --
>>> 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.

Attachment: athena-badvalue-update2.patch
Description: Binary data

Raspunde prin e-mail lui