Tracing machinery sensitive to dynamic environment after end of traced call

Bug #1798991 reported by Richard M Kreuter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

SB-DEBUG::TRACE-END-BREAKPOINT-FUN doesn't establish a controlled dynamic environment, and so printing traced functions' return values can cause errors that don't occur for printing the same functions' arguments. Patch attached, based on the union of the shenanigans that the rest of TRACE, the debugger, and the inspector do.

Example of problem (note that this problem only affects printing the result of the form's evaluation, since TRACE-START-BREAKPOINT-FUN already handles *PRINT-READABLY* itself).

----
* (defun foo () *package*)
FOO
* (trace foo)
(FOO)
* (foo)
  0: (FOO)
  0: FOO returned #<PACKAGE "COMMON-LISP-USER">
#<PACKAGE "COMMON-LISP-USER">
* (let ((*print-readably* t)) (foo))
  0: (FOO)

debugger invoked on a PRINT-NOT-READABLE in thread
#<THREAD "main thread" RUNNING {10005205B3}>:
  #<error printing object> cannot be printed readably.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [PRINT-UNREADABLY] Print unreadably.
  1: [USE-VALUE ] Supply an object to be printed instead.
  2: [ABORT ] Exit debugger, returning to top level.

(SB-INT:PRINT-NOT-READABLE-ERROR #<error printing object> #<SB-PRETTY:PRETTY-STREAM {100186D653}>)
0] 0
  0: FOO returned #<error printing object>
#<PACKAGE "COMMON-LISP-USER">
----

Other bug reporting requirements:

$ uname -a
Darwin m5.localdomain 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
$ ./run-sbcl.sh --no-userinit --no-sysinit
This is SBCL 1.4.12.114-d27fc52fa, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* *features*
(:X86-64 :64-BIT :64-BIT-REGISTERS :ALIEN-CALLBACKS :ANSI-CL :BSD
 :C-STACK-IS-CONTROL-STACK :CALL-SYMBOL :COMMON-LISP :COMPACT-INSTANCE-HEADER
 :COMPARE-AND-SWAP-VOPS :CYCLE-COUNTER :DARWIN :FLOAT-EQL-VOPS
 :FP-AND-PC-STANDARD-SAVE :GENCGC :IEEE-FLOATING-POINT :IMMOBILE-CODE
 :IMMOBILE-SPACE :INODE64 :INTEGER-EQL-VOP :LINKAGE-TABLE :LITTLE-ENDIAN
 :MACH-EXCEPTION-HANDLER :MACH-O :OS-PROVIDES-BLKSIZE-T :OS-PROVIDES-DLADDR
 :OS-PROVIDES-DLOPEN :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T
 :PACKAGE-LOCAL-NICKNAMES :RELOCATABLE-HEAP :SB-DOC :SB-EVAL :SB-LDB
 :SB-PACKAGE-LOCKS :SB-SIMD-PACK :SB-SOURCE-LOCATIONS :SB-THREAD :SB-UNICODE
 :SBCL :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-FIXED-OBJECTS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS
 :STACK-GROWS-DOWNWARD-NOT-UPWARD :UD2-BREAKPOINTS :UNDEFINED-FUN-RESTARTS
 :UNIX :UNWIND-TO-FRAME-AND-CALL-VOP)

Revision history for this message
Richard M Kreuter (kreuter) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.