Details
-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b32
-
x86
-
linux
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8019028 | 7u45 | Sean Chou | P4 | Closed | Fixed | b01 |
JDK-8002053 | 7u40 | Sean Chou | P4 | Closed | Fixed | b02 |
JDK-8015386 | 6u71 | Vladislav Karnaukhov | P2 | Closed | Fixed | b01 |
Description
FULL PRODUCT VERSION :
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux zhouyx-workstation 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:50:54 UTC 2012 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
In X11SurfaceData.c, when memory allocation failed, the error handling code does not free the memory already allocated.
eg.
In following piece of code, if "shminfo->shmid = shmget(IPC_PRIVATE, height * img->bytes_per_line, PC_CREAT|0777); " failed, both "img" and "shminfo" are not freed.
////////////////////////////////////////////////////////////
shminfo = malloc(sizeof(XShmSegmentInfo));
if (shminfo == NULL) {
return NULL;
}
memset(shminfo, 0, sizeof(XShmSegmentInfo));
img = XShmCreateImage(awt_display, xsdo->configData->awt_visInfo.visual,
xsdo->depth, ZPixmap, NULL, shminfo,
width, height);
if (img == NULL) {
free((void *)shminfo);
return NULL;
}
shminfo->shmid =
shmget(IPC_PRIVATE, height * img->bytes_per_line, IPC_CREAT|0777);
if (shminfo->shmid < 0) {
J2dRlsTraceLn1(J2D_TRACE_ERROR,
"X11SD_SetupSharedSegment shmget has failed: %s",
strerror(errno));
return NULL;
}
////////////////////////////////////////////
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
It is not easy to reproduce, we observed the memory leak only on one machine because it exists in error handling code and app rarely goes there.
However, this bug is obvious when looking at the code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All allocated memory should be freed in error handling code.
ACTUAL -
Some allocated memory are not freed.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux zhouyx-workstation 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:50:54 UTC 2012 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
In X11SurfaceData.c, when memory allocation failed, the error handling code does not free the memory already allocated.
eg.
In following piece of code, if "shminfo->shmid = shmget(IPC_PRIVATE, height * img->bytes_per_line, PC_CREAT|0777); " failed, both "img" and "shminfo" are not freed.
////////////////////////////////////////////////////////////
shminfo = malloc(sizeof(XShmSegmentInfo));
if (shminfo == NULL) {
return NULL;
}
memset(shminfo, 0, sizeof(XShmSegmentInfo));
img = XShmCreateImage(awt_display, xsdo->configData->awt_visInfo.visual,
xsdo->depth, ZPixmap, NULL, shminfo,
width, height);
if (img == NULL) {
free((void *)shminfo);
return NULL;
}
shminfo->shmid =
shmget(IPC_PRIVATE, height * img->bytes_per_line, IPC_CREAT|0777);
if (shminfo->shmid < 0) {
J2dRlsTraceLn1(J2D_TRACE_ERROR,
"X11SD_SetupSharedSegment shmget has failed: %s",
strerror(errno));
return NULL;
}
////////////////////////////////////////////
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
It is not easy to reproduce, we observed the memory leak only on one machine because it exists in error handling code and app rarely goes there.
However, this bug is obvious when looking at the code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All allocated memory should be freed in error handling code.
ACTUAL -
Some allocated memory are not freed.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
Attachments
Issue Links
- backported by
-
JDK-8015386 Potential memory leak in error handling code in X11SurfaceData.c
-
- Closed
-
-
JDK-8002053 Potential memory leak in error handling code in X11SurfaceData.c
-
- Closed
-
-
JDK-8019028 Potential memory leak in error handling code in X11SurfaceData.c
-
- Closed
-