Also start trying to del with some redir issues.
For some libc functions the plain function gets replaced by a
checked version (not sure if this is only for debug builds).
For instance in /usr/include/secure/_string.h there are a load of macros
that look like
/* void *memccpy(void *dst, const void *src, int c, size_t n) */
__builtin___memccpy_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
To defeat these macros I've put the function name in parens. That hasn't
solved the issue. In addition these seems to be an ifunc like mechanism
that resolves calls to platform functions. For instance
nm /usr/lib/system/*dylib | grep memcc
0000000000081e14 T ___memccpy_chk
U __platform_memccpy
I _memccpy (indirect for __platform_memccpy)
0000000000004eb4 T __platform_memccpy
That matches what I see in lldb (memccpy then function lookup code then _platform_memccpy).
Need to look at how indirects work.
cxx17_aligned_new.stdout.exp \
duplicate_align_size_errors.stderr.exp \
duplicate_align_size_errors.stderr.exp-memalign \
+ duplicate_align_size_errors.stderr.exp-darwin \
duplicate_align_size_errors.vgtest \
sized_aligned_new_delete_args.stderr.exp \
sized_aligned_new_delete_args.vgtest \
--- /dev/null
+Invalid alignment value: 0 (should be non-zero and a power of 2)
+ at 0x........: operator new(unsigned long, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+ by 0x........: main (duplicate_align_size_errors.cpp:19)
+
+Invalid alignment value: 0 (should be non-zero and a power of 2)
+ at 0x........: operator delete(void*, std::align_val_t, std::nothrow_t const&) (vg_replace_malloc.c:...)
+ by 0x........: main (duplicate_align_size_errors.cpp:20)
+
+Mismatched new/delete size value: 33
+ at 0x........: operator delete(void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+ by 0x........: main (duplicate_align_size_errors.cpp:43)
+ Address 0x........ is 0 bytes inside a block of size 32 alloc'd
+ at 0x........: operator new(unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+ by 0x........: main (duplicate_align_size_errors.cpp:42)
+
+Mismatched new[]/delete[] alignment alloc value: 64 dealloc value: 128
+ at 0x........: operator delete[](void*, unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+ by 0x........: main (duplicate_align_size_errors.cpp:48)
+ Address 0x........ is 0 bytes inside a block of size 32 alloc'd
+ at 0x........: operator new[](unsigned long, std::align_val_t) (vg_replace_malloc.c:...)
+ by 0x........: main (duplicate_align_size_errors.cpp:47)
+
{
char* astring = strdup("this is a string # with something to seek");
size_t len = strlen(astring);
- memccpy(astring+10, astring, '#', len-10);
+ (memccpy)(astring+10, astring, '#', len-10);
sprintf(astring, "this is a string # with something to seek");
- memccpy(astring, astring+10, '#', len);
+ (memccpy)(astring, astring+10, '#', len);
sprintf(astring, "this is a string # with something to seek");
/*
assert(res && *res == 'g');
sprintf(astring, "this is a string # with something to seek");
/* length is 0, nothing copied, returns NULL */
- res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0);
+ res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 0);
assert(NULL == res);
/* 'z' not found so 20 bytes copied, returns NULL */
- res = memccpy(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20);
+ res = (memccpy)(astring, "abcdefhhijklmnopqrstuvwxy", 'z', 20);
assert(NULL == res);
free(astring);
}
memcpy(x, x+20, 21); // overlap
strncpy(x+20, x, 20); // ok
- strncpy(x+20, x, 21); // overlap
+ (strncpy)(x+20, x, 21); // overlap
strncpy(x, x+20, 20); // ok
- strncpy(x, x+20, 21); // overlap
+ (strncpy)(x, x+20, 21); // overlap
x[39] = '\0';
strcpy(x, x+20); // ok
x[39] = 39;
x[40] = '\0';
- strcpy(x, x+20); // overlap
+ (strcpy)(x, x+20); // overlap
x[19] = '\0';
strcpy(x+20, x); // ok
always run forever, I think... */
for ( i = 0; i < 2; i++)
- strncat(a+20, a, 21); // run twice to check 2nd error isn't shown
- strncat(a, a+20, 21);
+ (strncat)(a+20, a, 21); // run twice to check 2nd error isn't shown
+ (strncat)(a, a+20, 21);
/* This is ok, but once gave a warning when strncpy() was wrong,
and used 'n' for the length, even when the src was shorter than 'n' */