Bug 14761 - commands using SET_PTR_TO_GLOBALS segfaults when compiled with clang 12.0.1
Summary: commands using SET_PTR_TO_GLOBALS segfaults when compiled with clang 12.0.1
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-17 18:06 UTC by Thiner Logoer
Modified: 2022-04-17 18:06 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
.config file for reference; mostly defconfig with only tweaks in general config (28.50 KB, application/octet-stream)
2022-04-17 18:06 UTC, Thiner Logoer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thiner Logoer 2022-04-17 18:06:46 UTC
Created attachment 9286 [details]
.config file for reference; mostly defconfig with only tweaks in general config

I compiled busybox using clang (12.0.1, default version on alpine 3.15 amd64, make CC=clang STRIP=llvm-strip) on aarch64 architecture, and then run it on aarch64 linux kernel. Some of commands segfaults directly:
```
~ $ busybox getty
Segmentation fault
~ $ busybox vi
Segmentation fault
~ $ busybox awk
Segmentation fault
~ $ busybox ed   
Segmentation fault
~ $ busybox diff
Segmentation fault
~ $ busybox netstat
Segmentation fault
~ $ busybox wget
Segmentation fault
~ $ busybox ftpd
Segmentation fault
~ $ busybox httpd
Segmentation fault
~ $ busybox ntpd
~ $ busybox arping
Segmentation fault
```

I suspect SET_PTR_TO_GLOBALS is the culprit, since many commands using SET_PTR_TO_GLOBALS does not work at all.

clang 12.0.1 may not respect "unconst" black magic in busybox.