Adding a certain multibyte character to isprint causes a segfault.

83 views
Skip to first unread message

Raúl Núñez de Arenas Coronado

unread,
Oct 29, 2009, 5:17:05 AM10/29/09
to Vim development
Hi Bram :)

Easy to reproduce:
$ vim -u NONE
[Vim starts]
:set isprint=∙

For the above I use <Ctrl-K> to enter the digraph, then "Sb" for Small
bullet. As soon as you hit enter after the above:
Vim: Caught deadly signal SEGV
Vim: Finished
[1] 29734 segmentation fault vim -u NONE

It happens with other digraphs, probably all above u+00ff but I haven't
tested thorougly.

My version of Vim


VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Oct 22 2009 12:06:16)
Included patches: 1-267
Compiled by DervishD <ra...@dervishd.net>
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset
+cindent +clientserver +clipboard +cmdline_compl +cmdline_hist
+cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con +diff
+digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi
+file_in_path +find_in_path +float +folding -footer +fork() -gettext
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall
+linebreak +lispindent +listcmds +localmap +menu +mksession
+modify_fname +mouse -mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm
+mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang
-mzscheme -netbeans_intg -osfiletype +path_extra +perl +postscript
+printer +profile +python +quickfix +reltime +rightleft -ruby
+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit
+visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows
+writebackup +X11 +xfontset -xim +xsmp_interact +xterm_clipboard
-xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"

Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2
-D_FORTIFY_SOURCE=1 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/lib/perl/5.10/CORE -I/usr/include/python2.6 -pthread

Linking: gcc -Wl,-E -L/usr/local/lib -o vim -lXt -lncurses -Wl,-E
-L/usr/local/lib -L/usr/lib/perl/5.10/CORE -lperl
-L/usr/lib/python2.6/config -lpython2.6 -L/usr/lib -lz -lutil -lm
-Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions


--
Raúl "DervishD" Núñez de Arenas Coronado
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!

Tony Mechelynck

unread,
Oct 29, 2009, 2:17:30 PM10/29/09
to vim...@googlegroups.com, Raúl Núñez de Arenas Coronado
On 29/10/09 10:17, Raúl Núñez de Arenas Coronado wrote:
>
> Hi Bram :)
>
> Easy to reproduce:
> $ vim -u NONE
> [Vim starts]
> :set isprint=∙
>
> For the above I use<Ctrl-K> to enter the digraph, then "Sb" for Small
> bullet. As soon as you hit enter after the above:
> Vim: Caught deadly signal SEGV
> Vim: Finished
> [1] 29734 segmentation fault vim -u NONE
>
> It happens with other digraphs, probably all above u+00ff but I haven't
> tested thorougly.
>
> My version of Vim
>
>
> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Oct 22 2009 12:06:16)
> Included patches: 1-267
> Compiled by DervishD<ra...@dervishd.net>
> Huge version without GUI. Features included (+) or not (-):
[...]

A crash means a bug; but this said, 'isprint' is not meant to contain
_any_ character above 0xFF, see its help:

> Multi-byte characters 256 and above are always included, only the
> characters up to 255 are specified with this option. When a character
> is printable but it is not available in the current font, a
> replacement character will be shown.
> Unprintable and zero-width Unicode characters are displayed as <xxxx>.
> There is no option to specify these characters.


Best regards,
Tony.
--
Laugh at your problems; everybody else does.

Raúl Núñez de Arenas Coronado

unread,
Oct 29, 2009, 2:24:48 PM10/29/09
to Tony Mechelynck, vim...@googlegroups.com
Saluton Tony :)

Tony Mechelynck <a...@gmail.com> skribis:


> On 29/10/09 10:17, Raúl Núñez de Arenas Coronado wrote:
>> Easy to reproduce:
>> $ vim -u NONE
>> [Vim starts]
>> :set isprint=∙
>

> A crash means a bug; but this said, 'isprint' is not meant to contain
> _any_ character above 0xFF, see its help:

[...]

I did (I forgot to tell in my message), and that's why I reported the
bug: it somewhat shocked me that being a known limitation of "isprint",
using a value out of the "legal" range caused a segfault and not an
error message, which was what I expected.

