Hi John:
        I follow your instruction that upgrade the valgrind  from 3.12 to 3.13. 
  It seem to be okay, Thank you. I did not find any change in the vg_preload.c 
vg_redir.c .  Can you tell me why the error  do not occur.

        But there is some mistake, I  still need to find out why.
        
        I run the aarch64 Application, with valgrind 3.13..
        It show me this error:
==23233== Mismatched free() / delete / delete []
==23233==    at 0x582144C: operator delete[](void*) (vg_replace_malloc.c:620)
==23233==    by 0x531351B: android::List<android::sp<android::IVPBuffer> 
>::~List() (List.h:174)
==23233==    by 0x5313233: RPCParcel::~RPCParcel() (RPCParcel.h:166)
==23233==    by 0x5313273: RPCParcel::~RPCParcel() (RPCParcel.h:162)
==23233==    by 0x9DCFA2F: android::RefBase::decStrong(void const*) const 
(RefBase.cpp:434)
==23233==    by 0x5312E8B: android::sp<IRPCParam>::~sp() (StrongPointer.h:157)
==23233==    by 0x53127E7: test_xvAlloc_proxy(char*, int) (test7.cpp:21)
==23233==    by 0x5313037: processAlgo (test7.cpp:45)
==23233==    by 0x55B1CAB: android::PPAlgorithmEngine::processAlgo(void*, int, 
android::imageBufInfos*) (PPAlgorithmEngine.cpp:237)
==23233==    by 0xA3561D7: Call(void*, unsigned int, double*) (ivptest.cpp:166)
==23233==    by 0x11D00B: CHECK_STUB_IVP_ALLOCDualTile_Test::TestBody() 
(testIT_xvAlloc.cpp:27)
==23233==    by 0x14BEDF: testing::Test::Run() (gtest.cc:0)
==23233==  Address 0x4ae91c0 is 0 bytes inside a block of size 24 alloc'd
==23233==    at 0x582082C: operator new(unsigned long) 
(vg_replace_malloc.c:333)----------------------------------------show me  I 
call new() function  not new[]
==23233==    by 0x531349F: android::List<android::sp<android::IVPBuffer> 
>::prep() (List.h:294)
==23233==    by 0x53130D3: android::List<android::sp<android::IVPBuffer> 
>::List() (List.h:166)
==23233==    by 0x531285F: RPCParcel::RPCParcel() (RPCParcel.h:146)
==23233==    by 0x53126EB: test_xvAlloc_proxy(char*, int) (test7.cpp:10)
==23233==    by 0x5313037: processAlgo (test7.cpp:45)
==23233==    by 0x55B1CAB: android::PPAlgorithmEngine::processAlgo(void*, int, 
android::imageBufInfos*) (PPAlgorithmEngine.cpp:237)
==23233==    by 0xA3561D7: Call(void*, unsigned int, double*) (ivptest.cpp:166)
==23233==    by 0x11D00B: CHECK_STUB_IVP_ALLOCDualTile_Test::TestBody() 
(testIT_xvAlloc.cpp:27)
==23233==    by 0x14BEDF: testing::Test::Run() (gtest.cc:0)
==23233==    by 0x14C9EB: testing::TestInfo::Run() (gtest.cc:2655)
==23233==    by 0x14CE57: testing::TestCase::Run() (gtest.cc:2773)

And then I objdump the so , the machine code show me as below:
 000000000000446c <android::List<android::sp<android::IVPBuffer> >::prep()>:
