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

Crash in sample_correlated_gnp #140

Closed
youngser opened this issue Jan 27, 2016 · 12 comments
Closed

Crash in sample_correlated_gnp #140

youngser opened this issue Jan 27, 2016 · 12 comments
Milestone

Comments

@youngser
Copy link

youngser commented Jan 27, 2016

Hello,

The following sequence causes R crashed on me on mac and linux:

igraph.version()
[1] "1.0.0"

library(igraph)
set.seed(123)
B <- cbind( c(.2, .1), c(.1, .3) )
g <- sample_sbm(1000, pref.matrix=B, block.sizes=c(300,700))
g2 <- sample_correlated_gnp(g, corr = 0.5)
@gaborcsardi
Copy link
Contributor

Yes, unfortunately. :(

@youngser
Copy link
Author

Is this still in your todo list?
If so,is it possible if you can move it up?
Thanks!

@gaborcsardi
Copy link
Contributor

Here is a stack

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffd00f15db0)
  * frame #0: 0x0000000108124f83 igraph.so`igraph_correlated_game(old_graph=<unavailable>, new_graph=0x00007ffeefbfd120, corr=0, p=498799, permutation=0x0000000000000000) at games.c:0:24 [opt]
    frame #1: 0x00000001082496ec igraph.so`R_igraph_correlated_game(old_graph=<unavailable>, corr=<unavailable>, p=<unavailable>, permutation=0x0000000101002ee0) at rinterface.c:10195:3 [opt]
    frame #2: 0x000000010015865b libR.dylib`R_doDotCall(ofun=<unavailable>, nargs=<unavailable>, cargs=0x00007ffeefbfda00, call=0x00000001091ca628) at dotcode.c:607:17 [opt]
    frame #3: 0x00000001001a451a libR.dylib`bcEval(body=0x00000001091cd850, rho=0x00000001091cbee0, useCache=<unavailable>) at eval.c:7659:21 [opt]
    frame #4: 0x000000010018a261 libR.dylib`Rf_eval(e=<unavailable>, rho=<unavailable>) at eval.c:727:8 [opt]
    frame #5: 0x00000001001aa791 libR.dylib`R_execClosure(call=0x00000001091cf770, newrho=<unavailable>, sysparent=<unavailable>, rho=0x0000000101040e08, arglist=<unavailable>, op=<unavailable>) at eval.c:0 [opt]
    frame #6: 0x00000001001a9569 libR.dylib`Rf_applyClosure(call=0x00000001091cf770, op=0x00000001091cfaf0, arglist=0x00000001091cbd58, rho=0x0000000101040e08, suppliedvars=0x0000000101002ee0) at eval.c:1818:16 [opt]
    frame #7: 0x000000010018a736 libR.dylib`Rf_eval(e=0x00000001091cf770, rho=0x0000000101040e08) at eval.c:850:12 [opt]
    frame #8: 0x00000001001adfbd libR.dylib`do_set(call=<unavailable>, op=0x0000000101001078, args=0x00000001091cf7e0, rho=0x0000000101040e08) at eval.c:2960:8 [opt]
    frame #9: 0x000000010018a459 libR.dylib`Rf_eval(e=0x00000001091cf850, rho=0x0000000101040e08) at eval.c:802:12 [opt]
    frame #10: 0x00000001001dfcea libR.dylib`Rf_ReplIteration(rho=0x0000000101040e08, savestack=<unavailable>, browselevel=0, state=0x00007ffeefbfe5c0) at main.c:264:2 [opt]
    frame #11: 0x00000001001e120f libR.dylib`run_Rmainloop [inlined] R_ReplConsole(rho=0x0000000101040e08, savestack=0, browselevel=0) at main.c:314:11 [opt]
    frame #12: 0x00000001001e11a6 libR.dylib`run_Rmainloop at main.c:1113 [opt]
    frame #13: 0x0000000100000f5b R`main + 27
    frame #14: 0x00007fff7c7e13d5 libdyld.dylib`start + 1

@szhorvat
Copy link
Member

Thanks @gaborcsardi!

@szhorvat
Copy link
Member

@gaborcsardi I think this is a bug in the R interface. The default value of the p parameter is old.graph$p, but that does not necessarily exist. When it is NULL, then a bad value is passed to the C function. I don't have a good enough understanding of how parameters as passed form R to C, but numeric(0) (which NULL becomes here) doesn't look like a valid value.

@szhorvat szhorvat mentioned this issue Nov 28, 2020
@ntamas ntamas added this to the 1.3.0 milestone Jan 10, 2022
@melprice
Copy link

Has this been resolved yet or is there a work around? I am having the same issue. Thanks!

@szhorvat
Copy link
Member

szhorvat commented Mar 15, 2022

I think there are two issues here:

  • One is that the R interface does not check that scalar arguments are indeed scalar. Instead, it just indexes them, and takes the first element. If the argument is zero-length, this causes a crash. This should be fixed in stimulus, in how it generates code. Perhaps we can add a check for the vector length. I have actually experimented with this very briefly @ntamas, but I'm too slow with R and can't afford the time now.
  • Trying to take old.graph$p as mentioned in my comment above.

@ntamas
Copy link
Member

ntamas commented Mar 15, 2022

I tried explicitly supplying p=edge_density(g) to sample_correlated_gnp(), but then it crashes with a different error so I'll have to investigate this more thoroughly tomorrow.

@szhorvat szhorvat changed the title sample_correlated_gnp Crash in sample_correlated_gnp Mar 15, 2022
@szhorvat
Copy link
Member

I don't get a crash, but a hang. I am about to add at least interruption support to igraph_correlated_game() on the master branch (will push soon).

@szhorvat
Copy link
Member

Opened a C core issue igraph/igraph#2004

@szhorvat
Copy link
Member

The issue on the C side is now fixed. The easiest immediate fix for the R-side issue is probably to use p=edge_density(g) by default.

@ntamas
Copy link
Member

ntamas commented Mar 16, 2022

The issue is now also fixed in the development branch of the R interface. The fix will officially be released in R-igraph 1.3.0.

@ntamas ntamas closed this as completed Mar 16, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants