Search code examples
pythonpycharmkernelexit-code

Pycharm gives this error: "process finished with exit code -1073741819 (0xc0000005)"


I am trying to use the library tvb-gdist in Pycharm to compute geodesic distances in several meshes. To install it just:

pip install tvb-gdist

However for some reason it works for only some of them. I work with lots of meshes but I will just show you an example with 2 of them to simplify (Here is the link to a folder with the files: https://drive.google.com/drive/folders/1dFKc8wdQuFaUNa3EIKdS7eTj6WVwwZFn?usp=sharing) . The function "gdist.local_gdist_matrix" takes as inputs the vertices and the faces of the mesh, and when executing it for the mesh formed by "vertices2" and "faces2" it works just fine. However when using the mesh formed by "vertices" and "faces" the error appears and the python console shuts down. The entire code is quite big but here is the code I developed to read the files and easily reproduce the error:

import csv
import gdist

file = open('faces.csv')
csvreader = csv.reader(file)
faces = []
for row in csvreader:
        faces.append(row)
file.close()

file = open('vertices.csv')
csvreader = csv.reader(file)
vertices = []
for row in csvreader:
        vertices.append(row)
file.close()

file = open('faces2.csv')
csvreader = csv.reader(file)
faces2 = []
for row in csvreader:
        faces2.append(row)
file.close()

file = open('vertices2.csv')
csvreader = csv.reader(file)
vertices2 = []
for row in csvreader:
        vertices2.append(row)
file.close()

vertices2 = np.array(vertices2).astype('float64')
faces2 = np.array(faces2).astype('int32')
aux_distances2 = gdist.local_gdist_matrix(vertices2, faces2, max_distance=12)

vertices = np.array(vertices).astype('float64')
faces = np.array(faces).astype('int32')
aux_distances = gdist.local_gdist_matrix(vertices, faces, max_distance=12)

If you run first until "aux_distances2" you will see that no problem arises and that it gives back the desired matrix. However when runing "aux_distances" the error "process finished with exit code -1073741819 (0xc0000005)" appears and the console crashes. I believe that since it works for some files, the problem cant be with the python version or with something related to the path of the files (they are under the same directory) but anything may be possible. I thought that it might be related with the amount of faces and/or vertices but I did a mesh decimation using the library "quad_mesh_simplify" and the same error appeared after the remesh had been done. I also tried to run it in a notebook in Google Colab to check if Pycharm was the problem but the result was the same: for the second mesh it worked just fine but for the first mesh it crashed. The error showed: "KernelRestarter: restarting kernel (1/5), keep random ports" and then "WARNING:root:kernel 0c24cfc6-3530-4211-a4d2-b147c3444581 restarted". I have tried every solution that I have found and none of them have worked so if anyone could help me I would very much appreciate it.


Solution

  • I suppose you are referring to tvb-gdist from here: https://github.com/the-virtual-brain/tvb-gdist

    I tested it myself, and I can reproduce the problem.

    I think you are right, it is not the installation, or the IDE's culprit. I suspect the surface has problems. A minor inspection with tvb software shows the warnings bellow.

    Could you alter the surface and get rid of its problems (pinched faces and possible small holes)? I suspect the piches produce an infinite loop in tvb-gdist.

    2022-04-26 05:34:01,630 - WARNING [proc:21055]  - tvb.datatypes.surfaces - Surface is pinched off.
    2022-04-26 05:34:01,630 - DEBUG [proc:21055]  - tvb.datatypes.surfaces - These are edges with more than 2 triangles: 
    [ 11022  11023  11033  11035  11036  11273  11280  11488  11489  11494
      11495  11508  11509  11516  11517  11753  11759  11770  11775  11782
      11976  11994  12238  12240  12247  12253  12279  12283  12485  12486
      12490  12491  12495  12498  12519  12746  12747  12752  12753  12778
      12781  12991  13033  13037  13045  13249  13250  13256  13258  13266
      13317  13549  13572  13577  13761  13803  14031  14034  14037  14084
      14319  14541  14589  14780  14784  15036  15286  15287  15293  15553
      15559  15801  15804  15814  15815  15822  15826  16121  16335  16336
      16632  16633  16636  16857  16866  17167  17169  17423  17717  17720
      17993  18292  18561  18853  18854  19155  19159  19170  19763  19765
      20093  20364  20685  20689  20984  21317  21602  21604  21978  22283
      22288  22637  22961  23330  23709  23711  23721  24110  24436  24444
      24865  25228  25234  25235  25674  25677  26061  26534  26921  26926
      27380  27764  27769  28620  29051  29440  29899  29907  30678  30683
      31028  31034  31495  31818  32303  32310  33042  33416  33418  33430
      34170  34567  34571  34932  35327  35679  36083  36453  36457  36857
      37213  38011  38443  38812  38815  38824  39347  39350  39632  39639
      40060  40131  40138  40140  40406  40492  40841  40843  40851  40923
      40928  41598  41603  41675  41682  41955  42025  42323  42329  42397
      42676  43056  43119  43126  43425  43432  43488  43872  44168  44171
      44237  44570  44621  44940  44996  45002  45335  45689  45735  45741
      46092  46099  46516  46522  46884  46887  46902  46904  46908  46910
      47275  47289  47295  47296  47325  47726  47735  47736  47740  47744
      47745  47758  47790  47796  48110  48118  48126  48132  48139  48152
      48153  48158  48160  48167  48170  48179  48181  48185  48579  48583
      48605  48610  48611  48612  48616  48622  48628  48632  48653  49030
      49038  49050  49051  49080  49086  49089  49100  49101  49106  49108
      49568  49588  49593  49610  49620  49627  49631  50042  50047  50060
      50061  50076  50598  50602  50603  50607  50613 118407 118416 118571
     118574 118578 118926 118932 119068 119276 119387 119496 119499 119503
     119606 119695 119811 119987 120165 120336 120482 120488 120797 120928
     121081 121174 121185 121325 121391 121588 121607 121716 121780 121859
     122210 122224 122337 122516 122518 122636 122750 122826 122832 123024
     123103 123136 123223 123378 123385 123435 123436 123449 123474 123589
     123760 123766 123799 123833 123933 123953 123963 123966 123967 123975
     123976 124142 124143 124152 124161 124168 124284 124297 124482 124484
     124485 124493 124501 124642]
    2022-04-26 05:34:01,631 - WARNING [proc:21055]  - tvb.datatypes.surfaces - Has holes.
    2022-04-26 05:34:01,631 - DEBUG [proc:21055]  - tvb.datatypes.surfaces - Free boundaries: 
    [108104 108106 108391 108430 117047 117051 117057 117068]