I haven't took a look at the sources yet, so I don't know if this is
fixable at all or if "isprint" is interpreting ∙ as 0xe2, 0x88, 0x99,
that is, three different characters under 0xff, and maybe one of them is
causing the problem :?

I don't think this weekend I will be able to check, but if I do I'll try
to prepare a patch if I discover how to fix the bug.

Tony Mechelynck

unread,
Oct 29, 2009, 2:50:13 PM10/29/09
to Raúl Núñez de Arenas Coronado, vim...@googlegroups.com
On 29/10/09 19:24, Raúl Núñez de Arenas Coronado wrote:
> Saluton Tony :)
>
> Tony Mechelynck<a...@gmail.com> skribis:
>> On 29/10/09 10:17, Raúl Núñez de Arenas Coronado wrote:
>>> Easy to reproduce:
>>> $ vim -u NONE
>>> [Vim starts]
>>> :set isprint=∙
>>
>> A crash means a bug; but this said, 'isprint' is not meant to contain
>> _any_ character above 0xFF, see its help:
>
> [...]
>
> I did (I forgot to tell in my message), and that's why I reported the
> bug: it somewhat shocked me that being a known limitation of "isprint",
> using a value out of the "legal" range caused a segfault and not an
> error message, which was what I expected.
>
> I haven't took a look at the sources yet, so I don't know if this is
> fixable at all or if "isprint" is interpreting ∙ as 0xe2, 0x88, 0x99,
> that is, three different characters under 0xff, and maybe one of them is
> causing the problem :?
>
> I don't think this weekend I will be able to check, but if I do I'll try
> to prepare a patch if I discover how to fix the bug.
>

I may be wrong, but my guess is that 'isprint' should accept characters
in 'encoding' but not above 0xFF, which means that in UTF-8 (and UTF-8
only) they can be multibyte characters, but of no more than two bytes (a
leader byte, 0xC2 or 0xC3, and a trailer byte in the range 0x80-0xBF)

Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
169. You hire a housekeeper for your home page.

Bram Moolenaar

unread,
Oct 29, 2009, 5:05:49 PM10/29/09
to Raúl Núñez de Arenas Coronado, Vim development

Raul wrote:

> Hi Bram :)
>
> Easy to reproduce:
> $ vim -u NONE
> [Vim starts]

> :set isprint=∙


>
> For the above I use <Ctrl-K> to enter the digraph, then "Sb" for Small
> bullet. As soon as you hit enter after the above:
> Vim: Caught deadly signal SEGV
> Vim: Finished
> [1] 29734 segmentation fault vim -u NONE
>
> It happens with other digraphs, probably all above u+00ff but I haven't
> tested thorougly.

It's indeed easy to reproduce. I'll put it at the top of the todo list.

--
TALL KNIGHT: We are now no longer the Knights Who Say Ni!
ONE KNIGHT: Ni!
OTHERS: Sh!
ONE KNIGHT: (whispers) Sorry.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Dominique Pellé

unread,
Oct 29, 2009, 5:37:36 PM10/29/09
to vim...@googlegroups.com
Raúl Núñez de Arenas Coronado wrote:

> Hi Bram :)
>
> Easy to reproduce:
> $ vim -u NONE
> [Vim starts]

> :set isprint=*


>
> For the above I use <Ctrl-K> to enter the digraph, then "Sb" for Small
> bullet. As soon as you hit enter after the above:
> Vim: Caught deadly signal SEGV
> Vim: Finished


I can reproduce it too. Not only with 'isprint' as you describe, but also
with 'isfname' and 'isident'.

-- Dominique

Jan Larres

unread,
Oct 30, 2009, 8:20:55 AM10/30/09
to vim...@googlegroups.com
Hi Raúl,

* Raúl Núñez de Arenas Coronado (rau...@gmail.com) wrote:
> Easy to reproduce:
> $ vim -u NONE
> [Vim starts]
> :set isprint=∙
>
> For the above I use <Ctrl-K> to enter the digraph, then "Sb" for Small
> bullet. As soon as you hit enter after the above:
> Vim: Caught deadly signal SEGV
> Vim: Finished
> [1] 29734 segmentation fault vim -u NONE
>
> It happens with other digraphs, probably all above u+00ff but I haven't
> tested thorougly.
>
> My version of Vim
>
>
> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Oct 22 2009 12:06:16)
> Included patches: 1-267

