[gs-code-review] The fix for 12-07c -- new errorinfo function.
Igor V. Melichev
igor.melichev at artifex.com
Tue Aug 15 12:25:41 PDT 2006
Alex,
PLRM3 page 115 reads :
"The default error-handling procedures all operate in a standard way. They
record information about the error in a special dictionary named $error, set
the VM allocation mode to local, and invoke the stop operator."
This gives you a sequence of the actions.
I'm not sure what Adobe strongly follows the sequence,
but we can do until we detect another inconformance.
(sorry I didn't check your code in details).
Igor.
----- Original Message -----
From: "Alex Cherepanov" <alexcher at quadnet.net>
To: "gs-code-review" <gs-code-review at ghostscript.com>
Cc: "L. Peter Deutsch" <ghost at aladdin.com>; "Ray Johnston" <ray at artifex.com>
Sent: Tuesday, August 15, 2006 5:39 AM
Subject: [gs-code-review] The fix for 12-07c -- new errorinfo function.
> Reviewers,
>
> Adobe interpreters often put a 2-element array in $error dictionary
> as the value of /errorinfo . The array represent an offending key-value
> pair in the dictionary argument.
>
> Many CET tests examine the value of /errorinfo and include it in the
> checksum. It looks like the proposed patch is the first to address this
> issue.
>
> Please help me with the memory allocators. I'm not sure that they are
> used correctly. Probably, the array should be local regardless of the
> current allocation mode.
>
> Regards,
> Alex Cherepanov
>
>
--------------------------------------------------------------------------------
> Index: gs/src/interp.c
> ===================================================================
> --- gs/src/interp.c (revision 6987)
> +++ gs/src/interp.c (working copy)
> @@ -725,6 +725,33 @@
> return 0;
> }
>
> +/* Create and store [/key any] array in $error.errorinfo. */
> +/* The key must be a permanently allocated C string. */
> +/* This routine is here because of the proximity to the error handler. */
> +int
> +gs_errorinfo_put_pair(i_ctx_t *i_ctx_p, const byte *key, int len, const
> ref *any)
> +{
> + int code;
> + ref pair, *aptr, key_name, *pderror;
> +
> + code = name_ref(imemory, key, len, &key_name, 0);
> + if (code < 0)
> + return code;
> + code = ialloc_ref_array(&pair, a_readonly, 2,
> "gs_errorinfo_put_pair");
> + if (code < 0)
> + return code;
> + aptr = pair.value.refs;
> + ref_assign_new(aptr, &key_name);
> + ref_assign_new(aptr+1, any);
> + if (dict_find_string(systemdict, "$error", &pderror) <= 0 ||
> + !r_has_type(pderror, t_dictionary) ||
> + idict_put_string(pderror, "errorinfo", &pair) < 0
> + )
> + return_error(e_Fatal);
> + return 0;
> +}
> +
> +
> /* Main interpreter. */
> /* If execution terminates normally, return e_InterpreterExit. */
> /* If an error occurs, leave the current object in *perror_object */
> Index: gs/src/interp.h
> ===================================================================
> --- gs/src/interp.h (revision 6987)
> +++ gs/src/interp.h (working copy)
> @@ -61,6 +61,10 @@
> /* Put a string in $error /errorinfo. */
> int gs_errorinfo_put_string(i_ctx_t *, const char *);
>
> +/* Create and store [/key any] array in $error /errorinfo. */
> +/* The key must be a permanently allocated C string. */
> +int gs_errorinfo_put_pair(i_ctx_t *, const byte *key, int len, const ref
> *any);
> +
> /* Initialize the interpreter. */
> int gs_interp_init(i_ctx_t **pi_ctx_p, const ref *psystem_dict,
> gs_dual_memory_t *dmem);
> Index: gs/src/zimage.c
> ===================================================================
> --- gs/src/zimage.c (revision 6988)
> +++ gs/src/zimage.c (working copy)
> @@ -27,6 +27,7 @@
> #include "gxiparam.h"
> #include "idict.h"
> #include "idparam.h"
> +#include "interp.h" /* for gs_errorinfo_put_pair() */
> #include "estack.h" /* for image[mask] */
> #include "ialloc.h"
> #include "igstate.h"
> @@ -297,8 +298,10 @@
> break;
> default:
> if (!r_is_proc(sources)) {
> - if (pie != NULL)
> - gx_image_end(pie, false); /* Clean up pie */
> + static const byte ds[] = "DataSource";
> + if (pie != NULL)
> + gx_image_end(pie, false); /* Clean up pie */
> + gs_errorinfo_put_pair(i_ctx_p, ds, sizeof(ds) - 1,
> pp);
> return_error(e_typecheck);
> }
> check_proc(*pp);
> Index: gs/src/int.mak
> ===================================================================
> --- gs/src/int.mak (revision 6987)
> +++ gs/src/int.mak (working copy)
> @@ -478,7 +478,7 @@
>
> $(PSOBJ)zimage.$(OBJ) : $(PSSRC)zimage.c $(OP) $(memory__h)\
> $(gscspace_h) $(gscssub_h) $(gsimage_h) $(gsmatrix_h) $(gsstruct_h)\
> - $(gxiparam_h)\
> + $(gxiparam_h) $(interp_h)\
> $(estack_h) $(ialloc_h) $(ifilter_h) $(igstate_h) $(iimage_h)
> $(ilevel_h)\
> $(store_h) $(stream_h)
> $(PSCC) $(PSO_)zimage.$(OBJ) $(C_) $(PSSRC)zimage.c
>
--------------------------------------------------------------------------------
> _______________________________________________
> gs-code-review mailing list
> gs-code-review at ghostscript.com
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
>
More information about the gs-code-review
mailing list