Subject: Re: bug#46111: Reverting fns.c hash function due to OpenBSD/SPARC64 compile breaking

From: Eli Zaretskii <[email-masked]>
Date: Thu, 28 Jan 2021 15:58:09 +0200

> From: Ahmed Khanzada <[email-masked]>
> Cc: 
> Date: Wed, 27 Jan 2021 20:06:01 -0800
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Thanks.  However, could you please show the C-level backtrace from the SIGBUS crash, as displayed by GDB?  I think we'd like to know which string has its data unaligned to cause this.
> 
> Is the log below the information that you are looking for?

Yes, thanks.

> 4613          EMACS_UINT c = *p;
> (gdb) next
> 
> Program received signal SIGBUS, Bus error.
> 0x000000455fe1dc6c in hash_string (ptr=0x47fa34d596 "DndProtocol",
> len=11) at fns.c:4613
> 4613          EMACS_UINT c = *p;
> (gdb) backtrace
> #0  0x000000455fe1dc6c in hash_string (ptr=0x47fa34d596 "DndProtocol",
> len=11) at fns.c:4613
> #1  0x000000455fe1dd48 in sxhash_string (ptr=0x47fa34d596 "DndProtocol",
> len=11) at fns.c:4640
> #2  0x000000455fe1e36c in sxhash_obj (obj=0x47fa02f0bc, depth=0) at
> fns.c:4759
> #3  0x000000455fe1e270 in sxhash (obj=0x47fa02f0bc) at fns.c:4741
> #4  0x000000455fe1c52c in hashfn_equal (key=0x47fa02f0bc,
> h=0x47fa02eff0) at fns.c:4096
> #5  0x000000455fe1cf44 in hash_table_rehash (hash=0x47fa02eff5) at
> fns.c:4342
> #6  0x000000455fdc5264 in hash_table_thaw (hash=0x47fa02eff5) at
> pdumper.c:2652
> #7  0x000000455fdcd184 in thaw_hash_tables () at pdumper.c:5477

Stefan, any ideas?

One possibility is to use memcpy instead of dereferencing a pointer.
We could do that either unconditionally or when the original pointer
is not aligned on 4/8-byte boundary.