From spinuvit at gmail.com  Wed Mar 21 10:07:43 2012
From: spinuvit at gmail.com (Vitalie Spinu)
Date: Wed, 21 Mar 2012 10:07:43 +0100
Subject: [Rd] enableJIT() and internal R completions (was: [ESS-bugs]
	ess-mode 12.03; ess hangs emacs)
In-Reply-To: <87limvnqrw.fsf@gnu.org> (Sam Steingold's message of "Tue, 20 Mar
	2012 13:09:07 -0400")
References: <87limvnqrw.fsf@gnu.org>
Message-ID: <87r4wml3ts.fsf@gmail.com>


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/"
  >  )



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