with my vim (7.2.245 under Linux) I get an error instead:

E474: Invalid argument: isprint=∙

Maybe it got introduced by a patch in between our versions?

Jan

--
OpenPGP Key-ID: 00A0FD5F
"It's hard to be religious when certain people are never incinerated by
bolts of lightning." -- Calvin, "Calvin & Hobbes"

Lech Lorens

unread,
Oct 30, 2009, 9:37:48 AM10/30/09
to vim_dev
On 30-Oct-2009 Jan Larres <li...@majutsushi.net> wrote:
>
> Hi Raúl,
>
> * Raúl Núñez de Arenas Coronado (rau...@gmail.com) wrote:
> > Easy to reproduce:
> > $ vim -u NONE
> > [Vim starts]
> > :set isprint=∙
> >
> > For the above I use <Ctrl-K> to enter the digraph, then "Sb" for Small
> > bullet. As soon as you hit enter after the above:
> > Vim: Caught deadly signal SEGV
> > Vim: Finished
> > [1] 29734 segmentation fault vim -u NONE
> >
> > It happens with other digraphs, probably all above u+00ff but I haven't
> > tested thorougly.
> >
> > My version of Vim
> >
> >
> > VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Oct 22 2009 12:06:16)
> > Included patches: 1-267
>
> with my vim (7.2.245 under Linux) I get an error instead:
>
> E474: Invalid argument: isprint=∙
>
> Maybe it got introduced by a patch in between our versions?
>
> Jan

The problem was introduced by patch 7.2.252. Or actually it was not
reproducible before 7.2.252 due to the fact that it was not possible to
use multi-byte characters at all.

The attached patch fixes the problem. Additionally, it allows to specify
a range of multi-byte characters, e.g.:
:set isp=ð-÷

--
Cheers,
Lech

isp-segfault.patch

Raúl Núñez de Arenas Coronado

unread,
Oct 31, 2009, 5:39:37 AM10/31/09
to vim...@googlegroups.com
Saluton Dominique :)

Dominique Pellé <d...@gmail.com> skribis:

I noticed this morning, while taking a look at the sources, just to
check that other "is-" options were not affected. The good news are that
Lech Lorens found the problem and made a patch! :)

Thanks a lot, Lech!

Bram Moolenaar

unread,
Oct 31, 2009, 8:52:43 AM10/31/09
to Lech Lorens, vim_dev

Lech Lorens wrote:

> > Hi Raúl,


> >
> > * Raúl Núñez de Arenas Coronado (rau...@gmail.com) wrote:
> > > Easy to reproduce:
> > > $ vim -u NONE
> > > [Vim starts]

> > > :set isprint=∙


> > >
> > > For the above I use <Ctrl-K> to enter the digraph, then "Sb" for Small
> > > bullet. As soon as you hit enter after the above:
> > > Vim: Caught deadly signal SEGV
> > > Vim: Finished
> > > [1] 29734 segmentation fault vim -u NONE
> > >
> > > It happens with other digraphs, probably all above u+00ff but I haven't
> > > tested thorougly.
> > >
> > > My version of Vim
> > >
> > >
> > > VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Oct 22 2009 12:06:16)
> > > Included patches: 1-267
> >
> > with my vim (7.2.245 under Linux) I get an error instead:
> >

> > E474: Invalid argument: isprint=∙


> >
> > Maybe it got introduced by a patch in between our versions?
> >
> > Jan
>
> The problem was introduced by patch 7.2.252. Or actually it was not
> reproducible before 7.2.252 due to the fact that it was not possible to
> use multi-byte characters at all.
>
> The attached patch fixes the problem. Additionally, it allows to specify
> a range of multi-byte characters, e.g.:

> :set isp=ð-÷

Thanks Lech!


--
Why isn't there mouse-flavored cat food?

Reply all
Reply to author
Forward
0 new messages