The Intel p4 manual suggests inserting a pause instruction in
spin-wait loops as a hint to what the code is doing. In other
respects it acts just like a nop. Pause (0xF3 0x90) currently
causes valgrind to panic. The patch below keeps things running.
vg_signals.c: vg_oursignalhandler(): don't longjmp() on fatal signal if
the scheduler's jmp_buf is not valid. This might avoid at least some
of the following:
vg_scheduler.c:479 (run_thread_for_a_while): Assertion `trc == 0'
failed.
Julian Seward [Sun, 30 Jun 2002 12:44:54 +0000 (12:44 +0000)]
Implement --weird-hacks=truncate-writes to limit the size of write syscalls
to 4096, to possibly avoid deadlocks under very rare circumstances.
Is fully documented and commented.
Julian Seward [Sun, 30 Jun 2002 10:57:30 +0000 (10:57 +0000)]
cleanup_after_thread_exited: also clean up the waiting_fds table on thread
disappearance. This fixes an assertion failure to do with thread nukage
on fork():
vg_scheduler.c:936 (poll_for_ready_fds):
Assertion `vgPlain_is_valid_tid(tid)' failed.
Julian Seward [Thu, 20 Jun 2002 10:25:37 +0000 (10:25 +0000)]
Fix subtle bug in the interaction between pthread_create and thread_wrapper,
exposed by scheduling changes caused by commit vg_scheduler.c rev 1.70.
We cannot simply pass the __attr pointer to the child, since it could
point to stuff on the parent's stack, which might not exist by the time
the child looked at it. Prior to scheduler.c rev 1.70 the child would
have been scheduled as soon as created, so the access was made before the
parent could clear the stuff from its stack. From rev 1.70 and after
the parent continues after creating the child, causing invalid stack
accesses when the child finally runs.
Julian Seward [Thu, 20 Jun 2002 10:19:38 +0000 (10:19 +0000)]
Rationalise client-request handling a bit, by merging the two switches
into one. This can change the scheduling a bit since the policy of
running the same thread after the request if it is possible now applies
to _all_ requests.
Julian Seward [Thu, 13 Jun 2002 17:47:05 +0000 (17:47 +0000)]
Be more robust to the situation where a signal arrives, and there is a
handler, but in the interval between the signal arriving and it being
delivered to the client, the handler is removed.
Julian Seward [Thu, 13 Jun 2002 16:07:51 +0000 (16:07 +0000)]
Remove inclusion of <linux/module.h> and <asm/atomic.h> since that
seems to lead to a portability swamp. As a result, remove autoconf
check for <asm/atomic.h>. Replace all this junk with
VKI_SIZEOF_STRUCT_MODULE (== 96) since that's all I ever wanted to
know in the first place.
vg_annotate.in:
- fixed a bug that was breaking the --threshold option.
vg_cachesim.c:
- fixed a bug that meant instructions that didn't have a line number in the
debug info were being written in cachegrind.out with whatever was the
last known line number. Now using 0.
Removed the need for the user to generate a cache simulation -- now do
automatic cache configuration detection using the CPUID instruction.
This can be overridden from the command-line if necessary.
vg_include.h:
- added the cache_t type and UNDEFINED_CACHE macro
- added command line args (of type cache_t) allowing manual override of
I1/D1/L2 configuration
- added log2(), which is generally useful
vg_main.c, valgrind.in, cachegrind.in:
- added handling of the new --{I1,D1,L2}=<size>,<assoc>,<line_size>
options
vg_cachesim.c:
- lots of stuff for auto-detecting cache configuration with CPUID.
Only handles Intel and AMD chips at the moment, and possibly not all of
them. Falls back onto defaults if anything goes wrong, and the configs
can be manually overridden from the command line anyway.
- now not printing cache summary stats if verbosity == 0. Still writing
cachegrind.out, though.
vg_cachesim_gen.c:
- new file containing stuff shared by the I1/D1/L2 simulations
vg_cachesim_{I1,D1,L2}:
- removed most of it; each now just calls a macro defined in
vg_cachesim_gen.c
vg_cachegen:
- has been cvs removed as it is no longer needed.
Julian Seward [Thu, 6 Jun 2002 01:27:39 +0000 (01:27 +0000)]
When a thread in a nanosleep() wait is interrupted by a non-restartable
signal, cause the nanoslep to return with EINTR. Then, in the user-space
nonblocking select() implementation, notice this and correspondingly return
with EINTR. This appears to fix the MySQL hang-at-exit problem.
Julian Seward [Wed, 5 Jun 2002 21:22:04 +0000 (21:22 +0000)]
Only terminate stack traces when the %ebp trail goes cold, and not
just because some addresses cannot be mapped to anything.
Needed to give sensible stack traces on Red Hat 7.3.
Julian Seward [Wed, 5 Jun 2002 20:28:33 +0000 (20:28 +0000)]
Minor mods to stop make the leak detector behave properly for the
following kind of stupid test program
int main (void) { char* a = malloc(100); return 0; }
which many people seem fond of trying for some reason.
In general the leak detector works fine.
Small improvement to stabs reader to avoid warnings of this form:
--14081-- warning: function CloseSocket__Fi:F(0,20) missing closing N_FUN stab at entry 10052
which were common when compiling with GCC's -gstabs option.
Instead of relying on an end-of-function N_FUN entry to handle the final
N_SLINE of a function, it can now handle it by finding the difference between
the start of the previous function and the start of the next.
Cache simulator now handles basic block discards correctly. When
VG_(cachesim_discard_notify) is called, the cost centre array for the basic
block is removed from the table, and its counts are aggregated into a single
"discard" cost centre, and the cost centre array is free'd.
The aggregate discard cost centre is given the filename:function_name
"(discarded):(discarded)". Mentioned this in the manual.
Only tested with tests/discard.c. Seems to work well for that case though :)
Added compile-time option to print instruction addresses for each line in
cachegrind.out. Increases file size by a fair bit, but useful for debugging
stabs errors <sigh>
Julian Seward [Tue, 4 Jun 2002 20:59:16 +0000 (20:59 +0000)]
- report the size requested size in pthread_attr_setstacksize() when
the size is bigger then the hardcoded value in valgrind. This
makes it easier to find out which value to use for
VG_PTHREAD_STACK_SIZE.
Julian Seward [Tue, 4 Jun 2002 09:44:09 +0000 (09:44 +0000)]
Fix bug in signal handling in threads shown by Peter Gober:
A signal *specifically directed* to one thread cannot be used
to fulfill a sigwait() request by some other thread, reasonably
enough.
Julian Seward [Tue, 4 Jun 2002 08:38:04 +0000 (08:38 +0000)]
Inch towards JVM (Sun, 1.4.0) working.
- Thread stack size = 1 Meg
- Alias for __pthread_kill_other_threads_np
Now at least valgrind doesn't crash/assert. Still doesn't work tho.