<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54664>54664</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[PowerPC] crash in libunwind/src/AddressSpace.hpp:164 on powerpc after running cargo (from rust)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkubaj
</td>
</tr>
</table>
<pre>
On FreeBSD 13.1-RC1/powerpc (32-bits):
```
cargo new hello_cargo
cd hello_cargo
env RUST_BACKTRACE=1 cargo build
<segfault>
```
Backtrace:
```
Program terminated with signal SIGSEGV, Segmentation fault.
Address not mapped to object.
#0 libunwind::LocalAddressSpace::get32 (addr=431585656, this=<optimized out>) at /usr/src/contrib/llvm-project/libunwind/src/AddressSpace.hpp:164
164 memcpy(&val, (void *)addr, sizeof(val));
(gdb) bt
#0 libunwind::LocalAddressSpace::get32 (addr=431585656, this=<optimized out>) at /usr/src/contrib/llvm-project/libunwind/src/AddressSpace.hpp:164
#1 libunwind::CFI_Parser<libunwind::LocalAddressSpace>::parseCIE (addressSpace=..., cie=431585656, cieInfo=0xffff82e8)
at /usr/src/contrib/llvm-project/libunwind/src/DwarfParser.hpp:319
#2 0x421bf76c in libunwind::CFI_Parser<libunwind::LocalAddressSpace>::findFDE (addressSpace=..., pc=18016363, ehSectionStart=28326632,
sectionLength=<optimized out>, fdeHint=<optimized out>, fdeInfo=0xffff8308, cieInfo=0xffff82e8)
at /usr/src/contrib/llvm-project/libunwind/src/DwarfParser.hpp:252
#3 0x421bf458 in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_ppc>::getInfoFromDwarfSection (this=0xffff9848,
pc=18016363, sects=..., fdeSectionOffsetHint=0) at /usr/src/contrib/llvm-project/libunwind/src/UnwindCursor.hpp:1566
#4 0x421bb658 in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_ppc>::setInfoBasedOnIPRegister (this=0xffff9848,
isReturnAddress=<optimized out>) at /usr/src/contrib/llvm-project/libunwind/src/UnwindCursor.hpp:1960
#5 0x421bb418 in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_ppc>::step (this=0xffff9848)
at /usr/src/contrib/llvm-project/libunwind/src/UnwindCursor.hpp:2105
#6 0x421ba108 in __unw_step (cursor=0xffff9848) at /usr/src/contrib/llvm-project/libunwind/src/libunwind.cpp:176
#7 0x421b8134 in _Unwind_Backtrace (callback=0x1977e74, ref=0xffff9c88) at /usr/src/contrib/llvm-project/libunwind/src/UnwindLevel1-gcc-ext.c:131
```
That points to https://github.com/llvm/llvm-project/blob/main/libunwind/src/AddressSpace.hpp#L164.
A simplified program that always segfaults during memcpy:
```
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
typedef uintptr_t pint_t;
uint32_t get32(pint_t addr) {
uint32_t val;
memcpy(&val, (void *)addr, sizeof(val));
return val;
}
int main(int argc, char **argv)
{
uint32_t a = get32(431585656);
printf("%d\n", a);
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdV1tvozgU_jXkxSoCOxB4yENCmtlqK7VqOvMaGWPAMwQj2_Syv36PuaXpbWbV7qy0KCLG52B_33d87EMqs8flVY22ivP1boN84vpnN4nv4G0j77lqGHJwRPBZKox2cOyQleNtHG_lhN7w6x4ZVYVENb9HJa8que-eB1P2so_Xd-jm6-52v14lf97erJJzh2x81I-StqLKhllIonmR07YyDjl_deb-vqbsh1GU8bcAXitZKHpAhquDqKnhGboXpkRaFDWt0O7iy-78yzcHJ2jHiwOvDTVC1qib2u2HWGWZ4lqjWhp0oE0DQxiJZPqds9HFwcRDqBJpW9-LOrNgyOpSMloNL--aASNZFdwQbNWlYAL6c-IHURAGoQVhSqGhD_jLxoiD-Asmk20nAo4RNfDettUK7loxuDNZGyVSaFXV3eGsUdKiso8TltH1KRK3bBqA4ofzHj800Hgd-IE1j4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