Bug 5620
Summary: | sigaddset/sigdelset may not work as expected with gcc optimizer | ||
---|---|---|---|
Product: | Platform Specific/Hardware | Reporter: | Constantine Gavrilov (constg) |
Component: | i386 | Assignee: | platform_i386 |
Status: | CLOSED CODE_FIX | ||
Severity: | high | CC: | akpm |
Priority: | P2 | ||
Hardware: | i386 | ||
OS: | Linux | ||
Kernel Version: | All 2.4 and all 2.6 versions | Subsystem: | |
Regression: | --- | Bisected commit-id: | |
Attachments: |
a patch to prevent miscompilation of sigaddset with const signal argument
A sample of code using sigaddset that shows the problem fix to sigaddset sigdelset for i386 fix to sigaddset sigdelset for i386 |
Description
Constantine Gavrilov
2005-11-17 00:41:25 UTC
Created attachment 6600 [details]
a patch to prevent miscompilation of sigaddset with const signal argument
Created attachment 6601 [details]
A sample of code using sigaddset that shows the problem
According to jakub@redhat.com, gcc maintainer at RedHat, it is a pure kernel bug and not gcc problem. Instead of __asm__("btsl %1,%0" : "=m"(*set) : "Ir"(_sig-1) : "cc"); sigsaddset must use __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig-1) : "cc"); I have reworked the pacth but kept the constant case optimization. A quote form jakub to make the issue clear: That's just buggy testcase. You need either __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig-1) : "cc"); or __asm__("btsl %1,%0" : "=m"(*set) : "Ir"(_sig-1), "m"(*set) : "cc"); because the btsl instruction doesn't just set the memory to some value, but needs to read its previous content as well. If you don't tell that fact to GCC, GCC is of course free to optimize as if the asm was just setting the value and not depended on the previous value. Created attachment 6602 [details]
fix to sigaddset sigdelset for i386
Created attachment 6603 [details]
fix to sigaddset sigdelset for i386
Previous patch had a typo.
Constantine, can you please redo this patch against 2.6.15-rc1 and mail it to me with a full description, as per http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt, thanks. err, make that 2.6.16-rc1. Linus picked up the patch (apparently from LKML) and included it into 2.6.15 (released on January, 2. I thought my patch was ignored and eventually stopped looking in kernel Bugzilla as well since it was not acknowledged in any way. I am closing the bug now as it is fixed as of kernel 2.6.15. |