1. rpy2
  2. rpy2
  3. rpy2
  4. Issues

Issues

Issue #413 new

Seg fault on closing Python3 when using .Last function in .Rprofile

Roger Westover
created an issue

I installed rpy2 using pip3 and it is version 2.8.6. I have the following ~/.Rprofile file to run commands on starting and exiting R.

.First <- function(){
    cat("Hi\n")
}

.Last <- function(){
    cat("\nGoodbye at ", date(), "\n")
}

If I run the simple python file

import rpy2.robjects as robjects

Then I get a seg fault on the program closing. If I run it in gdb then I see

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
__new_sem_wait (sem=0x0) at sem_wait.c:26
26      sem_wait.c: No such file or directory.

If I comment out the .Last function in the .Rprofile then no seg fault occurs so it seems this is where the issue is.

Comments (2)

  1. Laurent Gautier

    What happens when you add the following at the end of your Python script ?

    print('--> Terminating the embedded R process')
    from rpy2 import rinterface
    rinterface.endr()
    print('--> done')
    
  2. Roger Westover reporter

    If I run

    import rpy2.robjects as robjects
    print('--> Terminating the embedded R process')
    from rpy2 import rinterface
    rinterface.endr(robjects)  # I believe this is the argument I am meant to pass (no arguments returned a TypeError)
    print('--> done')
    

    Then it seems to run the .Last command from R but it still seg faults when the program ends. Note that with just the one line script I was previously using, the .Last command was not being run.

  3. Log in to comment