Re: [JunkMail] Fix for Bug 686946, ps2epsi segfaults
"Igor V. Melichev" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
Jeong, The logic looks good, but please get approval from Ray. Igor. ----- Original Message ----- From: "Jeong Kim" <[email protected]> To: "Gs-Code-Review" <[email protected]> Sent: Sunday, August 10, 2003 6:04 PM Subject: [JunkMail] [gs-code-review] Fix for Bug 686946, ps2epsi segfaults > Reviewers, > > Running ps2epsi with any file causes a SEGV error. > When 'ps2epsi' procedure in ps2epsi.ps is executed > an image device is made and is set by 'setdevice' operator. > Then .setsafe is executed and thus setpagedevice is called. > The SEGV occurs when 'setpagedevice' which is followed by > 'setdevice' and 'fillpage' is called. > > Following is a simplified PostScript code for error reproduction. > > matrix 1056 816 null > makeimagedevice > setdevice > << >> setpagedevice > > When 'setdevice' is called, a device is opened and 'setpagedevice' > is called the opened device is closed. And any following attempts > to draw something (e.g. fillpage) in the device would fail and > makes a SEGV. > > Again, setpagedevice calls another setdevice and this calls > 'gs_setdevice_no_init' and 'gs_closedevice' consequently. > > In detail, 'gs_setdevice_no_init' calls 'gs_closedevice' to > close an open device when the following condition is satisfied. > > if (pgs->device != NULL && pgs->device->rc.ref_count == 1) { > > I think the reason why we close a device when gs_setdevice_no_init > is called, is to close the current device when a new device is set. > > So we must not close device when current device and new device > to set is same. > > Following is the modified code to prevent closing current device > which is same with new device. > > if (pgs->device != NULL && > pgs->device->rc.ref_count == 1 && > pgs->device != dev) { > > With this simple patch, SEGV disppeared and ps2epsi works good. > > Jeong > > Log: > gs_setdevice_no_init function sometimes closes a device > when the current device and a new device to set is same. > Now it doesn't. Bug 686946. > > Index: src/gsdevice.c > =================================================================== > RCS file: /cvs/ghostscript/gs/src/gsdevice.c,v > retrieving revision 1.19 > diff -C2 -r1.19 gsdevice.c > *** src/gsdevice.c 25 Feb 2003 12:25:18 -0000 1.19 > --- src/gsdevice.c 10 Aug 2003 13:58:45 -0000 > *************** > *** 402,406 **** > * device parameters. > */ > ! if (pgs->device != NULL && pgs->device->rc.ref_count == 1) { > int code = gs_closedevice(pgs->device); > > --- 402,408 ---- > * device parameters. > */ > ! if (pgs->device != NULL && > ! pgs->device->rc.ref_count == 1 && > ! pgs->device != dev) { > int code = gs_closedevice(pgs->device); > > _______________________________________________ > gs-code-review mailing list > [email protected] > http://www.ghostscript.com/mailman/listinfo/gs-code-review >