Segfault of __thread varaible in Linux/ARM due to bug of LLVM ARM code generation

Bug #1584089 reported by Geunsik Lim
30
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LLVM
Fix Released
Wishlist
llvm (Ubuntu)
Fix Released
Undecided
Unassigned
llvm-defaults (Ubuntu)
Fix Released
Undecided
Unassigned
llvm-toolchain-3.6 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

There are four thread local storage (TLS) models in Clang/LLVM as following:
1) global-dynamic TLS model
2) local-dynamic TLS model
3) local-exec TLS model
4) initial-exec TLS model
and emulated-TLS (for Android S/W platform)??

Even though, We can build run normally with the static relocation method by selecting the initial-exec TLS model instead of global-dynamic TLS model (by default) , We need to run the clang application code with global-dynamic (or local-dynamic) TLS model in order that we support some applications is working with dlopen(3) library call.

We have found the appropriate solution for some clang/LLVM applications including 1) __thread variables and 2) -O2/-O3 of the clang language. Could you apply this patch to Ubuntu 14.04 LTS and Ubuntu 16.04 LTS repository?

* LLVM: Revision 268662 (ARM: don't attempt to merge litpools referencing different PC-anchors.)
http://llvm.org/viewvc/llvm-project?view=revision&revision=268662
https://llvm.org/bugs/show_bug.cgi?id=27836
https://llvm.org/bugs/show_bug.cgi?id=28035

Below is the mailing list discussed to fix this issue.
http://lists.llvm.org/pipermail/llvm-dev/2016-May/098974.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160502/353476.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/355091.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356679.html

* Before r268662:
  ubuntu@raspberrypi2#> ./corerun ./hello.exe (with -O2/-O3)
  Segmentation Fault

* After r268662:
  ubuntu@raspberrypi2#> ./corerun ./hello.exe (with -O2/-O3)
  Hello!!! Welcome to .NET Core (CoreCLR) world.!!!

Tags: patch llvm-arm
Revision history for this message
Geunsik Lim (leemgs) wrote :

Here is additional information.

Runtime (CoreCLR) of .NET Core is available at https://github.com/dotnet/coreclr.

Clang/LLVM3.6.2 (for Ubuntu 14.04 X64) binary that I re-compiled the existing Clang/LLVM is available at https://onedrive.live.com/redir?resid=C93799B86B006829!191&authkey=!AKb-qFmpFRUGDtM&ithint=file%2cbz

Geunsik Lim (leemgs)
description: updated
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "[LLVM] Linux/ARM: don't attempt to merge litpools referencing different PC-anchors." seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Geunsik Lim (leemgs) wrote :

This patch is to fix the incorrect __thread variable operation of Clang/LLVM for Linux/ARM.

Geunsik Lim (leemgs)
Changed in llvm-defaults (Ubuntu):
status: New → Confirmed
no longer affects: llvm-toolchain (Ubuntu)
Revision history for this message
In , Geunsik Lim (leemgs) wrote :

Created attachment 16399
ARM: don't attempt to merge litpools referencing different PC-anchors.

There are four thread local storage (TLS) models in Clang/LLVM as following:
1) global-dynamic TLS model
2) local-dynamic TLS model
3) local-exec TLS model
4) initial-exec TLS model
and emulated-TLS (for Android S/W platform)??

Even though, We can build run normally with the static relocation method by selecting the initial-exec TLS model instead of global-dynamic TLS model (by default) , We need to run the clang application code with global-dynamic (or local-dynamic) TLS model in order that we support some applications is working with dlopen(3) library call.

We have found the appropriate solution for some clang/LLVM applications including 1) __thread variables and 2) -O2/-O3 of the clang language. Could you apply this patch to Ubuntu 14.04 LTS and Ubuntu 16.04 LTS repository?

* LLVM: Revision 268662 (ARM: don't attempt to merge litpools referencing different PC-anchors.)
http://llvm.org/viewvc/llvm-project?view=revision&revision=268662

Below is the mailing list discussed to fix this issue.
http://lists.llvm.org/pipermail/llvm-dev/2016-May/098974.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160502/353476.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/355091.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356679.html

* Before r268662:
  ubuntu@raspberrypi2#> ./corerun ./hello.exe (with -O2/-O3)
  Segmentation Fault

* After r268662:
  ubuntu@raspberrypi2#> ./corerun ./hello.exe (with -O2/-O3)
  Hello!!! Welcome to .NET Core (CoreCLR) world.!!!

Changed in llvm:
status: New → Fix Committed
Changed in llvm-toolchain-3.6 (Ubuntu):
status: New → Confirmed
Revision history for this message
In , Geunsik Lim (leemgs) wrote :

We have posted this issue and patch to Ubuntu's launchpad bug system (e.g. llvm-defaults package) as following:
* https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1584089

Revision history for this message
Geunsik Lim (leemgs) wrote :
description: updated
Changed in llvm (Ubuntu):
status: New → Confirmed
Changed in llvm:
importance: Undecided → Unknown
status: Fix Committed → Unknown
Revision history for this message
Geunsik Lim (leemgs) wrote :

Adding: Tim Northover <email address hidden>

Revision history for this message
In , Tim Northover (t-p-northover) wrote :

As noted, this was fixed by r268662.

Changed in llvm:
importance: Unknown → Wishlist
status: Unknown → Fix Released
Revision history for this message
Geunsik Lim (leemgs) wrote :

I have added "Ubuntu Toolchain Hackers".

Revision history for this message
Geunsik Lim (leemgs) wrote :

I have evaluated the effect the patch after uploading the updated packages to my PPA.
The evauation result was Okay.
* https://launchpad.net/~leemgs/+archive/ubuntu/dotnet/+packages

Geunsik Lim (leemgs)
description: updated
Revision history for this message
Geunsik Lim (leemgs) wrote :
Changed in llvm-defaults (Ubuntu):
status: Confirmed → Fix Released
Changed in llvm-toolchain-3.6 (Ubuntu):
status: Confirmed → Fix Released
Changed in llvm (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.