* [PATCH] Fix i?86 lll_futex_{,timed_}wait and lll_wait_tid
@ 2006-02-08 10:30 Jakub Jelinek
2006-02-08 15:51 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2006-02-08 10:30 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
Hi!
All other arches except i?86 have "memory" clobber in lll_futex_wait
etc. (be it through INTERNAL_SYSCALL or explicitly). These macros
are only used a handful time in generic code (and never in i?86 specific
code) and in a big portion of those places in tight loops, without
an explicit memory clobber anywhere. The syscall itself I guess
servers as a CPU memory barrier, so all we need is a barrier to tell
GCC not to optimize things accross it.
At least 2 places are miscompiled because of this:
1) unregister_atfork (say with GCC 4.1.0pre current CVS glibc):
d40c0: f0 ff 48 14 lock decl 0x14(%eax)
d40c4: 8b 50 14 mov 0x14(%eax),%edx
d40c7: 85 d2 test %edx,%edx
d40c9: 74 22 je d40ed <__unregister_atfork+0xed>
d40cb: 8d 78 14 lea 0x14(%eax),%edi
d40ce: 31 f6 xor %esi,%esi
d40d0: b8 f0 00 00 00 mov $0xf0,%eax
d40d5: 89 f1 mov %esi,%ecx
d40d7: 87 fb xchg %edi,%ebx
d40d9: 65 ff 15 10 00 00 00 call *%gs:0x10
d40e0: 87 fb xchg %edi,%ebx
d40e2: eb ec jmp d40d0 <__unregister_atfork+0xd0>
(note the endless loop)
2) start_thread:
52b8: 8b 45 b8 mov 0xffffffb8(%ebp),%eax
52bb: f6 40 5c 40 testb $0x40,0x5c(%eax)
52bf: 75 44 jne 5305 <start_thread+0x123>
...
5305: 31 d2 xor %edx,%edx
5307: 89 c7 mov %eax,%edi
5309: 81 c7 e8 01 00 00 add $0x1e8,%edi
530f: 31 f6 xor %esi,%esi
5311: b8 f0 00 00 00 mov $0xf0,%eax
5316: 89 f1 mov %esi,%ecx
5318: 87 fb xchg %edi,%ebx
531a: 65 ff 15 10 00 00 00 call *%gs:0x10
5321: 87 fb xchg %edi,%ebx
5323: eb ec jmp 5311 <start_thread+0x12f>
(likewise)
2006-02-08 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_futex_wait,
lll_futex_timedwait, lll_wait_tid): Add "memory" clobber.
--- libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h.jj 2006-01-06 06:01:25.000000000 +0100
+++ libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h 2006-02-08 11:12:25.000000000 +0100
@@ -75,7 +75,8 @@
: "=a" (__status) \
: "0" (SYS_futex), LLL_EBX_REG (futex), "S" (0), \
"c" (FUTEX_WAIT), "d" (_val), \
- "i" (offsetof (tcbhead_t, sysinfo))); \
+ "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
__status; \
})
@@ -90,7 +91,8 @@
: "=a" (__status) \
: "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \
"c" (FUTEX_WAIT), "d" (_val), \
- "i" (offsetof (tcbhead_t, sysinfo))); \
+ "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
__status; \
})
@@ -346,7 +348,8 @@ extern int lll_unlock_wake_cb (int *__fu
: "=&a" (__ignore) \
: "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \
"c" (FUTEX_WAIT), "d" (_tid), \
- "i" (offsetof (tcbhead_t, sysinfo))); \
+ "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
} while (0)
extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix i?86 lll_futex_{,timed_}wait and lll_wait_tid
2006-02-08 10:30 [PATCH] Fix i?86 lll_futex_{,timed_}wait and lll_wait_tid Jakub Jelinek
@ 2006-02-08 15:51 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2006-02-08 15:51 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers
[-- Attachment #1: Type: text/plain, Size: 101 bytes --]
Applied.
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-08 15:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-08 10:30 [PATCH] Fix i?86 lll_futex_{,timed_}wait and lll_wait_tid Jakub Jelinek
2006-02-08 15:51 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).