Commit Graph

174 Commits

Author SHA1 Message Date
Nicholas Nethercote
266836ab69 Arch-abstraction:
- Factored out the remaining arch-specific code from vg_libpthread.c.
- Also fixed up the build process for x86/libpthread.c, which was done
  wrongly in the previous commit.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2798
2004-10-19 13:18:00 +00:00
Nicholas Nethercote
7ac2403543 Arch-abstraction:
- Started out x86-specific libpthread code; began with spinlocks.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2797
2004-10-19 11:38:48 +00:00
Tom Hughes
e581bc5f41 Really fix statically initialised read-write locks this time...
BUG: 91604


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2796
2004-10-18 23:03:24 +00:00
Tom Hughes
25725b8d8b Make statically initialised read-write locks work.
BUG: 91604


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2790
2004-10-18 17:34:43 +00:00
Tom Hughes
f5216fc7c7 Add a couple of lines that were missed out in the long timeouts patch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2783
2004-10-18 12:11:23 +00:00
Tom Hughes
2d7c989f9a Fix problems with very long timeouts given when waiting on a mutex or
condition variable. The pthread routines now use a timeout of 0xfffffffe
if the user asks for something longer than that otherwise we will wrap
around and actually get a much shorter timeout.

The scheduler has also been changed so that it it now limits itself to
a timeout of 0x7fffffff when working how how long to poll for. This won't
affect how long a thread actually sleeps for as we'll just wind up waiting
a bit more on the next pass round the loop.

This fixes bug 76845.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2781
2004-10-17 15:18:22 +00:00
Tom Hughes
b7229cb4fc Implement pthread_mutex_timedlock. This resolves bug 78422.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2780
2004-10-17 15:00:20 +00:00
Tom Hughes
e7e79a576f Remove the limit on the number of pthread read/write locks. This works
in a similar way to the previous patch that removed the limit on the
number of semaphores and fixes bug 86264.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2776
2004-10-16 14:49:53 +00:00
Tom Hughes
6204049d43 Add a dummy implementation of pthread_attr_getinheritsched.
BUG: 79495


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2775
2004-10-16 14:24:43 +00:00
Tom Hughes
f2f2fe6cb7 Yet another attempt to quash the assertions in the pthread forwarding code.
It appears that the resolution of the address is to forward to is now
working properly but that on some systems the second part of the assertion
fails because the dynamic linker resolves the name of the function being
forwarded to the glibc version rather than the version in valgrind's pthread
library.

The solution is to use dlopen to explicitly obtain a handle to valgrind's
pthread library and then lookup the symbol with dlsym when doing the
comparison in the assertion.

BUG: 88614


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2772
2004-10-16 10:50:11 +00:00
Tom Hughes
5aa943f129 Implement pthread_mutexattr_gettype.
CCMAIL: 91199-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2759
2004-10-13 18:29:54 +00:00
Tom Hughes
18ee5b49cb Fix conversion of timeval to milliseconds - tv_usec is microseconds
and not nanoseconds.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2726
2004-09-27 18:55:55 +00:00
Nicholas Nethercote
ba210a6364 Arch-abstraction step: renamed "vg_include.h" as "core.h".
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2643
2004-09-01 23:58:16 +00:00
Nicholas Nethercote
a2b3609df7 Small step in factoring out arch-specific code: replace
__attribute((regparm(n))) with REGPARM(n) everywhere.  REGPARM() is defined in
vg_skin.h, but will eventually be defined separately for each arch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2601
2004-08-23 15:06:23 +00:00
Tom Hughes
57d86ee4de More fixes for the cancellation wrappers in libpthread - if looking
for the original function with RTLD_NEXT doesn't work then try looking
for the __libc_ version of the function the RTLD_DEFAULT instead.

The reason for this is that, contrary to the dlsym documentation, it
seems that RTLD_NEXT doesn't always seem to find the definition that
would have been used if it weren't for the override. This is particularly
common wihen libpthread is pulled in implicitly by a dependency from
another library.

This should hopefully fix bug #85658.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2595
2004-08-22 22:56:25 +00:00
Tom Hughes
42c7adce45 Maek init_global_thread_specific_state as a constructor to try and ensure
that it is called as soon as libpthread.so is loaded even if pthread_create
is never called.

This ensures that pthread_exit will work correctly, and I think will also
cure the famous memory leak in the pthread specifics for the main thread.

CCMAIL: 86730-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2584
2004-08-14 15:37:59 +00:00
Tom Hughes
5392f371af Make sure init_global_thread_specific_state() set the global_init_done
flag before the call to __uselocale() in order to avoid deadlock.

