functions bodies ending in infinite loops execute false branches
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
High
|
Unassigned |
Bug Description
I'm doing a CLI app that starts some threads and then does (loop) to force the executable stay alive and not (quit). However, having:
- function body ending in (loop) or equivalent infinite loop (I've tried (loop while t) and (loop for i = 0 until (plusp i)), for instance),
- (if arg ...) or (when arg ...) checks in the body,
- and some non-obviously-nil arg
makes the if/when before the (loop) to execute unconditionally, even if the condition is false.
The code snippet that shows the behavior reliably:
(progn
(defvar *whatever-var* nil)
(defun whatever ()
(let ((arg (parse-integer
""
(when arg
(setf *whatever-var* "woo")))
(loop))
(sb-thread:
(sleep 1)
*whatever-var*)
2. SBCL version:
$ sbcl --version
SBCL 2.2.6
3. uname output
$ uname -a
Linux paranoidal 5.18.10 #1 SMP PREEMPT_DYNAMIC 1 x86_64 GNU/Linux
4. Features
CL-USER> *features*
(:SLYNK CFFI-FEATURES:
:CFFI CFFI-SYS:
:ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-UNIX :NON-BASE-
:ASDF-UNICODE :X86-64 :GENCGC :64-BIT :ANSI-CL :COMMON-LISP :ELF
:IEEE-
:SB-CORE-
:UNIX)
Changed in sbcl: | |
status: | Confirmed → Fix Committed |
assignee: | Stas Boukarev (stassats) → nobody |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
I hope you don't actually have a (loop) in your code. That just wastes enormous amounts of CPU time.