+ if (lheader->type == lrecord_type_free)
+ {
+ printing_major_badness (printcharfun, "freed lrecord", 0,
+ lheader, BADNESS_NO_TYPE);
+ break;
+ }
+ else if (lheader->type == lrecord_type_undefined)
+ {
+ printing_major_badness (printcharfun, "lrecord_type_undefined", 0,
+ lheader, BADNESS_NO_TYPE);
+ break;
+ }
+ else if (lheader->type >= lrecord_type_count)
+ {
+ printing_major_badness (printcharfun, "illegal lrecord type",
+ (int) (lheader->type),
+ lheader, BADNESS_POINTER_OBJECT);
+ break;
+ }
+
+ /* Further checks for bad memory in critical situations. We don't
+ normally do these because they may be expensive or weird
+ (e.g. under Unix we typically have to set a SIGSEGV handler and
+ try to trigger a seg fault). */
+
+ if (inhibit_non_essential_printing_operations)
+ {
+ const struct lrecord_implementation *imp =
+ LHEADER_IMPLEMENTATION (lheader);
+
+ if (!debug_can_access_memory
+ (lheader, imp->size_in_bytes_method ?
+ imp->size_in_bytes_method (lheader) :
+ imp->static_size))
+ {
+ write_fmt_string (printcharfun,
+ "#<EMACS BUG: type %s BAD MEMORY ACCESS %p>",
+ LHEADER_IMPLEMENTATION (lheader)->name,
+ lheader);
+ break;
+ }
+
+ if (STRINGP (obj))
+ {
+ Lisp_String *l = (Lisp_String *) lheader;
+ if (!debug_can_access_memory (l->data, l->size))
+ {
+ write_fmt_string
+ (printcharfun,
+ "#<EMACS BUG: %p (CAN'T ACCESS STRING DATA %p)>",
+ lheader, l->data);
+ break;
+ }
+ }
+ }
+