Summary: | Ghostscript uses globals where it should not. | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | Robin Watts <robin.watts> |
Component: | General | Assignee: | Robin Watts <robin.watts> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | sphinx.pinastri |
Priority: | P4 | ||
Version: | master | ||
Hardware: | All | ||
OS: | All | ||
Customer: | Word Size: | --- |
Description
Robin Watts
2012-10-10 19:22:02 UTC
gdevpdtt.o is actually OK. gsicc_lcms2 and gsicc_lcms are now fixed. I found the following global variables in all programs of 'ghostpdl'. clist_io_procs_memory_global clist_io_procs_file_global _cmsIntentsPluginChunk _cmsCurvesPluginChunk _cmsInterpPluginChunk _cmsOptimizationPluginChunk _cmsFormattersPluginChunk _cmsTagPluginChunk _cmsTagTypePluginChunk _cmsMPETypePluginChunk _cmsTransformPluginChunk _TIFFerrorHandlerExt _TIFFwarningHandlerExt _TIFFerrorHandler _TIFFwarningHandler hdr_id gs_debug gs_scan_comment_proc gs_scan_dsc_proc pjl_permanent_soft_fonts xps_doc_trace xps_zip_trace The symbol maps were generated with: XLDFLAGS=-Wl,-M make -e 2>&1 | tee build.log The log was parsed by the following Python script: acc = {} try: while True: s = input() ss = s.split() if s[1:5] == ".bss": bss = True elif s[1:5] != " ": bss = False else: if (bss): acc[ss[1]] = True except EOFError: pass for a in acc: print(a) The following commits remove all the globals except for the lcms ones and the tiff ones. commit e68c710d2df3f6e74c66a2c78f668502039a0ef3 (golden/master) Author: Robin Watts <Robin.Watts@artifex.com> Date: Fri Jan 21 13:14:33 2022 +0000 Bug 693376: Move pjl_permanent_soft_fonts to pjl state structure. Move a global to the pjl state. The global is initialised when the pjl state is allocated, so the lifespans match. commit 4abddf623a6f2cb6291b06235fb63b58262ea8ab Author: Robin Watts <Robin.Watts@artifex.com> Date: Fri Jan 21 12:17:25 2022 +0000 Bug 693376: Strip out hdr_id. This is part of some debugging code that hoped to give every memory allocation within gs (at least in single threaded mode) a unique id number. In consultation with Chris, we decided it's never really been used, so we're stripping it out. commit a017fee74598e9f9a67353086eeaf4fd7edf9e7b Author: Robin Watts <Robin.Watts@artifex.com> Date: Fri Jan 21 11:41:20 2022 +0000 Bug 693376: Eliminate postscript scanner handling globals. There are 2 global vars (gs_scan_comment_proc and gs_scan_dsc_proc) that can (I think) be used to intercept comment scanning in the PS interpreter. These are undocumented anywhere, and we never actually set these variables in our code. Just over 10 years ago, we renamed these with no complaints from anyone, which makes us believe that they are unused. We excise them completely here. commit 3ed3f5b01ebbe9106ff8c08d6acb29a789e63288 Author: Robin Watts <Robin.Watts@artifex.com> Date: Fri Jan 21 11:07:03 2022 +0000 Bug 693376: Remove 2 vestigial debugging variables. It seems xps_doc_trace and xps_zip_trace are never actually used other than to be set. commit 6f53ab7da8baf5322236fb2a84e34204cfcc48e2 Author: Robin Watts <Robin.Watts@artifex.com> Date: Fri Jan 21 10:49:43 2022 +0000 Bug 693376: Remove 2 more global variables from Ghostscript. These should not have been a problem, as they are 'monotonic' in any given build, but nonetheless, this is neater. Remove clist_io_procs_memory_global and clist_io_procs_file_global. These hold pointers to the io_procs structures for either memory or file writing as appropriate. Here we move them into gs_lib_ctx_core_t. I couldn't make the python script work, so I did: make LDFLAGS="-Xlinker -Map=output.map" and then manually looked at the produced output.map. I see the following symbols left: _cmsIntentsPluginChunk _cmsCurvesPluginChunk _cmsInterpPluginChunk _cmsOptimizationPluginChunk _cmsFormattersPluginChunk _cmsTagPluginChunk _cmsTagTypePluginChunk _cmsMPETypePluginChunk _cmsTransformPluginChunk _TIFFerrorHandlerExt _TIFFwarningHandlerExt _TIFFerrorHandler _TIFFwarningHandler gs_debug The _cms ones are unavoidable (without radical rewriting of lcms). I believe they are safe because they get set once at startup, and then don't change. The _TIFF ones are unavoidable (without forking libtiff). I hope they don't affect us. gs_debug is (as the name suggests) only used for debugging, so that's fine. I'm going to close this bug. |