_ZN7android4ListINS_2spINS_9IVPBufferEEEE4prepEv():
system/core/libutils/include/utils/List.h:293
    446c:       d10083ff        sub     sp, sp, #0x20
    4470:       a9017bfd        stp     x29, x30, [sp,#16]
    4474:       910043fd        add     x29, sp, #0x10
    4478:       b27d07e8        orr     x8, xzr, #0x18
    447c:       f90007e0        str     x0, [sp,#8]
    4480:       f94007e0        ldr     x0, [sp,#8]
system/core/libutils/include/utils/List.h:294
    4484:       f90003e0        str     x0, [sp]
    4488:       aa0803e0        mov     x0, x8
    448c:       97fffb8b        bl      32b8 <operator new[](unsigned 
long)@plt> -------------------It show me I used the new[] function not the 
new(),but valgrind show me I used the new()
    4490:       f94003e8        ldr     x8, [sp]
    4494:       f9000500        str     x0, [x8,#8]
system/core/libutils/include/utils/List.h:295
    4498:       f9400500        ldr     x0, [x8,#8]
    449c:       f9400501        ldr     x1, [x8,#8]
    44a0:       9400002a        bl      4548 
<android::List<android::sp<android::IVPBuffer> 
>::_Node::setPrev(android::List<android::sp<android::IVPBuffer> >::_Node*)>
system/core/libutils/include/utils/List.h:296
    44a4:       f94003e8        ldr     x8, [sp]
    44a8:       f9400500        ldr     x0, [x8,#8]
    44ac:       f9400501        ldr     x1, [x8,#8]
    44b0:       9400002e        bl      4568 
<android::List<android::sp<android::IVPBuffer> 
>::_Node::setNext(android::List<android::sp<android::IVPBuffer> >::_Node*)>
system/core/libutils/include/utils/List.h:297
    44b4:       a9417bfd        ldp     x29, x30, [sp,#16]
    44b8:       910083ff        add     sp, sp, #0x20
    44bc:       d65f03c0        ret
BR
Owen



-----邮件原件-----
发件人: John Reiser [mailto:jrei...@bitwagon.com] 
发送时间: 2018年4月5日 12:17
收件人: valgrind-users@lists.sourceforge.net
主题: Re: [Valgrind-users] [HELP] I run the valgrind in the unreleased android 
version(arm32), I am confused by function stack. Can you show me why?

>              Why I call the strcmp, but function stack show that the 
> strcat is  called not the strcmp, but the file is belong to the 
> function strcmp
>              Can you show the how to replace the strcmp with 
> “STRCMP(VG_Z_LIBC_SONAME,          strcmp)”, and then  I can follow the code 
> to find out why.
> 
>              I can find the code you set the LD_PRELOAD ,  but symbol name  
> is not match,  I do not know how you replace the strcmp with 
> STRCMP(VG_Z_LIBC_SONAME,          strcmp).
>              Can  you help to point out the function do the job 
> replace the strcmp with STRCMP(VG_Z_LIBC_SONAME,          strcmp)”,
> 
> Valgrind 3.12.
> CPU:arm

#include <errno.h>
#include <limits.h>
#include <stdatomic.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

_Atomic(unsigned int ) g_status;

#define __unused /*empty*/
#define __predict_true /*empty*/

int main(int argc __unused , char ** argv __unused ) {
         unsigned int init = 1;
         int flag = 1;
         unsigned int expect = random();
         unsigned int value = 2;
         atomic_init(&g_status, init);

         if (__predict_true(atomic_compare_exchange_strong_explicit(&g_status, 
&expect,
                              value, memory_order_acquire, 
memory_order_relaxed))) {
             flag = 0;
         }

         printf("Done  flag:%d cmp:%d \n", flag, strcmp("aaaa", "cccc") );
         return  1;
}


The compiler name and version were not specified.  I used:
        gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20) As shown, I had to 
#define the symbols __unused and __predict_true.


> Valgrind show me output :
> ==30141== Invalid write of size 4
> ==30141== at 0x4C27CAE: strcat(strcmp.c:3) ==30141==    by 0x108871: 
> main (testClang.c:27) ==30141==  Address 0xfeb445bc is on thread 1's 
> stack ==30141==  12 bytes below stack pointer

Using valgrind-3.13 on Fedora 28 beta for armv7l (armhfp; 32-bit ARM):
$ valgrind ./predict
==2012== Memcheck, a memory error detector ==2012== Copyright (C) 2002-2017, 
and GNU GPL'd, by Julian Seward et al.
==2012== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info 
==2012== Command: ./predict ==2012== Done  flag:1 cmp:-1 ==2012== ==2012== HEAP 
SUMMARY:
==2012==     in use at exit: 0 bytes in 0 blocks
==2012==   total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==2012==
==2012== All heap blocks were freed -- no leaks are possible ==2012== ==2012== 
For counts of detected and suppressed errors, rerun with: -v ==2012== ERROR 
SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech 
sites, Slashdot.org! http://sdm.link/slashdot 
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to