Opened 6 years ago

Closed 3 years ago

#3429 closed defect (duplicate)

g.gui.iclass: segfault when loading vector layer

Reported by: mlennert Owned by: grass-dev@…
Priority: normal Milestone: 7.4.5
Component: wxGUI Version: svn-trunk
Keywords: g.gui.iclass import segfault Cc:
CPU: Unspecified Platform: Unspecified

Description

  • define group
  • define classes
  • digitize a few training areas
  • save training areas to vector map
  • close g.gui.iclass
  • reopen g.gui.iclass
  • import saved vector maps

=> segfault

Change History (14)

in reply to:  description ; comment:1 by mlennert, 6 years ago

Replying to mlennert:

  • define group
  • define classes
  • digitize a few training areas
  • save training areas to vector map
  • close g.gui.iclass
  • reopen g.gui.iclass
  • import saved vector maps

=> segfault

I still have this problem. Can anyone reproduce ? Does anyone have a hint on how to debug this ?

in reply to:  1 ; comment:2 by annakrat, 6 years ago

Replying to mlennert:

Replying to mlennert:

  • define group
  • define classes
  • digitize a few training areas
  • save training areas to vector map
  • close g.gui.iclass
  • reopen g.gui.iclass
  • import saved vector maps

=> segfault

I still have this problem. Can anyone reproduce ? Does anyone have a hint on how to debug this ?

Yes, I looked at it couple days ago, and I could see where the problem is, but I didn't have time to fix it. The problem is somewhere in iclass/frame, how it calls the C functions, but I need to explore it more. The simplest way to debug this (for me) is using debugger integrated into qtcreator (you need to import grass as a project there). First you run g.gui.iclass, then in qtcreator you attach this external process and then do the actions in gui and the debugger shows you the place where it crashes.

in reply to:  2 comment:3 by mlennert, 6 years ago

Replying to annakrat:

Replying to mlennert:

Replying to mlennert:

  • define group
  • define classes
  • digitize a few training areas
  • save training areas to vector map
  • close g.gui.iclass
  • reopen g.gui.iclass
  • import saved vector maps

=> segfault

I still have this problem. Can anyone reproduce ? Does anyone have a hint on how to debug this ?

Yes, I looked at it couple days ago, and I could see where the problem is, but I didn't have time to fix it. The problem is somewhere in iclass/frame, how it calls the C functions, but I need to explore it more. The simplest way to debug this (for me) is using debugger integrated into qtcreator (you need to import grass as a project there). First you run g.gui.iclass, then in qtcreator you attach this external process and then do the actions in gui and the debugger shows you the place where it crashes.

Thanks for the hint, but I have been pulling my hair out trying to make this work. On my machine, as soon as I attach to the process, the g.gui.iclass window blanks out completely and I cannot do anything. As soon as I detach the debugger from the process, I can again see the GUI window as expected and work with it. This makes it difficult to "do the action"...

comment:4 by annakrat, 6 years ago

I have just been looking at this, but since I have to leave right now, this is where I got. I don't understand how the temporary maps work, so it's hard to say what consequences this has, but please test.

Index: Vlib/open.c
===================================================================
--- Vlib/open.c	(revision 71523)
+++ Vlib/open.c	(working copy)
@@ -960,7 +960,7 @@
     }
     G_debug(1, "Vect_open_tmp_new(): name = '%s' with_z = %d", name, with_z);
 
-    return open_new(Map, tmp_name, with_z, TEMPORARY_MAP); /* temporary map */
+    return open_new(Map, tmp_name, with_z, TEMPORARY_MAP_ENV); /* temporary map */
 }

Index: gui/wxpython/iclass/frame.py
===================================================================
--- gui/wxpython/iclass/frame.py	(revision 71523)
+++ gui/wxpython/iclass/frame.py	(working copy)
@@ -624,7 +624,8 @@
             return
 
         # copy features to the temporary map
-        vname = self._getTempVectorName()
+        #vname = self._getTempVectorName()
+        vname = self.trainingAreaVector
         # avoid deleting temporary map
         os.environ['GRASS_VECTOR_TEMPORARY'] = '1'
         if digitClass.CopyMap(vname, tmp=True) == -1:

For the debugging, you need to (after attaching the process) press Continue to release the gui, then do things in gui and it then jumps in qtcreator to segfaults or breakpoints.

in reply to:  4 ; comment:5 by mlennert, 6 years ago

Replying to annakrat:

I have just been looking at this, but since I have to leave right now, this is where I got. I don't understand how the temporary maps work, so it's hard to say what consequences this has, but please test.

Martin: as you introduced the whole notion of temporary vector maps, maybe you can explain ?

Index: Vlib/open.c
===================================================================
--- Vlib/open.c	(revision 71523)
+++ Vlib/open.c	(working copy)
@@ -960,7 +960,7 @@
     }
     G_debug(1, "Vect_open_tmp_new(): name = '%s' with_z = %d", name, with_z);
 
-    return open_new(Map, tmp_name, with_z, TEMPORARY_MAP); /* temporary map */
+    return open_new(Map, tmp_name, with_z, TEMPORARY_MAP_ENV); /* temporary map */
 }

Index: gui/wxpython/iclass/frame.py
===================================================================
--- gui/wxpython/iclass/frame.py	(revision 71523)
+++ gui/wxpython/iclass/frame.py	(working copy)
@@ -624,7 +624,8 @@
             return
 
         # copy features to the temporary map
-        vname = self._getTempVectorName()
+        #vname = self._getTempVectorName()
+        vname = self.trainingAreaVector
         # avoid deleting temporary map
         os.environ['GRASS_VECTOR_TEMPORARY'] = '1'
         if digitClass.CopyMap(vname, tmp=True) == -1:

This allows me to open the vector file with the stored polygons. Thanks ! In the terminal, I get messages such as:

G__open(read): Unable to open '/home/mlennert/GRASSDATA/nc_spm_08_grass7/user1/.tmp/moritz-ulb/vector/trAreas325320/frmt': No such file or directory

For the debugging, you need to (after attaching the process) press Continue to release the gui, then do things in gui and it then jumps in qtcreator to segfaults or breakpoints.

Thanks for the hint ! Now I can get the module to crash, but the debugger indicates some completely different place in the code. But probably I don't understand the debugging in qtcreator enough, yet.

in reply to:  5 comment:6 by annakrat, 6 years ago

Replying to mlennert:

This allows me to open the vector file with the stored polygons. Thanks ! In the terminal, I get messages such as:

G__open(read): Unable to open '/home/mlennert/GRASSDATA/nc_spm_08_grass7/user1/.tmp/moritz-ulb/vector/trAreas325320/frmt': No such file or directory

I noticed, but they don't seem to actually cause anything so I ignored it so far, but we should look at it too.

For the debugging, you need to (after attaching the process) press Continue to release the gui, then do things in gui and it then jumps in qtcreator to segfaults or breakpoints.

Thanks for the hint ! Now I can get the module to crash, but the debugger indicates some completely different place in the code. But probably I don't understand the debugging in qtcreator enough, yet.

This is more complicated case for debugging than normally since the C calls are made from the GUI. I think the actual crash happened elsewhere, but that is just a consequence of a problem happening before. The specific problem I found was that in function CopyMap in iclass/digit.py the Vect_close function was deleting the temporary vector (which causes segfault later on). At this point I don't understand the temporary vectors enough to fix it properly...

comment:7 by neteler, 6 years ago

Milestone: 7.4.07.4.1

Ticket retargeted after milestone closed

comment:8 by mlennert, 6 years ago

Trying this with current trunk, just aopplying the first part of the patch, i.e.


Index: Vlib/open.c
===================================================================
--- Vlib/open.c	(revision 71523)
+++ Vlib/open.c	(working copy)
@@ -960,7 +960,7 @@
     }
     G_debug(1, "Vect_open_tmp_new(): name = '%s' with_z = %d", name, with_z);
 
-    return open_new(Map, tmp_name, with_z, TEMPORARY_MAP); /* temporary map */
+    return open_new(Map, tmp_name, with_z, TEMPORARY_MAP_ENV); /* temporary map */
 }

does the trick for me.

Anna, do you remember what the second part (in frame.py) was for ?

comment:9 by annakrat, 6 years ago

Not specifically, but I remember it was needed. The problem was I don't know what that change in Vlib would cause or where elsewhere it is used.

comment:10 by neteler, 6 years ago

Milestone: 7.4.17.4.2

comment:11 by neteler, 5 years ago

Milestone: 7.4.27.4.3

Ticket retargeted after milestone closed

comment:12 by martinl, 5 years ago

Milestone: 7.4.37.4.4

Bump milestone to 7.4.4

comment:13 by neteler, 5 years ago

Milestone: 7.4.47.4.5

Ticket retargeted after milestone closed

comment:14 by mlennert, 3 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.