Re: [XenAccess-devel] Segmentation fault when calling the same function twice
Status: Beta
Brought to you by:
bdpayne
From: Daniele S. <da...@ya...> - 2006-08-28 08:01:12
|
> > Have you been able to reproduce this problem without > the python > ctypes library? I've been trying these days to locate the problem: I don't know very well how to use ctypes. But I've been able to reproduce the same problem in C; the file is process-data.c: again, the "main" has been renamed to "process-data" and I've removed all the printf statements: -------------------------process-data.c------------------------- #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/mman.h> #include <stdio.h> #include "../xenaccess.h" #include "../xa_private.h" int process_data (int argc, char **argv) { xa_instance_t xai; xa_linux_taskaddr_t taskaddr; unsigned char *memory = NULL; uint32_t offset = 0; /* this is the domain ID that we are looking at */ uint32_t dom = atoi(argv[1]); /* This is the pid that we are looking at, passed as an argument on the command line. */ int pid = atoi(argv[2]); /* initialize the xen access library */ if (xa_init(dom, &xai) == XA_FAILURE){ perror("failed to init XenAccess library"); goto error_exit; } /* get the relavent addresses for this process */ if (xa_linux_get_taskaddr(&xai, pid, &taskaddr) == XA_FAILURE){ perror("failed to get task addresses"); goto error_exit; } /* grab the memory at the start of the code segment for this process and print it out */ memory = xa_access_user_virtual_address( &xai, taskaddr.start_code, &offset, pid); if (NULL == memory){ perror("failed to map memory"); goto error_exit; } error_exit: /* cleanup any memory associated with the XenAccess instance */ xa_destroy(&xai); /* sanity check to unmap shared pages */ if (memory) munmap(memory, XA_PAGE_SIZE); return 0; } int main (int argc, char **argv) { int i; for(i=0; i<100; i++) { printf("%d ", i); process_data(argc, argv); } return 0; } ------------------------------------------------------------------- [root@dhcp12 example]# xm list Name ID Mem(MiB) VCPUs State Time(s) Debian1 1 64 1 -b---- 12.7 Domain-0 0 419 1 r----- 74.4 [root@dhcp12 example]# ./run ./process-data 1 1 Entity: line 1: parser error : Start tag expected, '<' not found ^ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ERROR: could not parse xml data for domain id 1 *** glibc detected *** ./process-data: double free or corruption (!prev): 0x08ed3d30 *** ======= Backtrace: ========= /lib/libc.so.6[0xdd0d0a] /lib/libc.so.6(__libc_free+0x70)[0xdd3f48] ../libxenaccess.so(linux_get_kernel_name+0x127)[0xd6e287] ../libxenaccess.so(linux_predict_sysmap_name+0x1f)[0xd6e34f] ../libxenaccess.so(linux_system_map_symbol_to_address+0x28)[0xd6d7b8] ../libxenaccess.so(linux_access_kernel_symbol+0x75)[0xd6dfd5] ../libxenaccess.so(xa_access_kernel_symbol+0x34)[0xd6ca14] ../libxenaccess.so(helper_init+0xfb)[0xd6c88b] ../libxenaccess.so(xa_init+0x42)[0xd6c922] ./process-data[0x80486a2] ./process-data[0x804878f] /lib/libc.so.6(__libc_start_main+0xc6)[0xd8670e] ./process-data[0x80485a1] ..... The problem is that sometime everything just works fine! I hope that can help you! Thanks!!! Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com |