CCMAIL: 77952-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2493
2004-07-17 11:08:03 +00:00
Tom Hughes
0142b68d33 Removed duplicate call to rw_remap.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2445
2004-06-27 13:26:44 +00:00
Tom Hughes
03df333128 Commit the patch from bug 69508 that seeks to make more of the pthread
stack attribute related functions work properly as it seems to be a
sensible thing to improve even if it isn't enough to get the JVM running
under valgrind now.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2444
2004-06-27 12:48:53 +00:00
Tom Hughes
f267e2c7d0 Fixed the NPTL cleanup handler support to try and make sure it will
compile on systems with NPTL header files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2406
2004-06-12 17:25:25 +00:00
Tom Hughes
83780627b5 It appears that NPTL uses a new system for dealing with cleanup
handlers when a thread is cancelled which has the side effect that
programs linked with librt fail on Fedora Core 2 due to librt having
been built against the NPTL header instead of the old pthread headers.

This change extends valgrind's libpthread.so to handle both the old
and new style cleanup handlers in a similar way to NPTL and seems to
be sufficient to get programs linked with librt working again.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2405
2004-06-12 12:58:22 +00:00
Tom Hughes
0bbe5bb70d There is no __accept in any libc or libpthread that I can find so
it isn't clear why we were intercepting that and only aliasing accept
to it. Switched to intercepting accept directly instead.

CCMAIL: 76869-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2404
2004-06-04 21:42:18 +00:00
Tom Hughes
95776fd744 Changed cancellation wrappers to use dlsym(RTLD_NEXT) to look up the
libc version of the wrapped function when forwarding the call rather
than trying to call the internal __libc_xxx version of the routine
as many of those are marked as GLIBC_PRIVATE in recent releases.

CCMAIL: 82026-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2402
2004-06-03 18:00:58 +00:00
Nicholas Nethercote
f7c264da4c Remove "pre-history" handling for mutexes -- now that Valgrind has full control
from the very beginning (thanks to FV) it's no longer necessary.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2356
2004-04-10 00:54:42 +00:00
Tom Hughes
b769d6df88 Implement tcdrain in the pthread library. The fact that this function
is missing was reported in bug #70344 but the reporter then closed the
bug saying that they were using the wrong version of valgrind.

Patch from Henrik Algestam <algestam@home.se>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2346
2004-03-31 15:23:13 +00:00
Tom Hughes
67bb2b010d Commit rewrite of semaphore handling to avoid having a fixed upper
limit. Patch courtesy of Aleksander Salwa <A.Salwa@osmosys.tv>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2336
2004-03-23 19:48:54 +00:00
Jeremy Fitzhardinge
d402c5408c When creating new threads, initially block all signals. It's up to the
client code (in vg_libpthread.c) to set the appropriate signal mask when
its ready.  This prevents a bug where a thread gets sent a signal before
even running any of its initialization code, which can cause problems
(particularly if the signal handler directly or indirectly uses TLS).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2332
2004-03-16 22:09:12 +00:00
Tom Hughes
ec672c606d Remove function which is no longer used following the changes to
the handling of libc thread specific data.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2297
2004-03-08 15:57:17 +00:00
Tom Hughes
2494bba71b Fix the handling of libc thread specific data so that it doesn't rely on
being able to use malloc as the libc malloc tries to use thread specific
data and we wind up in a recursive nightmare.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2293
2004-03-07 19:36:14 +00:00
Nicholas Nethercote
9f16738ca3 Some newer systems have a new version of pthreadtypes.h that comes from glibc
2.3.3, which is binary-compatible, but not source compatible with the old one,
which came from LinuxThreads.  We were using the types defined in the old one,
which caused compilation errors on systems using the new one.

This commit introduces our own versions of these types.  Our versions are laid
out identically to the LinuxThreads ones, but the field names are different.
We convert all pthread types to our versions before using them, so we don't
rely on the pthreadtypes.h types any more.  Hopefully this will fix the
problem;  I have three reports that it does.  Let's see...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2272
2004-02-28 15:40:36 +00:00
Jeremy Fitzhardinge
75d6dc8434 This change implements the TLS extension to the x86 ABI. This allows
threads to have thread-private data which is quickly accessible via a
segment in the GDT, stored in %gs.  The patch implements the relevent
syscalls (setthreadarea), and also manages switching the VCPU's segment
information at thread context-switch time.  Mostly Tom Hughes' work.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2215
2004-01-21 01:27:27 +00:00
Nicholas Nethercote
07b8e3438b Updated copyright dates for 2004. Also added a couple of missing headers and
footers to some new files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2177
2004-01-04 16:43:23 +00:00
Julian Seward
6bbfc962d3 (David Lee, <david.lee@teracruz.com>)
This patch fixes a semaphore leak within valgrind. If your application
dynamically allocates/releases semaphores, you will very quickly run out.
Also, as a nice side effect, it implements sem_destroy properly.

(me)
Protect sem_getvalue with a lock/unlock of the semaphore's mutex,
like the other routines do.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2153
2004-01-02 11:39:06 +00:00
Jeremy Fitzhardinge
918c3a7b7e This jumbo-checkin is the Full Virtualization checkin. This eliminates
Valgrind's dependency on the dynamic linker for getting started, and
instead takes things into its own hands.

This checkin doesn't add much in the way of new functionality, but it
is the basis for all future work on Valgrind.  It allows us much more
flexibility in implementation, and well as increasing the reliability
of Valgrind by protecting it more from its clients.

This patch requires some changes to tools to update them to the changes
in the tool API, but they are straightforward.  See the posting "Heads
up: Full Virtualization" on valgrind-developers for a more complete
description of this change and its effects on you.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2118
2003-12-16 02:05:15 +00:00
Nicholas Nethercote
d6d804d382 Updated all "report bugs to..." messages to point to valgrind.kde.org; also
updated the docs to refer to valgrind.kde.org instead of the old website.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2055
2003-11-20 16:20:55 +00:00
Nicholas Nethercote
b6e961b0bf Improved vg_libpthread's IGNORED/KLUDGED error messages; lots of people found
"kludged" confusing.  Even printing out brief explanations of why functions are
ignored/kludged, in some cases.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2054
2003-11-20 14:23:09 +00:00
Nicholas Nethercote
c4d186f121 Removed no-longer-needed declarations of __SOME_SKIN_H.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2025
2003-11-13 23:02:16 +00:00
Dirk Mueller
25a97a8692 fix build with kernel 2.6.x
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1941
2003-10-16 16:14:13 +00:00
Jeremy Fitzhardinge
1e6361234c A complete reworking of Valgrind's handling of system calls and signals,
with the aim of making it more robust, more correct and perhaps faster.

This patch removes the need to poll blocking syscalls, by adding a proxy
LWP for each application thread.  This LWP is a kernel thread whose job
is to run all (potentially) blocking syscalls, and also to handle signals.

This allows the kernel to do more of the work of dealing with signals,
so on kernels which do this properly (2.6), Valgrind's behavious is a
lot more posix compliant.  On base 2.4 kernels, we emulate some of the
missing 2.6 functionality.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1918
2003-10-13 22:26:55 +00:00
Nicholas Nethercote
f5ba3bad17 Added a couple of small #ifdefs so that Valgrind works with Erik Anderson's
uClibc (micro libc, a small alternative to glibc).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1908
2003-10-12 17:26:04 +00:00
Julian Seward
b820f69079 Delete some "inline" directives on functions that gcc-3.3.1 declined
to inline.  This is needed to get a warning-free compilation on 3.3.1.
It seems we had "inline" on some pretty huge functions in places.
Also it appears gcc-3.3.1 won't inline a function call in a tail call
position, reasonably enough.  I assume in that case it prefers to
create a tailcall to the callee, rather than inlining it.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1907
2003-10-12 10:27:06 +00:00
Julian Seward
b3e4bdb2a5 Implement pthread_spinlock_* (Tim Potter, tpot@samba.org)
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1902
2003-10-12 08:33:30 +00:00
Nicholas Nethercote
c8c6b4132e Fix minor cut+paste error.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1856
2003-09-29 12:58:37 +00:00
Dirk Mueller
612b8daeac fix compiler warnings
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1823
2003-09-18 01:39:50 +00:00
Julian Seward
9ee2fd8e43 A new implementation of pthread_once() which I believe should comply
properly with POSIX, and not get assertion failures when the same
thread makes nested calls to pthread_once with different once_control
pointers.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1746
2003-07-11 00:12:58 +00:00
Julian Seward
090be413d9 Fix up weak binding for pthread_mutexattr_setpshared.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1726
2003-07-06 01:29:49 +00:00
Julian Seward
cceee45f87 Implement pthread_mutexattr_setpshared (Nick did this).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1724
2003-07-06 01:23:11 +00:00
Dirk Mueller
2416fb6967 don't bail out when pthread_once's init route calls itself recursively
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1684
2003-06-13 12:24:41 +00:00
Julian Seward
ecee893b06 Improve threaded handling of errno:
- Change various incorrect direct references to errno into
  *(__errno_location()).

- In __errno_location and __h_errno_location, treat the tid==1 case
  (root thread) specially, as with __res_state().

This seems to fix a bug in threaded handling of errno on R H 9 and SuSE8.2,
and almost makes OpenOffice work again on R H 9.

MERGE TO STABLE, if it doesn't break anything.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1625
2003-05-09 23:40:34 +00:00
Julian Seward
e455ba148d Fix interception of pthread_atfork with glibc-2.3.2.
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1587
2003-05-04 12:35:54 +00:00