Follow-up Comment #4, bug #18481 (project freeciv):

[12:12:ttypl][longturn@spock:~:4]$ cat a.c
#include <stdio.h>

int
main()
{
        printf("%d %dn", sizeof(int), sizeof(size_t));
        return 0;
}
[12:12:ttypl][longturn@spock:~:5]$ gcc a.c -o a && ./a 
4 8


Here we go, I believe this is the source of the SIGBUS. 2.2 works fine on
sparc64, here is what changed:
2.3:

./utility/registry.c:1952: int *secfile_lookup_int_vec(const struct
section_file *secfile,
./utility/registry.c:1953:                             size_t *dim, const
char *path, ...)
...
   3230   food_ini = secfile_lookup_int_vec(file, (size_t *)
   3231                                     &game.info.granary_num_inis,
   3232                                     "civstyle.granary_food_ini");

2.2:

./utility/registry.c:1606: int *secfile_lookup_int_vec(struct section_file
*my_section_file,
./utility/registry.c:1607:                            int *dimen, const char
*path, ...)
...
   3082   food_ini = secfile_lookup_int_vec(&file,
&game.info.granary_num_inis,
   3083                                     "civstyle.granary_food_ini");


The function secfile_lookup_int_vec() is now broken (it was good in 2.2).

I think this is what is called "strict alignment". n-byte data types must be
n-byte aligned. game.info.granary_num_inis is 4-byte aligned, and when cast to
a 8-byte data type causes the SIGBUS.

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?18481>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to