* [PATCH] bug in org-babel-execute-src-block
@ 2013-04-18 8:16 Aaron Ecay
2013-04-18 8:49 ` Bastien
0 siblings, 1 reply; 2+ messages in thread
From: Aaron Ecay @ 2013-04-18 8:16 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 230 bytes --]
Hello,
I’ve discovered a bug in org-babel-execute-src-block. Calls to setf can
leak outside of the function and affect the library of babel. The
attached org file illustrates the problem. The attached patch fixes it.
[-- Attachment #2: lob-bug.org --]
[-- Type: text/plain, Size: 676 bytes --]
* Bug
Step 1: place the foo code block below into a different file and ingest that
file into the library of babel. (It must be in a separate file for the
bug to manifest.)
#+name: foo
#+BEGIN_SRC emacs-lisp
2
#+END_SRC
Step 2: evaluate this code block. The result should be =(:results . replace)=
#+BEGIN_SRC emacs-lisp :results append
(assq :results (nth 2 (cdr (assq 'foo org-babel-library-of-babel))))
#+END_SRC
#+RESULTS:
: (:results . replace)
: (:results . silent)
Step 3: evaluate this source block:
#+BEGIN_SRC emacs-lisp :var bar=foo
bar
#+END_SRC
#+RESULTS:
: 2
Step 4: re-evaluate the block from step 2. The result should be =(:results . silent)=
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0004-Fix-bug-in-org-babel-execute-src-block.patch --]
[-- Type: text/x-patch, Size: 1090 bytes --]
From 84531966dc5ca50fb56c61726694e988da3053eb Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Thu, 18 Apr 2013 04:02:47 -0400
Subject: [PATCH 4/4] Fix bug in org-babel-execute-src-block
* lisp/ob-core.el (org-babel-execute-src-block): copy the info
Otherwise, the setf calls in this function can reach into and change
other configuration variables, such as the library of babel.
---
lisp/ob-core.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 12fcecc..71e9d61 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -547,7 +547,9 @@ Optionally supply a value for PARAMS which will be merged with
the header arguments specified at the front of the source code
block."
(interactive)
- (let* ((info (or info (org-babel-get-src-block-info)))
+ (let* ((info (if info
+ (copy-tree info)
+ (org-babel-get-src-block-info)))
(merged-params (org-babel-merge-params (nth 2 info) params)))
(when (org-babel-check-evaluate
(let ((i info)) (setf (nth 2 i) merged-params) i))
--
1.8.2.1
[-- Attachment #4: Type: text/plain, Size: 16 bytes --]
--
Aaron Ecay
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bug in org-babel-execute-src-block
2013-04-18 8:16 [PATCH] bug in org-babel-execute-src-block Aaron Ecay
@ 2013-04-18 8:49 ` Bastien
0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2013-04-18 8:49 UTC (permalink / raw)
To: Aaron Ecay; +Cc: emacs-orgmode
Hi Aaron,
Aaron Ecay <aaronecay@gmail.com> writes:
> From 84531966dc5ca50fb56c61726694e988da3053eb Mon Sep 17 00:00:00 2001
> From: Aaron Ecay <aaronecay@gmail.com>
> Date: Thu, 18 Apr 2013 04:02:47 -0400
> Subject: [PATCH 4/4] Fix bug in org-babel-execute-src-block
Applied, thanks.
--
Bastien
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-18 8:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-18 8:16 [PATCH] bug in org-babel-execute-src-block Aaron Ecay
2013-04-18 8:49 ` Bastien
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).