我正在尝试使用Callgrind监视SDL2应用程序中的缓存使用情况,但它挂起了SDL_Init调用 - 编辑:为了澄清,Valgrind挂起,我的程序没有进一步输出,Valgrind似乎陷入了困境等待函数调用完成,但它永远不会。这是一个展示问题的最小来源:
blank 20 February, 2016
blank 22 February, 2016
挂起时的输出:(编辑为包含额外的调试信息,使用flags -v -d和--fair-sched = try生成)
#include <SDL.h>
#include <iostream>
int main (int argc, char *argv[]) {
std::cout << "SDL Init" << std::endl;
if (SDL_Init(SDL_INIT_VIDEO) != 0 ) {
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
std::cout << "Done" << std::endl;
SDL_Quit();
return 0;
}
仅运行SDL Init
--5591:1: aspacem allocated valgrind thread stack at 0x7000050db000 size 1064960
--5591:1:syswrap- run_a_thread_NORETURN(tid=2): pre-thread_wrapper
--5591:1:syswrap- thread_wrapper(tid=2): entry
--5591-- REDIR: 0x104be985a (libsystem_malloc.dylib:malloc_size) redirected to 0x10013fb50 (malloc_size)
--5591-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option
--5591:1:mallocfr newSuperblock at 0x700005262000 (pszB 294880) unsplittable owner VALGRIND/ttaux
--5591:1:mallocfr reclaimSuperblock at 0x7000050AB000 (pszB 196576) unsplittable owner VALGRIND/ttaux
--5591-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option (repeated 2 times)
--5591-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option (repeated 4 times)
--5591:1: aspacem allocated valgrind thread stack at 0x70000532d000 size 1064960
--5591:1:syswrap- run_a_thread_NORETURN(tid=3): pre-thread_wrapper
--5591:1:syswrap- thread_wrapper(tid=3): entry
--5591:1: aspacem allocated valgrind thread stack at 0x700005431000 size 1064960
--5591:1:syswrap- run_a_thread_NORETURN(tid=4): pre-thread_wrapper
--5591:1:syswrap- thread_wrapper(tid=4): entry
--5591:1: aspacem allocated valgrind thread stack at 0x7000055b8000 size 1064960
--5591:1:syswrap- run_a_thread_NORETURN(tid=5): pre-thread_wrapper
--5591:1:syswrap- thread_wrapper(tid=5): entry
--5591-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option (repeated 8 times)
--5591:1:execonte resizing htab from size 1543 to 3079 (idx 2) Total#ECs=1544
--5591-- UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option (repeated 16 times)
--5591:1:hashtabl resizing table `MC_(malloc_list)' from 1543 to 3079 (total elems 1544)
--5591:1:syswrap- thread_wrapper(tid=3): done
--5591:1:syswrap- run_a_thread_NORETURN(tid=3): post-thread_wrapper
--5591:1:syswrap- run_a_thread_NORETURN(tid=3): not last one standing
--5591:1:syswrap- thread_wrapper(tid=5): done
--5591:1:syswrap- run_a_thread_NORETURN(tid=5): post-thread_wrapper
--5591:1:syswrap- run_a_thread_NORETURN(tid=5): not last one standing
也会出错(截断):
valgrind ./Application
编辑:我试过通过gdb运行它,非常高兴。通过helgrind或drd运行它会在SDL_Init调用中产生段错误:11。
Conditional jump or move depends on uninitialised value(s)
at 0x7FFF5FC24A87: bcmp (in /usr/lib/dyld)....
Use of uninitialised value of size 8
at 0x7FFF5FC24A9F: bcmp (in /usr/lib/dyld)....
Use of uninitialised value of size 8
at 0x7FFF5FC24A9F: bcmp (in /usr/lib/dyld)....
Use of uninitialised value of size 8
at 0x7FFF5FC24A9F: bcmp (in /usr/lib/dyld)....
鉴于gdb是干净的,我认为通过valgrind运行SDL应用程序会导致这个问题,但我不知道它可能是什么,或者如何解决这个问题,我找不到任何关于它是我进一步调查的。
来自helgrind的完整堆栈跟踪:
Helgrind: hg_main.c:4470 (void instrument_mem_access(IRSB *, IRExpr *, Int, Bool, Int, Int, IRExpr *)): Assertion 'szB > 8 && szB <= 512' failed.
这是在最新的El Capitan Macbook,Valgrind-3.12.0.SVN和LibVEX以及SDL2-2.0.4上编译的。
我尝试将最新来源(最初是通过brew获得)编译成SDL2和Valgrind,但这没有任何影响。
有人知道为什么Valgrind会导致SDL_Init出现段错误,以及是否有办法解决这个问题?
由于