Bug 15325 - segfault when using browser() in Rprofile.site
segfault when using browser() in Rprofile.site
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Startup
R 3.0.0
All Linux
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-29 01:13 UTC by Benjamin Tyner
Modified: 2013-07-15 16:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Tyner 2013-05-29 01:13:32 UTC
It seems that if I put a browser() in Rprofile.site, a
segfault occurs. This happens on several machines, several versions of R.

Here it the valgrind output when using revision 62797:

==31314== Memcheck, a memory error detector
==31314== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==31314== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==31314== Command: /home/btyner/R62797/lib/R/bin/exec/R
==31314==

R version 3.0.1 Patched (2013-05-24 r62797) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

<snip>

Called from: top level
Browse[1]> ls()
==31314== Invalid write of size 1
==31314==    at 0x4CF07D: R_IoBufferPutc (iosupport.c:135)
==31314==    by 0x4D3C5C: Rf_ReplIteration (main.c:222)
==31314==    by 0x4D4047: R_ReplConsole (main.c:307)
==31314==    by 0x4D4353: do_browser (main.c:1137)
==31314==    by 0x4B1E86: Rf_eval (eval.c:639)
==31314==    by 0x4D22F0: R_ReplFile (main.c:101)
==31314==    by 0x4D23FF: R_LoadProfile (main.c:663)
==31314==    by 0x4D2965: setup_Rmainloop (main.c:892)
==31314==    by 0x4D4558: Rf_mainloop (main.c:992)
==31314==    by 0x41A4D7: main (Rmain.c:32)
==31314==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==31314==

 *** caught segfault ***
address (nil), cause 'memory not mapped'

And here is the gdb backtrace:

#0  R_IoBufferPutc (c=c at entry=108, iob=iob at entry=0x9868c0 <R_ConsoleIob>)
    at iosupport.c:135
#1  0x00000000004d3c5d in Rf_ReplIteration (rho=rho at entry=0x9b9920,
    savestack=savestack at entry=9, browselevel=browselevel at entry=1,
    state=state at entry=0x7fffffffadb0) at main.c:222
#2  0x00000000004d4048 in R_ReplConsole (rho=rho at entry=0x9b9920,
    savestack=savestack at entry=9, browselevel=browselevel at entry=1) at
main.c:307
#3  0x00000000004d4354 in do_browser (call=0x1464b20, op=<optimized out>,
    args=<optimized out>, rho=0x9b9920) at main.c:1137
#4  0x00000000004b1e87 in Rf_eval (e=0x1464b20, rho=rho at entry=0x9b9920)
    at eval.c:639
#5  0x00000000004d22f1 in R_ReplFile (fp=0x146fdb0, rho=rho at entry=0x9b9920)
    at main.c:101
#6  0x00000000004d2400 in R_LoadProfile (fparg=0x146fdb0,
    env=env at entry=0x9b9920) at main.c:663
#7  0x00000000004d2966 in setup_Rmainloop () at main.c:892
#8  0x00000000004d4559 in Rf_mainloop () at main.c:992
#9  0x000000000041a4d8 in main (ac=ac at entry=1, av=av at entry=0x7fffffffe058)
    at Rmain.c:32
#10 0x00007ffff6a87ea5 in __libc_start_main (main=0x41a4c0 <main>, argc=1,
    ubp_av=0x7fffffffe058, init=<optimized out>, fini=<optimized out>,
    rtld_fini=<optimized out>, stack_end=0x7fffffffe048) at libc-start.c:260
#11 0x000000000041a509 in _start ()


Lastly, here is my

> sessionInfo()
R version 3.0.1 Patched (2013-05-24 r62797)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C             
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8   
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8  
 [7] LC_PAPER=C                 LC_NAME=C                
 [9] LC_ADDRESS=C               LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
Comment 1 Brian Ripley 2013-07-15 16:18:26 UTC
R is not set up for interaction with the user at that point.  So don't do it!

Also not for .Rprofile.

I've moved the initialization of the console up.