Summary: | malloc() instead of g_malloc() | ||
---|---|---|---|
Product: | pkg-config | Reporter: | Alexis Wilke <alexis> |
Component: | src | Assignee: | Tollef Fog Heen <tfheen> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | high | CC: | ohnobinki |
Version: | unspecified | ||
Hardware: | x86 (IA32) | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | g_malloc/free/realloc/strdup + alloca() definitions removal |
Description
Alexis Wilke
2006-11-23 16:47:51 UTC
Okay, I got many others! 8-} The poptParseArgvString() function called, for instance, from parse_libs() returns a new buffer in the variable 'argv' which you g_free() a little lower in that function. Argh! This is totally wrong because poptParseArgvString() does malloc() and free() only (it is not glib aware--should we change that? that's what I'm gonna do now!) So here again you were likely destroying memory big time. Patch later, as I mentioned sooner. Okay... two things: I was linking against my compiled version of glib and thus g_malloc() == malloc() and g_free() == free() by default! So no worry there I guess. I'll still send a patch with my changes. I looked all around and I could not really find a problem. Yet, the alloca() function did not need to be defined as you had it. It is available in glib so all you have to do is include glib.h and you have it. I suggest the addition of a file named pkg-glib.h and the removal of the partial-glib.h (the new name makes more sense). It functions the same way, but all the .c file include it (the popt*.c files too in order to ge the alloca() file). That is, if you accept my changes... 8-) So all of that to say that I'm not too sure what the problem was! Ha! One thing however, which I did not really fix correctly, is the default path in the main.c file. You define it on the command line with -D...="\"blah\"". That does not work under MinGW and propably other systems. I get many errors about extranous backslashes. That's why the pre-compiled version of pkg-config could never find my files even thought they were at the right place! You need to have a .h.in with the info (config.h.in would work, you just need to substitute that variable too.) Another way is to change the main.c into main.c.in but I think many people would not like that. I'll be glad to make that work for you, I just need to know how you want to proceed. Finally, there is another possibly "more serious" problem: the default path separator under MinGW, according to glib, is ';' and not ':'. I'm not too sure how to handle that one because MinGW without MSYS, that's correct! (;) but with MSYS, it's wrong. Since I do not myself need more than one path, I'm fine, but it could be a problem for some other people. Created attachment 7890 [details] [review] g_malloc/free/realloc/strdup + alloca() definitions removal WARNING: DO NOT INCLUDE main.c; I put it in there so you can see what I used to test the memory but the path for the default directories is hard-coded in there! Okay! I got the gtk+ configuration script to work. The problem must be the shell because they have something like this: VAR="`pkg-config --cflags ...` $var1 $var2 ..." and it breaks after the closing ` by adding a \x01 and ignoring the other variables. I moved the extras variables first (which is totally fine for MSYS) and the problem goes away! VAR="$var1 $var2 ... `pkg-config --cflags ...`" So really, the only problem I can see is the default path which does not work at this time. Sorry for all the trouble 8-} Alexis Since popt is removed, I'm pretty sure anything that allocates memory in pkg-config is going through the glib routines except for alloca in rpmvercmp. Since I know people have that working on MSYS (I've done it myself), I'm going to say that this is resolved. Please reopen if you're still finding memory corruption. And the bug with the \x01 was indeed a MSYS shell bug. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.