Re: [Rd] enableJIT() and internal R completions (was: [ESS-bugs] ess-mode 12.03; ess hangs emacs)

From: <luke-tierney_at_uiowa.edu>
Date: Wed, 21 Mar 2012 14:48:52 -0500

The compiler/JIT is behaving as expected. The idea of compiling on duplicate, which level 2 enables, is to address some idioms where functions are modified at runtime. Ideally it would be good to avoid these idioms, and we may eventually get there, but for now they are an issue.

In this particular case getAnywhere contains

         if (is.function(x))
             environment(x) <- baseenv()
         x

and the new function is duplicated and compiled in an lapply() call, but the function doesn't make much sense with the baseenv() environment, hence all the warnings. This seems to be done so that identical() can be used to compare functions and consider functions that only differ in the environment to be edentical. It would probably be better to do this in another more explicit way -- I'll look into it.

(This does not occur in 2.4.1 because of a lack of duplicating bug in lapply that has since been fixed.)

luke

On Wed, 21 Mar 2012, Vitalie Spinu wrote:

>
> Hello,
>
> JIT compiler interferes with internal R completions:
>
> compiler::enableJIT(2)
> utils:::functionArgs("density", '')
>
> gives:
>
> utils:::functionArgs("density", '')
> Note: no visible global function definition for 'bw.nrd0'
> Note: no visible global function definition for 'bw.nrd'
> Note: no visible global function definition for 'bw.ucv'
> Note: no visible global function definition for 'bw.bcv'
> Note: no visible global function definition for 'bw.SJ'
> Note: no visible global function definition for 'bw.SJ'
> Note: no visible binding for global variable 'C_massdist'
> Note: no visible global function definition for 'dnorm'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'approx'
> Note: no visible global function definition for 'bw.nrd0'
> Note: no visible global function definition for 'bw.nrd'
> Note: no visible global function definition for 'bw.ucv'
> Note: no visible global function definition for 'bw.bcv'
> Note: no visible global function definition for 'bw.SJ'
> Note: no visible global function definition for 'bw.SJ'
> Note: no visible binding for global variable 'C_massdist'
> Note: no visible global function definition for 'dnorm'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'approx'
> Note: no visible global function definition for 'bw.nrd0'
> Note: no visible global function definition for 'bw.nrd'
> Note: no visible global function definition for 'bw.ucv'
> Note: no visible global function definition for 'bw.bcv'
> Note: no visible global function definition for 'bw.SJ'
> Note: no visible global function definition for 'bw.SJ'
> Note: no visible binding for global variable 'C_massdist'
> Note: no visible global function definition for 'dnorm'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'fft'
> Note: no visible global function definition for 'approx'
> [1] "x=" "...=" "bw=" "adjust=" "kernel=" "weights="
> [7] "window=" "width=" "give.Rkern=" "n=" "from=" "to="
> [13] "cut=" "na.rm="
>
>
> Disabling JIT warnings removes the notes, but the call remains to be
> extremely slow, as the compiler still processes all the exceptions.
>
> Thanks,
> Vitalie.
>
>>>>> Sam Steingold <sds_at_gnu.org>
>>>>> on Tue, 20 Mar 2012 13:09:07 -0400 wrote:
>
> > ess hangs emacs completely.
>
> > I just created a brand new Rprofile
>
> > options(error = utils::recover)
> > library(compiler)
> > compiler::enableJIT(3)
>
>
> > and now and I start R and start typing I see this:
> >> options(STERM=.....)
> >> matrix(nrow=|)
> > ("|" stands for my cursor)
> > and "nrow: x" in the minibuffer.
> > that's it.
> > emacs is stuck.
>
> > Program received signal SIGTSTP, Stopped (user).
> > 0x00000000005a115a in exec_byte_code (bytestr=8748337, vector=8748373, maxdepth=<optimized out>, args_template=11970946,
> > nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:487
> > 487 stack.pc = stack.byte_string_start = SDATA (bytestr);
> > (gdb) where
> > #0 0x00000000005a115a in exec_byte_code (bytestr=8748337, vector=8748373, maxdepth=<optimized out>, args_template=11970946,
> > nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:487
> > #1 0x0000000000569111 in funcall_lambda (fun=8748253, nargs=<optimized out>, arg_vector=0x7fffffffb0b8)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #2 0x000000000056948b in Ffuncall (nargs=3, args=0x7fffffffb0b0) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #3 0x00000000005a1d46 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:785
> > #4 0x0000000000569111 in funcall_lambda (fun=20119685, nargs=<optimized out>, arg_vector=0x7fffffffb278)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #5 0x000000000056948b in Ffuncall (nargs=4, args=0x7fffffffb270) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #6 0x00000000005a1d46 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:785
> > #7 0x0000000000569111 in funcall_lambda (fun=20126229, nargs=<optimized out>, arg_vector=0x7fffffffb448)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #8 0x000000000056948b in Ffuncall (nargs=6, args=0x7fffffffb440) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #9 0x00000000005a1d46 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:785
> > #10 0x0000000000569111 in funcall_lambda (fun=19976549, nargs=<optimized out>, arg_vector=0x7fffffffb618)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #11 0x000000000056948b in Ffuncall (nargs=4, args=0x7fffffffb610) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #12 0x00000000005a1d46 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:785
> > #13 0x0000000000569111 in funcall_lambda (fun=20815797, nargs=<optimized out>, arg_vector=0x7fffffffb7e8)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #14 0x000000000056948b in Ffuncall (nargs=2, args=0x7fffffffb7e0) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #15 0x00000000005a1d46 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:785
> > #16 0x0000000000569111 in funcall_lambda (fun=20802901, nargs=<optimized out>, arg_vector=0x7fffffffb9b0)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #17 0x000000000056948b in Ffuncall (nargs=1, args=0x7fffffffb9a8) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #18 0x00000000005a1d46 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:785
> > #19 0x0000000000568aa3 in eval_sub (form=<optimized out>) at /home/sds/src/emacs/trunk/src/eval.c:2356
> > #20 0x000000000056bd44 in internal_lisp_condition_case (var=12376962, bodyform=18220518, handlers=18218726)
> > at /home/sds/src/emacs/trunk/src/eval.c:1469
> > #21 0x00000000005a2699 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:981
> > #22 0x0000000000569111 in funcall_lambda (fun=19912645, nargs=<optimized out>, arg_vector=0x7fffffffbfa0)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #23 0x000000000056948b in Ffuncall (nargs=1, args=0x7fffffffbf98) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #24 0x000000000056a55b in Fapply (nargs=2, args=0x7fffffffbf98) at /home/sds/src/emacs/trunk/src/eval.c:2450
> > #25 0x00000000005696cc in Ffuncall (nargs=3, args=0x7fffffffbf90) at /home/sds/src/emacs/trunk/src/eval.c:2984
> > #26 0x00000000005a1d46 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:785
> > #27 0x0000000000568aa3 in eval_sub (form=<optimized out>) at /home/sds/src/emacs/trunk/src/eval.c:2356
> > #28 0x000000000056bd44 in internal_lisp_condition_case (var=11970946, bodyform=9986302, handlers=8751622)
> > at /home/sds/src/emacs/trunk/src/eval.c:1469
> > #29 0x00000000005a2699 in exec_byte_code (bytestr=<optimized out>, vector=<optimized out>, maxdepth=<optimized out>,
> > args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at /home/sds/src/emacs/trunk/src/bytecode.c:981
> > #30 0x0000000000569111 in funcall_lambda (fun=9985997, nargs=<optimized out>, arg_vector=0x7fffffffc488)
> > at /home/sds/src/emacs/trunk/src/eval.c:3233
> > #31 0x000000000056948b in Ffuncall (nargs=2, args=0x7fffffffc480) at /home/sds/src/emacs/trunk/src/eval.c:3063
> > #32 0x00000000005698fa in call1 (fn=<optimized out>, arg1=<optimized out>) at /home/sds/src/emacs/trunk/src/eval.c:2771
> > #33 0x00000000004f815e in timer_check_2 () at /home/sds/src/emacs/trunk/src/keyboard.c:4463
> > #34 timer_check () at /home/sds/src/emacs/trunk/src/keyboard.c:4509
> > #35 0x00000000004f8489 in readable_events (flags=<optimized out>) at /home/sds/src/emacs/trunk/src/keyboard.c:3390
> > #36 0x00000000004fa9e5 in get_input_pending (flags=1, addr=0xb5a970) at /home/sds/src/emacs/trunk/src/keyboard.c:6739
> > #37 0x00000000004fd06a in detect_input_pending_run_timers (do_display=1) at /home/sds/src/emacs/trunk/src/keyboard.c:10506
> > #38 0x00000000005a82e0 in wait_reading_process_output (time_limit=30, microsecs=0, read_kbd=<optimized out>, do_display=1,
> > wait_for_cell=11970946, wait_proc=<optimized out>, just_wait_proc=0) at /home/sds/src/emacs/trunk/src/process.c:4733
> > #39 0x000000000041add4 in sit_for (timeout=120, reading=1, do_display=1) at /home/sds/src/emacs/trunk/src/dispnew.c:6063
> > #40 0x00000000004ff345 in read_char (commandflag=1, nmaps=2, maps=0x7fffffffcd50, prev_event=11970946,
> > used_mouse_menu=0x7fffffffced0, end_time=0x0) at /home/sds/src/emacs/trunk/src/keyboard.c:2690
> > #41 0x00000000005000c7 in read_key_sequence (keybuf=0x7fffffffcf30, prompt=11970946, dont_downcase_last=0,
> > can_return_switch_frame=1, fix_current_buffer=1, bufsize=30) at /home/sds/src/emacs/trunk/src/keyboard.c:9326
> > #42 0x0000000000501da5 in command_loop_1 () at /home/sds/src/emacs/trunk/src/keyboard.c:1448
> > #43 0x00000000005677b6 in internal_condition_case (bfun=0x501bd0 <command_loop_1>, handlers=12023138, hfun=0x4f6980 <cmd_error>)
> > at /home/sds/src/emacs/trunk/src/eval.c:1515
> > #44 0x00000000004f4dee in command_loop_2 (ignore=<optimized out>) at /home/sds/src/emacs/trunk/src/keyboard.c:1159
> > #45 0x0000000000567698 in internal_catch (tag=2738188573441308546, func=0x4f4dd0 <command_loop_2>, arg=11970946)
> > at /home/sds/src/emacs/trunk/src/eval.c:1272
> > #46 0x00000000004f6457 in command_loop () at /home/sds/src/emacs/trunk/src/keyboard.c:1138
> > #47 recursive_edit_1 () at /home/sds/src/emacs/trunk/src/keyboard.c:758
> > #48 0x00000000004f678c in Frecursive_edit () at /home/sds/src/emacs/trunk/src/keyboard.c:822
> > #49 0x000000000040fbad in main (argc=1, argv=<optimized out>) at /home/sds/src/emacs/trunk/src/emacs.c:1715
>
> > Lisp Backtrace:
> > "process-get" (0xffffb0b8)
> > "ess-wait-for-process" (0xffffb278)
> > "ess-command" (0xffffb448)
> > "ess-get-words-from-vector" (0xffffb618)
> > "ess-function-arguments" (0xffffb7e8)
> > "ess-eldoc-function" (0xffffb9b0)
> > "byte-code" (0xffffba90)
> > "eldoc-print-current-symbol-info" (0xffffbfa0)
> > "apply" (0xffffbf98)
> > "byte-code" (0xffffc080)
> > "timer-event-handler" (0xffffc488)
> > (gdb)
>
> > killing R does not help - R is dead but Emacs is still stuck.
>
> > Emacs : GNU Emacs 24.0.94.2 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
> > of 2012-03-20 on t520sds
> > Package: ess-mode 12.03
>
> > current state:
> > ==============
> > (setq
> > ess-language "Initial"
> > ess-dialect nil
> > ess-ask-for-ess-directory t
> > ess-ask-about-transfile nil
> > ess-directory nil
> > ess-keep-dump-files "always"
> > ess-source-directory "/tmp/"
> > )
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney_at_uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 21 Mar 2012 - 21:00:30 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 21 Mar 2012 - 22:10:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive