<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>10911</bug_id>
          
          <creation_ts>2007-02-23 14:22:34 +0300</creation_ts>
          <short_desc>crash due to -D_FORTIFY_SOURCE=2 false positive</short_desc>
          <delta_ts>2007-03-18 01:12:12 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>vim-console</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sergey Vlasov">vsu</reporter>
          <assigned_to name="Gleb F-Malinovskiy">glebfm</assigned_to>
          <cc>admsasha</cc>
    
    <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>php-coder</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>45777</commentid>
    <comment_count>0</comment_count>
    <who name="Sergey Vlasov">vsu</who>
    <bug_when>2007-02-23 14:22:34 +0300</bug_when>
    <thetext>vim (все полнофункциональные варианты, не только vim-console) падает при
выполнении примера из &quot;:help self&quot;:

        :function Mylen() dict
        :   return len(self.data)
        :endfunction
        :let mydict = {&apos;data&apos;: [0, 1, 2, 3], &apos;len&apos;: function(&quot;Mylen&quot;)}
        :echo mydict.len()

#0  0x00002aaaacd333a5 in raise () from /lib64/libc.so.6
#1  0x00002aaaacd34730 in abort () from /lib64/libc.so.6
#2  0x00002aaaacd68ebb in __fsetlocking () from /lib64/libc.so.6
#3  0x00002aaaacdd04ff in __chk_fail () from /lib64/libc.so.6
#4  0x0000000000457a64 in call_func (name=0x857e90 &quot;Mylen&quot;, len=Variable &quot;len&quot;
is not available.
) at eval.c:19832
#5  0x000000000045a8dc in get_func_tv (name=0x857e90 &quot;Mylen&quot;, len=5,
rettv=0x7fff452d7cd0, arg=0x7fff452d7ce8, firstline=494, 
    lastline=494, doesrange=0x7fff452d77fc, evaluate=1, selfdict=0x921410) at
eval.c:7411
#6  0x000000000045aacb in handle_subscript (arg=0x7fff452d7ce8,
rettv=0x7fff452d7cd0, evaluate=1, verbose=1) at eval.c:17185
#7  0x000000000045be48 in eval7 (arg=0x7fff452d7ce8, rettv=0x7fff452d7cd0,
evaluate=1) at eval.c:4701
#8  0x000000000045c6a4 in eval6 (arg=0x7fff452d7ce8, rettv=0x7fff452d7cd0,
evaluate=1) at eval.c:4442
#9  0x000000000045927f in eval5 (arg=0x7fff452d7ce8, rettv=0x7fff452d7cd0,
evaluate=1) at eval.c:4311
#10 0x00000000004594f6 in eval4 (arg=0x7fff452d7ce8, rettv=0x7fff452d7cd0,
evaluate=1) at eval.c:4043
#11 0x0000000000459c24 in eval3 (arg=0x7fff452d7ce8, rettv=0x7fff452d7cd0,
evaluate=1) at eval.c:3955
#12 0x0000000000459d74 in eval1 (arg=0x7fff452d7ce8, rettv=0x7fff452d7cd0,
evaluate=1) at eval.c:3884
#13 0x000000000045a042 in ex_echo (eap=0x7fff452d7e50) at eval.c:18150
#14 0x000000000047d974 in do_one_cmd (cmdlinep=0x7fff452d8068, sourcing=0,
cstack=0x7fff452d8070, fgetline=0x48bad0 &lt;getexline&gt;, 
    cookie=0x0) at ex_docmd.c:2616
#15 0x000000000047eda9 in do_cmdline (cmdline=Variable &quot;cmdline&quot; is not available.
) at ex_docmd.c:1098
#16 0x00000000004e8352 in nv_colon (cap=0x7fff452d85b0) at normal.c:5161
#17 0x00000000004ea9d3 in normal_cmd (oap=0x7fff452d8650, toplevel=1) at
normal.c:1136
#18 0x00000000004affbf in main_loop (cmdwin=0, noexmode=0) at main.c:1154
#19 0x00000000004b301a in main (argc=Variable &quot;argc&quot; is not available.
) at main.c:934

При сборке vim обнаружилось предупреждение:

eval.c: In function &apos;call_func&apos;:
eval.c:19832: warning: call to __builtin___strcpy_chk will always overflow
destination buffer

Ситуация следующая: тип dictitem_T объявлен как:

/*
 * Structure to hold an item of a Dictionary.
 * Also used for a variable.
 * The key is copied into &quot;di_key&quot; to avoid an extra alloc/free for it.
 */
struct dictitem_S
{
    typval_T	di_tv;		/* type and value of the variable */
    char_u	di_flags;	/* flags (only used for variable) */
    char_u	di_key[1];	/* key (actually longer!) */
};

typedef struct dictitem_S dictitem_T;

При этом в eval.c:call_user_func() имеется следующий код:

    funccall_T	fc;
    dictitem_T	*v;
    char_u	*name;
...
	/* Set l:self to &quot;selfdict&quot;.  Use &quot;name&quot; to avoid a warning from
	 * some compiler that checks the destination size. */
	v = &amp;fc.fixvar[fixvar_idx++].var;
	name = v-&gt;di_key;
	STRCPY(name, &quot;self&quot;);

Однако даже использование промежуточной переменной name не помогает скрыть от
компилятора то, что копирование происходит в поле di_key, которое объявлено как
массив из 1 элемента. Вероятно, играет роль и то, что структура funccall_S
определена весьма специфическим образом:

struct funccall_S
{
...
    struct			/* fixed variables for arguments */
    {
	dictitem_T	var;		/* variable (without room for name) */
	char_u	room[VAR_SHORT_LEN];	/* room for the name */
    } fixvar[FIXVAR_CNT];
...
};

Т.е., в данном случае код написан с расчётом на то, что var.di_name будет
переполнено с залезанием в room.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45796</commentid>
    <comment_count>1</comment_count>
    <who name="Sir Raorn">raorn</who>
    <bug_when>2007-02-23 20:51:32 +0300</bug_when>
    <thetext>Патч из OpenSUSE нашёл, заслал проблему в обстрём, посмотрим что будет...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45812</commentid>
    <comment_count>2</comment_count>
    <who name="Sergey Vlasov">vsu</who>
    <bug_when>2007-02-24 12:38:56 +0300</bug_when>
    <thetext>На самом деле это, конечно, не -fstack-protector, а -D_FORTIFY_SOURCE=2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45813</commentid>
    <comment_count>3</comment_count>
    <who name="Sir Raorn">raorn</who>
    <bug_when>2007-02-24 13:23:20 +0300</bug_when>
    <thetext>Апстрим послал меня чинить gcc и ставить релиз glibc вместо &quot;unfinished and
contains bugs&quot; снапшота.  В следующей сборке приложу патч, посмотрим что будет...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46841</commentid>
    <comment_count>4</comment_count>
    <who name="Sir Raorn">raorn</who>
    <bug_when>2007-03-18 01:12:12 +0300</bug_when>
    <thetext>Fixed in 4:7.0.218-alt1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>