Florian Krohm [Wed, 3 Dec 2014 22:53:00 +0000 (22:53 +0000)]
Add -Wformat -Wformat-security to the list of compile flags.
This was not as straight forward as expected. Specifically, adding the
new flag to CFLAGS in configure.ac did not work and was causing
compiler warnings. For instance, compiling memcheck/tests/execve2.c will
generate a -Wnonnull warning even though the testcase is explicitly
compiled with -Wno-nonnull. The reason is that (a) -Wformat is implied by
-Wnonnull and (b) the list of compiler flags gets assembled in the wrong
order. The culprit appears to be that we modify CFLAGS in configure.ac and
that really is not the right place. Conceptually, configure should determine
tool-chain capabilities and not assemble compiler flags. That should be done
in Makefiles. This patch entangles all this.
So, whatever was added to CFLAGS in configure.ac has now been moved to
Makefile.all.am and Makefile.tool-tests.am. Those are:
-Wno-long-long
-Wwrite-strings
-Wcast-qual
-fno-stack-protector
Note, that this change allows us to simplify Makefile.tool-tests.am which
in the past was disabling some of those flags (e.g. by adding -Wno-cast-qual
again).
In case of the clang compiler, extra command line options are needed. I've
moved those into a separate 'if COMPILER_IS_CLANG' section and not merge
them into baseline flags.
Florian Krohm [Sat, 29 Nov 2014 14:41:32 +0000 (14:41 +0000)]
Fix BZ 334802. Patch by Mark Wielaard with a few mods to make it apply.
r14794 is related as well.
Also: remove -Wno-format-zero-length from compile options.
Florian Krohm [Sat, 29 Nov 2014 13:31:18 +0000 (13:31 +0000)]
Fix up the error processing in VG_(expand_file_name). E.g. giving
--log-file= on the command line results in the following error:
valgrind: --log-file: filename is emptyBad option: --log-file=
...
Relatedly, fix the 1st argument to VG_(expand_file_name) in coredump-elf.c.
This should not contain additional verbiage as it is assumed to be an option
name which us used to construct an error message containing
option_name=file_name
As an aside, this logic in coredump-elf.c seems odd:
If VG_(clo_log_fname_expanded) is not NULL, then it has already been
expanded in main_process_cmd_line_options. Expanding it again would only
make a difference, if the original logfile name contained an environment
variable whose value contained %q{whatever} thereby referring to a yet
another environment variable. That seems strange.
But I'm not touching it.
Change pub_tool_addrinfo.h AddrInfo and VG_(describe_addr) so as to describe
anonymous or file mmap-ed segments and shared memory segments.
* pub_tool_addrinfo.h:
new AddrTag Addr_SegmentKind // Client segment (mapped memory)
new struct SegmentKind in AddrInfo
* m_addrinfo.c:
If address is still undescribed, try to describe by findinf a client segment.
* update various tests
* mc_errors.c:
add a call to VG_(clear_addrinfo) in MC_(pp_describe_addr)
as the memory allocated in the local AddrInfo has to be cleared once
info is printed.
Florian Krohm [Mon, 24 Nov 2014 17:30:01 +0000 (17:30 +0000)]
As the BEAM checker correctly points out, the conditions on lines 430 and 485
are always false. I'm keeping them as assertions for documentation purposes.
The proof is left as exercise to the reader.
Hint: use conditions on lines 307 and 311 and the fact that old_len and
old_arg are both unsigned entities.
Julian Seward [Wed, 19 Nov 2014 09:15:56 +0000 (09:15 +0000)]
Add a lot more intercepts. Very crude. I am sure this is merely
hiding a whole bunch of problems in the Darwin syscall wrappers. In
particular it suppresses all invalid address errors arising from
AppleIntelHD4000GraphicsGLDriver.dylib, as it appears that maps
hardware into user space and aspacemgr doesn't know anything about it.
Julian Seward [Sat, 15 Nov 2014 10:29:57 +0000 (10:29 +0000)]
* add a logging mechanism to show repeated messages at exponentially
declining rates, so as to reduce the amount of junk spewed out by
the various support functions for the MacOS syscall wrappers.
* add a couple more cases to the resync filter for Yosemite. This
is working pretty well now.
Florian Krohm [Thu, 13 Nov 2014 21:41:28 +0000 (21:41 +0000)]
Merge revisions 14445 and 14446 from the BUF_REMOVAL branch to trunk.
Two things:
- remove the buffer argument from VG_(DebugInfo_sect_kind)
- allocate AddrInfo::SectKind::objname dynamically
* This option can be used to mark the begin/end of errors in textual
output mode, to facilitate searching/extracting errors in output files
mixing valgrind errors with program output.
* Use the new option in various existing regtests to test the various
possible usage.
Julian Seward [Tue, 11 Nov 2014 12:46:19 +0000 (12:46 +0000)]
PRE(mach_msg) on OSX 10.10 64-bit: replace failing assertion
vg_assert(! (mh->msgh_bits & MACH_SEND_TRAILER));
with a warning message, but let it continue.
Florian Krohm [Sun, 9 Nov 2014 21:57:23 +0000 (21:57 +0000)]
Fix a bug spotted by IBM's BEAM checker in VG_(describe_IP).
In the non-XML part buf_dirname was read without observing the
know_dirinfo guard. Now fixed. Initialise buf_dirname nevertheless.
Also remove a dead assignment.
Florian Krohm [Sun, 9 Nov 2014 16:15:23 +0000 (16:15 +0000)]
Change VG_(mkstemp) such that
(a) the 2nd argument must not be NULL
This was true anyhow and requiring it allows us to simplify the function
by eliminating the local buffer.
(b) the memory pointed to by the 2nd argument is always initialised
In the past the output file name was not initialised in case VG_(open)
failed 10 times in a row. The call sites in m_main.c and m_gdbserver/target.c
were reading the uninitialised filename unconditionally. This was spotted
by IBM's BEAM checker.
Fix call sites, eliminate some magic constants along the way.
Comment only changes.
* Clarify in the dedup pool comments that all bytes of elements are compared.
* pub_core_options.h : remove old/misplaced comment for clo_trace_children
and replace by a more clear comment (matching the --help)
Florian Krohm [Thu, 6 Nov 2014 22:01:15 +0000 (22:01 +0000)]
Merge revisions 14366 and 14367 from the BUF_REMOVAL branch to trunk.
In function dump_state_togdb use VG_(gdb_printf) directly. No need to write
to a buffer first.
Florian Krohm [Thu, 6 Nov 2014 21:43:44 +0000 (21:43 +0000)]
Merge revisions 14344 and 14345 from the BUF_REMOVAL branch to trunk.
Basically:
CLG_(sprint_eventmapping) --> CLG_(eventmapping_as_string)
CLG_(sprint_mappingcost) --> CLG_(mappingcost_as_string)
The new functions return the string in a dynamically allocated buffer
that caller ought to free.
Julian Seward [Thu, 6 Nov 2014 20:29:01 +0000 (20:29 +0000)]
Adds initial support for new syscalls on MacOS X 10.10, including new
syscall numbers, and dummy wrappers for bsdthread_ctl and
sysctlbyname. Mash up of patches from fxcoudert@gcc.gnu.org and Rhys
Kidd (rhyskidd@gmail.com). Part of bug 339045.
Julian Seward [Thu, 6 Nov 2014 20:23:22 +0000 (20:23 +0000)]
On MacOS X 10.10, when postprocessing tool executables, set the SVMA
of __PAGEZERO to zero. Without this, the 10.10 kernel refuses to
start these executables. Based on investigations and a
proof-of-concept implementation by Rhys Kidd (rhyskidd@gmail.com).
Part of bug 339045.
Julian Seward [Thu, 6 Nov 2014 20:20:01 +0000 (20:20 +0000)]
On MacOS X 10.10, provide a dummy definition for voucher_mach_msg_set.
Not sure why this is necessary, but without it, the tool executables
don't link. Part of bug 339045.
Julian Seward [Tue, 4 Nov 2014 17:35:04 +0000 (17:35 +0000)]
PRE(sys_openat): when checking whether ARG1 == VKI_AT_FDCWD, be sure
only to check the lowest 32 bits, since that arg is a file descriptor
-- hence "int" -- and checking all 64 bits fails unexpectedly if ARG1
and VKI_AT_FDCWD are not both zero- or sign- extended.
Florian Krohm [Tue, 4 Nov 2014 15:08:53 +0000 (15:08 +0000)]
Merge r14339 from BUF_REMOVAL branch to trunk.
Prepare print_file function to be converted to use VG_(fprintf).
Basically get rid of arithmetic involving the output buffer.
Florian Krohm [Mon, 3 Nov 2014 22:43:42 +0000 (22:43 +0000)]
Merge r14308 from the BUF_REMOVAL branch to trunk
Changes VG_(describe_IP) to return the untruncated result in a statically
allocated local buffer. Fix call sites and update two .exp files who had
truncated names.
fix 338995 shmat with hugepages (SHM_HUGETLB) fails with EINVAL
Bug is not really fixed, instead the SHM_HUGETLB flag is ignored.
Note that it is not straightforward to properly fix this,
as this implies either to learn aspacemgr what huge pages are.
Also, the trick used in the fix for 333051 cannot be used easily,
because the SHM_HUGETLB flag is given in shmget, while the mmap
is done in shmat.
So, the easiest is to just ignore the SHM_HUGETLB flag.
SHM_HUGETLB is supposed to only give a performance impact.
Ignoring it should be benign.
Theoretically, the caller might expect a sucessful shmget(SHM_HUGETLB)+shmat
to give pages aligned on e.g. 1MB.
In this case, bad luck, the program will misbehave under valgrind.
To warn of this, a warning is given (once) when SHM_HUGETLB is seen.
The map_unmap.c test has been restructured somewaht to allow
TEST_SHM_HUGETLB to be tested independently (or not) of the TEST_MAP_HUGETLB.
Note also that by default, testing MAP_HUGETLB and SHM_HUGETLB
is disabled as usually, huge pages are not enabled.
Fix 333051 mmap of huge pages fails due to incorrect alignment
Learning aspacemgr to handle huge page is too difficult.
So, huge page requests that fails due to bad advice by aspacemgr
will (we hope) succeed if a mmap retry is done with the kernel,
without any constraints.
Julian Seward [Sat, 1 Nov 2014 12:05:09 +0000 (12:05 +0000)]
Rearrange the test case generators to be exactly in the same order
that they are called, so as to make future editing easier. And
generally tidy up. No functional change.
Julian Seward [Fri, 31 Oct 2014 10:29:23 +0000 (10:29 +0000)]
Add test cases and expected outputs for
FMLA 2d_2d_d[], 4s_4s_s[], 2s_2s_s[]
FMLS 2d_2d_d[], 4s_4s_s[], 2s_2s_s[]
PRFM (immediate)
Unfortunately huge diff for arm64/fp_and_simd.stdout.exp because the
new cases are not at the end, and the random data for all after it is
different. ToDo: reset RNG after each test.
Florian Krohm [Thu, 30 Oct 2014 22:17:56 +0000 (22:17 +0000)]
Merge revisions 14222, 14268, and 14270 from the BUF_REMOVAL branch to trunk.
Assorted fixes in exp-bbv to eliminate a few buffers.
Implement a suggestion found in the massif source, namely to add the
equivalent of fprintf to m_libcprint. Good suggestion. Thusly
- VgFile: similar to FILE; buffered output, 8k buffer
- VG_(fopen): similar to fopen, but with arguments as in VG_(open)
- VG_(fprintf) and VG_(vfprintf): like [v]fprintf with VgFile 1at argument
- VG_(fclose)
Change massif, exp-bbv and cachegrind to use this functionality.
Florian Krohm [Wed, 29 Oct 2014 13:57:49 +0000 (13:57 +0000)]
Configury and Makefile tweaks to support compilation with Intel's
ICC Compiler. Patch mostly by Gregory Czajkowski <gregczajkowski@yahoo.com>.
Fixes BZ #339542.
Florian Krohm [Tue, 28 Oct 2014 20:52:07 +0000 (20:52 +0000)]
Merge revision 14309 from BUF_REMOVAL branch to trunk.
Eliminates a fixed size buffer in helgrind. Instead of building up a
string in a buffer and then writing the string to stdout can as well
write to stdout directly.
Florian Krohm [Tue, 28 Oct 2014 20:28:32 +0000 (20:28 +0000)]
When traversing VG_(args_for_client) there is no need to check
the array element for NULL. Function VG_(split_up_argv), which
sets up that array, ensures that no element is NULL.
Florian Krohm [Mon, 27 Oct 2014 12:06:35 +0000 (12:06 +0000)]
Merge revisions 14255, 14293, and 14294 from the BUF_REMOVAL branch to trunk.
The functions VG_(get_filename) and VG_(get_filename_lineno) now return
a pointer to filename and directory name instead of copying them into
buffers passed in from the caller.
The returned strings are persistent as long as the DebugInfo to which
they belong is not discarded. The caller therefore needs to stash them
away as needed.
Function VG_(strncpy_safely) has been removed as it is no longer needed.
Florian Krohm [Sun, 26 Oct 2014 19:16:14 +0000 (19:16 +0000)]
Merge r14289 from the BUF_REMOVAL branch to trunk.
Change CLG_(get_debug_info) to not build up an absolute pathname in its
'file' parameter. Instead give it an additional parameter to hold the
directory name. Callers can then build up the absolute pathname if needed.
This change will come in handy soonish when VG_(get_filename_lineno) will be
changed and those buffers will disappear.
The change has a bit of ripple to get_fn_node_inseg and CLG_(get_file_node).
Florian Krohm [Sun, 26 Oct 2014 17:12:12 +0000 (17:12 +0000)]
Merge r14288 from the BUF_REMOVAL branch to trunk.
What it does it changing cachegrind's get_debug_info function such
that it no longer builds up an absolute pathname. Instead the function
get an additional parameter for the directory name and the absolute
pathname is built when it is needed. This will come in handy soonish
when VG_(get_filename_lineno) will be changed and those buffers will
disappear.
Florian Krohm [Sat, 25 Oct 2014 19:20:38 +0000 (19:20 +0000)]
Merge r14202 from the BUF_REMOVAL branch to trunk.
This patch changes the interface and behaviour of VG_(demangle) and
VG_(maybe_Z_demangle). Instead of copying the demangled name into a
fixed sized buffer that is passed in from the caller (HChar *buf, Int n_buf),
the demangling functions will now return a pointer to the full-length
demangled name (HChar **result). It is the caller's responsiblilty to
make a copy if needed.
This change in function parameters ripples upward
- first: to get_sym_name
- then to the convenience wrappers
- VG_(get_fnname)
- VG_(get_fnname_w_offset)
- VG_(get_fnname_if_entry)
- VG_(get_fnname_raw)
- VG_(get_fnname_no_cxx_demangle)
- VG_(get_datasym_and_offset)
The changes in foComplete then forces the arguments of
- VG_(get_objname) to be changed as well
There are some issues regarding the ownership and persistence of
character strings to consider.
In general, the returned character string is owned by "somebody else"
which means the caller must not free it. Also, the caller must not
modify the returned string as it possibly points to read only memory.
Additionally, the returned string is not necessarily persistent. Here are
the scenarios:
- the returned string is a demangled function name in which case the
memory holding the string will be freed when the demangler is called again.
- the returned string hangs off of a DebugInfo structure in which case
it will be freed when the DebugInfo is discarded
- the returned string hangs off of a segment in the address space manager
in which case it may be overwritten when the segment is merged with
another segment
So the rule of thunb here is: if in doubt strdup the string.
Julian Seward [Thu, 23 Oct 2014 19:48:01 +0000 (19:48 +0000)]
Darwin only: add a filter mechanism that aims to remove pointless
memory-map resync operations. Without the filter, such operations
come to dominate the running time of complex apps with thousands of
memory segments (eg Firefox) and it becomes unusably slow. With
the filter in place, the huge performance loss is mostly avoided.
Has no meaning and no effect on non-Darwin targets. Controlled by
flag --resync-filter=no|yes|verbose [yes]. Filter is currently only
set up for Mac OS X 10.9 (Mavericks) 64 bit and will not produce
any performance benefit on any other configuration.