Segmentation faults when converting objects

Issue #524 resolved
Philipp A. created an issue

When I convert objects, python crashes. A simple reproducible example: https://github.com/flying-sheep/anndata2ri/blob/segfault/rpy2-reproduce.py

/edit: simpler example

Comments (10)

  1. Laurent Gautier

    Complex examples and non-deterministic bugs require a lot from someone interested in looking at the issue. Try simplifying the example. I suspect a memory error of some sort, so try calling Python and R's garbage collector to see if you can trigger it more reliably as you work your way toward a simpler example.

  2. Laurent Gautier

    Looks like that R / Bioconductor object is a matrix of numbers, which would mean that the issue is present for all R matrices.

  3. Laurent Gautier

    A shorter way to trigger the issue:

    import gc
    import faulthandler
    
    from rpy2.robjects import numpy2ri, baseenv, r
    
    faulthandler.enable()
    
    exprs = numpy2ri.rpy2py(r('''
    matrix(rnorm(20000*200), nrow = 20000, ncol = 200)
    '''))
    
    gc.collect()
    baseenv['gc']()
    
    # SEGFAULT when interacting with the numpy array
    print(exprs)
    

    This is not triggering the issue:

    import gc
    import faulthandler
    
    from rpy2.robjects import numpy2ri, baseenv, r
    
    faulthandler.enable()
    
    exprs = numpy2ri.rpy2py(r('''
    m <- matrix(rnorm(20000*200), nrow = 20000, ncol = 200)
    m
    '''))
    
    gc.collect()
    baseenv['gc']()
    
    print(exprs)
    
  4. Philipp A. reporter

    Great! This comes just in time for my colleagues’ review paper. Thank you so much!

  5. Laurent Gautier

    rpy2-3.0.1 is released and on pypi.

    Thanks for narrowing where the bug is happening down.

    I still have to follow-up on your other issues or comments...

  6. Log in to comment