On Fri, 2012-12-28 at 22:45 -0800, Roger Binns wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I'm running 3.8.1 on MacOS 10.7 with an Objective-C app compiled using > ARC. I need to see where an object was allocated, not just where it was > freed. > > An object is getting accessed after free in an autoreleasepool. However > due to ARC pretty much everything is freed in an autoreleasepool so I > can't tell where the item was actually allocated to further help diagnose.
Currently, memcheck remembers only one stack trace per block. When a block is allocated, this stack trace is the allocation stack trace. When this block is freed, the alloc stack trace is replaced by the stack trace where the block is freed. I think (not tested) that the below trivial change will keep the alloc stack trace: In the function die_and_free_mem (in memcheck/mc_malloc_wrappers.c), just comment the line: /* Record where freed */ mc->where = VG_(record_ExeContext) ( tid, 0/*first_ip_delta*/ ); Then the "where" will continue to be the alloc stack trace. It might be a good idea to have a new memcheck option --keep-alloc-stacktrace=yes|no and/or to allow to (optionally) remember and report the alloc stack trace in addition to the "free" stack trace. This will however imply (for a 64 bits platform) 8 bytes more per allocated block. Philippe ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 _______________________________________________ Valgrind-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/valgrind-users
