Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using an SO object between R sessions crashes R studio #5

Open
stumoodie opened this issue Mar 8, 2018 · 3 comments
Open

Using an SO object between R sessions crashes R studio #5

stumoodie opened this issue Mar 8, 2018 · 3 comments

Comments

@stumoodie
Copy link

I was getting the occasional crash related to the SO object and I think I have identified what is causing it. It seems to be that if you use an object that is in your R environment after you restart the R session in R studio then the session crashes. This occurs on the Mac and Windows. To reproduce initialise an So object from a file.

test_so_file <- "UC1_focei_SO.xml"
test_so <- libsoc::so_SO_read(file.path("tests/testthat", test_so_file))

Test is works:

test_so$all_population_estimates()

Restart the R session and try the last command again:

test_so$all_population_estimates()

This crashes the R session. I've attached the R studio screenshot.
rcrash

@rikardn
Copy link
Member

rikardn commented Mar 9, 2018

Very interesting! I don't know exactly what happens when you restart an R session. How can even the variables be retained in the global environment if R was restarted? But, still, I think I know what is causing this. The restart causes the underlying C objects to be freed from memory, but the R object that is somehow retained still points into this memory so we have a case of dangling pointers. There are ways to let R know about this memory and hopefully not free it when restarting.

@stumoodie
Copy link
Author

I'll leave it with you. Now I know I'll try and avoid this scenario.

@bguiastr
Copy link

bguiastr commented Mar 9, 2018

Not sure if it could be of any help in this case but you may be interested in this function:

library.dynam(chname = 'libsoc',
              package = 'libsoc',
              lib.loc = .libPaths()[1])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants