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

maxp_greedy crashing RStudio #39

Closed
yasmoune opened this issue Mar 3, 2023 · 8 comments
Closed

maxp_greedy crashing RStudio #39

yasmoune opened this issue Mar 3, 2023 · 8 comments

Comments

@yasmoune
Copy link

yasmoune commented Mar 3, 2023

Hello !
I have been using the function "maxp_greedy" from rgeoda for many months and it was working perfectly. I tried running the same unmodified script this week and the maxp_greedy function is not working anymore. I have the following error "R encountered a fatal error. The session was terminated".
I tried to download an older version of rgeoda but got errors while dowloading version 0.0.9 and older ones.
Has anyone encountered the same issues (fatal error using maxp_greedy or/and issues downloading older versions of rgeoda) ?
Thank you for your help !

@walkerke
Copy link

I have the same issue, I've tested on multiple operating systems and the Max-P and AZP algorithms don't work. I have tried on the Python side with pygeoda, and I have not encountered such issues. I'd be happy to try to put together a PR if I knew where to start looking - @lixun910 do you have any pointers here?

@lixun910
Copy link
Member

Is there any crash report or log? I can help to check what might cause the crash. Thanks!

@walkerke
Copy link

Thanks @lixun910! Here's what I see when running the Guerry example in the docs for maxp_greedy() under valgrind on Ubuntu.

> maxp_clusters <- maxp_greedy(queen_w, data, bound_variable, min_bound, iterations=99)
==19557== Thread 7:
==19557== Invalid read of size 4
==19557==    at 0x2AA2F461: swap<int> (move.h:198)
==19557==    by 0x2AA2F461: iter_swap<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> > > (stl_algobase.h:148)
==19557==    by 0x2AA2F461: DataUtils::Shuffle(std::vector<int, std::allocator<int> >&, Xoroshiro128Random&) (DataUtils.h:164)
==19557==    by 0x2AA29168: MaxpRegionMaker::InitSolution() (azp.cpp:968)
==19557==    by 0x2AA2A687: MaxpRegionMaker::MaxpRegionMaker(GalElement*, double**, RawDistMatrix*, int, int, std::vector<ZoneControl, std::allocator<ZoneControl> > const&, std::vector<int, std::allocator<int> > const&, long long) (azp.cpp:943)
==19557==    by 0x2AA2AB5C: MaxpRegion::RunConstruction(long long) (azp.cpp:1287)
==19557==    by 0x2AA23864: MaxpRegion::RunConstructionRange(int, int) (azp.cpp:1272)
==19557==    by 0x2AA23805: maxp_thread_helper_construction(void*) (azp.cpp:27)
==19557==    by 0x78586DA: start_thread (pthread_create.c:463)
==19557==    by 0x55C461E: clone (clone.S:95)
==19557==  Address 0x12981f2c is 4 bytes before a block of size 512 alloc'd
==19557==    at 0x4C3217F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19557==    by 0x2A9798C3: allocate (new_allocator.h:111)
==19557==    by 0x2A9798C3: allocate (alloc_traits.h:436)
==19557==    by 0x2A9798C3: _M_allocate (stl_vector.h:172)
==19557==    by 0x2A9798C3: void std::vector<int, std::allocator<int> >::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&) (vector.tcc:406)
==19557==    by 0x2AA29B7A: push_back (stl_vector.h:948)
==19557==    by 0x2AA29B7A: MaxpRegionMaker::InitSolution() (azp.cpp:965)
==19557==    by 0x2AA2A687: MaxpRegionMaker::MaxpRegionMaker(GalElement*, double**, RawDistMatrix*, int, int, std::vector<ZoneControl, std::allocator<ZoneControl> > const&, std::vector<int, std::allocator<int> > const&, long long) (azp.cpp:943)
==19557==    by 0x2AA2AB5C: MaxpRegion::RunConstruction(long long) (azp.cpp:1287)
==19557==    by 0x2AA23864: MaxpRegion::RunConstructionRange(int, int) (azp.cpp:1272)
==19557==    by 0x2AA23805: maxp_thread_helper_construction(void*) (azp.cpp:27)
==19557==    by 0x78586DA: start_thread (pthread_create.c:463)
==19557==    by 0x55C461E: clone (clone.S:95)
==19557== 
==19557== Invalid write of size 4
==19557==    at 0x2AA2F463: swap<int> (move.h:199)
==19557==    by 0x2AA2F463: iter_swap<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> > > (stl_algobase.h:148)
==19557==    by 0x2AA2F463: DataUtils::Shuffle(std::vector<int, std::allocator<int> >&, Xoroshiro128Random&) (DataUtils.h:164)
==19557==    by 0x2AA29168: MaxpRegionMaker::InitSolution() (azp.cpp:968)
==19557==    by 0x2AA2A687: MaxpRegionMaker::MaxpRegionMaker(GalElement*, double**, RawDistMatrix*, int, int, std::vector<ZoneControl, std::allocator<ZoneControl> > const&, std::vector<int, std::allocator<int> > const&, long long) (azp.cpp:943)
==19557==    by 0x2AA2AB5C: MaxpRegion::RunConstruction(long long) (azp.cpp:1287)
==19557==    by 0x2AA23864: MaxpRegion::RunConstructionRange(int, int) (azp.cpp:1272)
==19557==    by 0x2AA23805: maxp_thread_helper_construction(void*) (azp.cpp:27)
==19557==    by 0x78586DA: start_thread (pthread_create.c:463)
==19557==    by 0x55C461E: clone (clone.S:95)
==19557==  Address 0x12981f2c is 4 bytes before a block of size 512 alloc'd
==19557==    at 0x4C3217F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19557==    by 0x2A9798C3: allocate (new_allocator.h:111)
==19557==    by 0x2A9798C3: allocate (alloc_traits.h:436)
==19557==    by 0x2A9798C3: _M_allocate (stl_vector.h:172)
==19557==    by 0x2A9798C3: void std::vector<int, std::allocator<int> >::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&) (vector.tcc:406)
==19557==    by 0x2AA29B7A: push_back (stl_vector.h:948)
==19557==    by 0x2AA29B7A: MaxpRegionMaker::InitSolution() (azp.cpp:965)
==19557==    by 0x2AA2A687: MaxpRegionMaker::MaxpRegionMaker(GalElement*, double**, RawDistMatrix*, int, int, std::vector<ZoneControl, std::allocator<ZoneControl> > const&, std::vector<int, std::allocator<int> > const&, long long) (azp.cpp:943)
==19557==    by 0x2AA2AB5C: MaxpRegion::RunConstruction(long long) (azp.cpp:1287)
==19557==    by 0x2AA23864: MaxpRegion::RunConstructionRange(int, int) (azp.cpp:1272)
==19557==    by 0x2AA23805: maxp_thread_helper_construction(void*) (azp.cpp:27)
==19557==    by 0x78586DA: start_thread (pthread_create.c:463)
==19557==    by 0x55C461E: clone (clone.S:95)
==19557== 
==19557== Invalid read of size 8
==19557==    at 0x2AA25725: RegionMaker::getBufferingAreas(boost::unordered::unordered_map<int, bool, boost::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, bool> > >&) (azp.cpp:775)
==19557==    by 0x2AA2934F: MaxpRegionMaker::InitSolution() (azp.cpp:1002)
==19557==    by 0x2AA2A687: MaxpRegionMaker::MaxpRegionMaker(GalElement*, double**, RawDistMatrix*, int, int, std::vector<ZoneControl, std::allocator<ZoneControl> > const&, std::vector<int, std::allocator<int> > const&, long long) (azp.cpp:943)
==19557==    by 0x2AA2AB5C: MaxpRegion::RunConstruction(long long) (azp.cpp:1287)
==19557==    by 0x2AA23864: MaxpRegion::RunConstructionRange(int, int) (azp.cpp:1272)
==19557==    by 0x2AA23805: maxp_thread_helper_construction(void*) (azp.cpp:27)
==19557==    by 0x78586DA: start_thread (pthread_create.c:463)
==19557==    by 0x55C461E: clone (clone.S:95)
==19557==  Address 0x42ec6d68 is not stack'd, malloc'd or (recently) free'd
==19557== 

 *** caught segfault ***
address 0x42ec6d68, cause 'memory not mapped'

Traceback:
 1: p_maxp_greedy(w$GetPointer(), df, n_vars, bound_values, min_bound,     iterations, initial_regions, scale_method, distance_method,     random_seed, cpu_threads, rdist)
 *** caught segfault ***
address 0x47801c1158, cause 'memory not mapped'

Traceback:
 1: p_maxp_greedy(w$GetPointer(), df, n_vars, bound_values, min_bound,     iterations, initial_regions, scale_method, distance_method,     random_seed, cpu_threads, rdist)
 2: maxp_greedy(queen_w, data, bound_variable, min_bound, iterations = 99)
An irrecoverable exception occurred. R is aborting now ...

 *** caught segfault ***
address 0x1c2d13e358, cause 'memory not mapped'

Traceback:
 1: p_maxp_greedy(w$GetPointer(), df, n_vars, bound_values, min_bound,     iterations, initial_regions, scale_method, distance_method,     random_seed, cpu_threads, rdist)
 2: maxp_greedy(queen_w, data, bound_variable, min_bound, iterations = 99)
An irrecoverable exception occurred. R is aborting now ...

 *** caught segfault ***
address 0x24c120a778, cause 'memory not mapped'

Traceback:
 1: p_maxp_greedy(w$GetPointer(), df, n_vars, bound_values, min_bound,     iterations, initial_regions, scale_method, distance_method,     random_seed, cpu_threads, rdist)
 2: maxp_greedy(queen_w, data, bound_variable, min_bound, iterations = 99)
An irrecoverable exception occurred. R is aborting now ...

 2: maxp_greedy(queen_w, data, bound_variable, min_bound, iterations = 99)==19557== 
==19557== Process terminating with default action of signal 11 (SIGSEGV)
==19557==    at 0x54E1E65: raise (raise.c:46)
==19557==    by 0x4FBBCBC: ??? (in /usr/lib/R/lib/libR.so)
==19557==    by 0x54E1F0F: ??? (in /lib/x86_64-linux-gnu/libc-2.27.so)
==19557==    by 0x2AA25724: RegionMaker::getBufferingAreas(boost::unordered::unordered_map<int, bool, boost::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, bool> > >&) (azp.cpp:775)
==19557==    by 0x2AA2934F: MaxpRegionMaker::InitSolution() (azp.cpp:1002)
==19557==    by 0x2AA2A687: MaxpRegionMaker::MaxpRegionMaker(GalElement*, double**, RawDistMatrix*, int, int, std::vector<ZoneControl, std::allocator<ZoneControl> > const&, std::vector<int, std::allocator<int> > const&, long long) (azp.cpp:943)
==19557==    by 0x2AA2AB5C: MaxpRegion::RunConstruction(long long) (azp.cpp:1287)
==19557==    by 0x2AA23864: MaxpRegion::RunConstructionRange(int, int) (azp.cpp:1272)
==19557==    by 0x2AA23805: maxp_thread_helper_construction(void*) (azp.cpp:27)
==19557==    by 0x78586DA: start_thread (pthread_create.c:463)
==19557==    by 0x55C461E: clone (clone.S:95)
==19557== 
==19557== HEAP SUMMARY:
==19557==     in use at exit: 100,939,230 bytes in 74,153 blocks
==19557==   total heap usage: 341,484 allocs, 267,331 frees, 328,141,876 bytes allocated
==19557== 
==19557== LEAK SUMMARY:
==19557==    definitely lost: 48 bytes in 1 blocks
==19557==    indirectly lost: 0 bytes in 0 blocks
==19557==      possibly lost: 2,216,359 bytes in 6,864 blocks
==19557==    still reachable: 98,722,823 bytes in 67,288 blocks
==19557==                       of which reachable via heuristic:
==19557==                         length64           : 2,740,728 bytes in 25,420 blocks
==19557==                         newarray           : 16,512 bytes in 2 blocks
==19557==         suppressed: 0 bytes in 0 blocks
==19557== Rerun with --leak-check=full to see details of leaked memory
==19557== 
==19557== For counts of detected and suppressed errors, rerun with: -v
==19557== Use --track-origins=yes to see where uninitialised values come from
==19557== ERROR SUMMARY: 8118 errors from 16 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

@lixun910
Copy link
Member

Thanks, @walkerke! Can you help to verify if the changes work on Ubuntu devtools::install_github("lixun910/rgeoda-1@fix-cran-gcc13")? I knew the github actions showed test cases of max-p were failed on Ubuntu (although success on Mac and Windows), just want to confirm it : )

@walkerke
Copy link

walkerke commented Jul 2, 2023

@lixun910 just tested a couple examples on Ubuntu (the documentation example, and an example of my own). Both worked! Thanks so much!

@lixun910
Copy link
Member

lixun910 commented Jul 3, 2023

Great to hear! The 0.0.10-4 with this fix has been checked and released, Please feel free to update to the latest version. Thank you! Ref: #38 #33 #27 @walkerke

@walkerke
Copy link

walkerke commented Jul 4, 2023

wonderful, thanks so much @lixun910!

@eestefaniasalazar
Copy link

I updated to the latest version and the same error occurs with the "skater" function

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

4 participants