|
From: <sv...@va...> - 2005-09-29 21:20:46
|
Author: sewardj
Date: 2005-09-29 22:20:41 +0100 (Thu, 29 Sep 2005)
New Revision: 4820
Log:
Fix a very stupid bug in the new aspacemgr, in which mmap "hint-style"
requests were being granted at the requested address when they should
not have been. This was causing ppc32-linux to crash at startup
(since the wrongly-granted mapping annihilated 5 others). This shows
the value of a multiplatform approach -- the bug applies to all
targets, yet x86 and amd64 appeared to work perfectly.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr.c
Modified: trunk/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-09-29 11:09:56 UTC (rev =
4819)
+++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-09-29 21:20:41 UTC (rev =
4820)
@@ -1586,9 +1586,14 @@
other words we are prepared to let the client trash its own
mappings if it wants to.
=20
- Similarly, a hinted client map will be granted at the
- requested address providing the same conditions hold.
+ The Default Policy is overriden by Policy Exception #2:
=20
+ If the request is for a hinted client map, we are prepared to
+ grant it providing all areas inside the request are either
+ free or reservations. In other words we are prepared to let=20
+ the client have a hinted mapping anywhere it likes provided
+ it does not trash either any of its own mappings or any of=20
+ valgrind's mappings.
*/
Int i, j;
Addr holeStart, holeEnd, holeLen;
@@ -1628,7 +1633,7 @@
=20
/* ------ Implement Policy Exception #1 ------ */
=20
- if (forClient && (req->rkind =3D=3D MFixed || req->rkind =3D=3D MHint=
)) {
+ if (forClient && req->rkind =3D=3D MFixed) {
Int iLo =3D find_nsegment_idx(reqStart);
Int iHi =3D find_nsegment_idx(reqEnd);
Bool allow =3D True;
@@ -1648,12 +1653,32 @@
*ok =3D True;
return reqStart;
}
- /* Not acceptable. Fixed fails, Hint is now attempted by the
- default policy. */
- if (req->rkind =3D=3D MFixed) {
- *ok =3D False;
- return 0;
+ /* Not acceptable. Fail. */
+ *ok =3D False;
+ return 0;
+ }
+
+ /* ------ Implement Policy Exception #2 ------ */
+
+ if (forClient && req->rkind =3D=3D MHint) {
+ Int iLo =3D find_nsegment_idx(reqStart);
+ Int iHi =3D find_nsegment_idx(reqEnd);
+ Bool allow =3D True;
+ for (i =3D iLo; i <=3D iHi; i++) {
+ if (nsegments[i].kind =3D=3D SkFree
+ || nsegments[i].kind =3D=3D SkResvn) {
+ /* ok */
+ } else {
+ allow =3D False;
+ break;
+ }
}
+ if (allow) {
+ /* Acceptable. Granted. */
+ *ok =3D True;
+ return reqStart;
+ }
+ /* Not acceptable. Fall through to the default policy. */
}
=20
/* ------ Implement the Default Policy ------ */
|