harpchad wrote:

> Additional details:
>
> VIM 7.2
> Included patches: 1-88
> Huge version without GUI.
>
> Compilation: /opt/studio/SOS11/SUNWspro/bin/cc -c -I. -Iproto -
> DHAVE_CONFIG_H   -I/opt/csw/include -xO3 -xarch=v9 -I/opt/csw/include
>
> Linking: /opt/studio/SOS11/SUNWspro/bin/cc   -xarch=v9 -L/opt/csw/lib/
> 64 -R/opt/csw/lib/\\$ISALIST -R/opt/csw/lib/64 -o vim       -lm -
> lncurses -liconv -lintl -ldl


Can you try to reproduce it after recompiling everything with
the equivalent of gcc options -O0 -g  (I don't remember what
these options are for the cc Sun compiler)

So debugger can then display the proper line numbers in the stack.

hash_init() seems to be called from spell_read_off() with an
address which is not 8-bytes aligned.  So it's one of those
3 lines in spell.c:

 5328     hash_init(&aff->af_pref);
 5329     hash_init(&aff->af_suff);
 5330     hash_init(&aff->af_comp);

So if looks like aff itself it not aligned on 8 bytes (required alignement
since struct afffile_T contains pointers)

aff comes is initialized just above with:

 5322     aff = (afffile_T *)getroom(spin, sizeof(afffile_T), TRUE);

The TRUE parameter means that it requests an address aligned
for pointers.  So this bug should normally not happen.

But the value 0x100313ac4 given by debugger is not
aligned indeed on 8 bytes.

So the bug must be in getroom(...).

I see that getroom(...) has some logic for alignement:

 7435     if (align && bl != NULL)
 7436         /* Round size up for alignment.  On some systems
structures need to be
 7437          * aligned to the size of a pointer (e.g., SPARC). */
 7438         bl->sb_used = (bl->sb_used + sizeof(char *) - 1)
 7439                                                       &
~(sizeof(char *) - 1);
 ...
 7453     p = bl->sb_data + bl->sb_used;
 7454     bl->sb_used += (int)len;
 7455
 7456     return p;
 7457 }


But it looks wrong.  It only align bl->sb_used on 8 bytes
but not the return value p.

p depends on bl->sb_data (not aligned) and
bl->sb_used (which is 8-bytes aligned)

bl->sb_data is not 8-bytes aligned since struct of bl is:

 4962 struct sblock_S
 4963 {
 4964     sblock_T    *sb_next;       /* next block in list */
 4965     int         sb_used;        /* nr of bytes already in use */
 4966     char_u      sb_data[1];     /* data, actually longer */
 4967 };

First field sb_next is a pointer, so aligned on 8 bytes.
Second field sb_used is thus also 8 bytes aligned.

But sizeof(int) is 4  (on most machines).  So third field sb_data[1]
will be aligned on 4 bytes only (not 8).

One way to ensure alignment of  sb_data on 8 bytes would be
to reorder fields in sblock_S as follows:

***************
*** 4961,4968 ****
  typedef struct sblock_S sblock_T;
  struct sblock_S
  {
-     sblock_T  *sb_next;       /* next block in list */
      int               sb_used;        /* nr of bytes already in use */
      char_u    sb_data[1];     /* data, actually longer */
  };

--- 4961,4968 ----
  typedef struct sblock_S sblock_T;
  struct sblock_S
  {
      int               sb_used;        /* nr of bytes already in use */
+     sblock_T  *sb_next;       /* next block in list */
      char_u    sb_data[1];     /* data, actually longer, must be
aligned on 8 bytes */
  };


Does this fix it?  I don't have a 64-bit machine to test....

PS: there is also a typo in spell.c

-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to