On Sat, Sep 04 2004, Mike McCormack wrote:
Valgrind stopped working with Wine a while back due to the way Wine reserves memory above address 0x80000000.
The following patch allows valgrind to work with wine again. You need to start wine-pthread or wine-kthread instead of starting the wine binary depending on whether your system uses NPTL or not. eg. my system uses kthreads so:
valgrind wine-kthread notepad.exe
I am very glad to hear this, Mike. Thanks.
I'm not sure if Alexandre wants to commit this or not, but it should be of use to those that want to use valgrind again.
Hm, still, for me valgrind doesn't work:
[s2@katleriai wine]$ valgrind --tool=memcheck wine-pthread notepad.exe Executable range 0x77f00000-0x77f02370 is outside the acceptable range (nil)-0x52c00000 valgrind: do_exec(/usr/local/bin/wine-pthread) failed: Cannot allocate memory [s2@katleriai wine]$
Ideas?
Saulius Krasuckas wrote:
Hm, still, for me valgrind doesn't work:
[s2@katleriai wine]$ valgrind --tool=memcheck wine-pthread notepad.exe Executable range 0x77f00000-0x77f02370 is outside the acceptable range (nil)-0x52c00000 valgrind: do_exec(/usr/local/bin/wine-pthread) failed: Cannot allocate memory [s2@katleriai wine]$
Ideas?
Which version of valgrind... some of them work and some don't. I think I'm still using one built with Adam Gundy's patches.
bash-2.05b$ valgrind --version valgrind-20031012
I'm also using wine-kthread, but that shouldn't make a difference.
Mike
On Sun, 5 Sep 2004, Mike McCormack wrote:
Saulius Krasuckas wrote:
Hm, still, for me valgrind doesn't work:
[s2@katleriai wine]$ valgrind --tool=memcheck wine-pthread notepad.exe Executable range 0x77f00000-0x77f02370 is outside the acceptable range (nil)-0x52c00000 valgrind: do_exec(/usr/local/bin/wine-pthread) failed: Cannot allocate memory [s2@katleriai wine]$
Which version of valgrind... some of them work and some don't. I think I'm still using one built with Adam Gundy's patches.
Nice idea. Yesterday I have compiled the latest one.
bash-2.05b$ valgrind --version valgrind-20031012
[s2@katleriai wine]$ valgrind --version valgrind-2.2.0
I'm also using wine-kthread, but that shouldn't make a difference.
Have installed the same version as yours.
[s2@katleriai wine]$ valgrind --version valgrind-20031012 [s2@katleriai wine]$ valgrind wine-pthread --version ==27403== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux. ==27403== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward. ==27403== Using valgrind-20031012, a program supervision framework for x86-linux. ==27403== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward. ==27403== Estimated CPU clock rate is 856 MHz ==27403== For more details, rerun with: -v ==27403== ==27403== Warning: set address range perms: large range 1073610752, a 1, v 1 Killed [s2@katleriai wine]$
Wow, it made some LAAAAAAG on my box.
I think i eats all of my RAM and then gets killed by the kernel. I guess valgrind wants ~1GB of RAM (or RAM+Swap) while I have only 256+300 MBs.
Bad luck.
Saulius Krasuckas wrote:
Wow, it made some LAAAAAAG on my box.
I think i eats all of my RAM and then gets killed by the kernel. I guess valgrind wants ~1GB of RAM (or RAM+Swap) while I have only 256+300 MBs.
That's exactly the problem I was trying to fix... it's eating 1Gb of RAM because Wine is trying to reserve 0x80000000-0xbfff0000 about 1G of memory. So it seems my patch isn't working :(
Maybe try adding a printf("reserving\n") after the if(reserve) in mmap_init() to see if it's still trying to reserve memory... it shouldn't.
Mike
On Sun, 5 Sep 2004, Mike McCormack wrote:
Saulius Krasuckas wrote:
I think i eats all of my RAM and then gets killed by the kernel. I guess valgrind wants ~1GB of RAM (or RAM+Swap) while I have only 256+300 MBs.
That's exactly the problem I was trying to fix... it's eating 1Gb of RAM because Wine is trying to reserve 0x80000000-0xbfff0000 about 1G of memory. So it seems my patch isn't working :(
Possibly, it works. That just I suck: the patch was not applied. :-/
Maybe try adding a printf("reserving\n") after the if(reserve) in mmap_init() to see if it's still trying to reserve memory... it shouldn't.
Instead I am having trouble compiling the libs/wine dir:
loader.c:524: conflicting types for `wine_init' ../../include/wine/library.h:56: previous declaration of `wine_init'
NP, that one required just a correction of function prototype in the header file. Wine is recompiling from ground now. Sorry for the buzz.
Saulius Krasuckas wrote:
Possibly, it works. That just I suck: the patch was not applied. :-/
Well, so long as it's working :)
Instead I am having trouble compiling the libs/wine dir:
loader.c:524: conflicting types for `wine_init' ../../include/wine/library.h:56: previous declaration of `wine_init'
NP, that one required just a correction of function prototype in the header file. Wine is recompiling from ground now. Sorry for the buzz.
OK, I missed that file. I'll resend the diff incase anybody else is interested.
There's probably a better way of doing it so that the wine_init prototype isn't changed, but for now at least people can use valgrind with the patch...
Mike
Index: loader/main.c =================================================================== RCS file: /cvstrees/crossover/office/wine/loader/main.c,v retrieving revision 1.1.1.11 diff -u -r1.1.1.11 main.c --- loader/main.c 16 Jun 2004 02:57:30 -0000 1.1.1.11 +++ loader/main.c 5 Sep 2004 12:56:37 -0000 @@ -32,16 +32,17 @@ int main( int argc, char *argv[] ) { char error[1024]; - int i; + int i, reserve = 0;
if (wine_main_preload_info) { for (i = 0; wine_main_preload_info[i].size; i++) wine_mmap_add_reserved_area( wine_main_preload_info[i].addr, wine_main_preload_info[i].size ); + reserve = 1; }
- wine_init( argc, argv, error, sizeof(error) ); + wine_init( argc, argv, error, sizeof(error), reserve ); fprintf( stderr, "wine: failed to initialize: %s\n", error ); exit(1); } Index: libs/wine/mmap.c =================================================================== RCS file: /cvstrees/crossover/office/wine/libs/wine/mmap.c,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 mmap.c --- libs/wine/mmap.c 31 Jul 2004 00:38:48 -0000 1.1.1.3 +++ libs/wine/mmap.c 5 Sep 2004 12:56:38 -0000 @@ -249,7 +249,7 @@ /*********************************************************************** * mmap_init */ -void mmap_init(void) +void mmap_init(int reserve) { struct reserved_area *area; struct list *ptr; @@ -258,6 +258,8 @@ char * const stack_ptr = &stack; char *user_space_limit = (char *)0x80000000;
+ if( reserve ) + { /* check for a reserved area starting at the user space limit */ /* to avoid wasting time trying to allocate it again */ LIST_FOR_EACH( ptr, &reserved_areas ) @@ -285,6 +287,7 @@ } else reserve_area( user_space_limit, 0 ); #endif /* __i386__ */ + }
/* reserve the DOS area if not already done */
Index: libs/wine/loader.c =================================================================== RCS file: /cvstrees/crossover/office/wine/libs/wine/loader.c,v retrieving revision 1.1.1.10 diff -u -r1.1.1.10 loader.c --- libs/wine/loader.c 16 Jun 2004 02:57:30 -0000 1.1.1.10 +++ libs/wine/loader.c 5 Sep 2004 12:56:39 -0000 @@ -78,7 +79,7 @@ static int nb_dll_paths; static int dll_path_maxlen;
-extern void mmap_init(void); +extern void mmap_init(int reserve);
/* build the dll load path from the WINEDLLPATH variable */ static void build_dll_path(void) @@ -511,7 +524,7 @@ * * Main Wine initialisation. */ -void wine_init( int argc, char *argv[], char *error, int error_size ) +void wine_init( int argc, char *argv[], char *error, int error_size, int reserve ) { char *wine_debug; int file_exists; @@ -523,7 +536,7 @@ __wine_main_argc = argc; __wine_main_argv = argv; __wine_main_environ = environ; - mmap_init(); + mmap_init( reserve );
if ((wine_debug = getenv("WINEDEBUG"))) { Index: include/wine/library.h =================================================================== RCS file: /cvstrees/crossover/office/wine/include/wine/library.h,v retrieving revision 1.1.1.17 diff -u -r1.1.1.17 library.h --- include/wine/library.h 16 Jun 2004 02:57:30 -0000 1.1.1.17 +++ include/wine/library.h 5 Sep 2004 12:56:39 -0000 @@ -53,7 +53,7 @@ extern char **__wine_main_argv; extern WCHAR **__wine_main_wargv; extern char **__wine_main_environ; -extern void wine_init( int argc, char *argv[], char *error, int error_size ); +extern void wine_init( int argc, char *argv[], char *error, int error_size, int reserve );
/* debugging */