Ticket #943 (new defect)

Opened 3 years ago

Last modified 5 days ago

wxpython gui hangs after switching to cairo display driver

Reported by: epatton Owned by: grass-dev@…
Priority: critical Milestone: 6.4.3
Component: wxGUI Version: svn-develbranch6
Keywords: cairo, driver, gui, wxpython Cc:
Platform: Linux CPU: All

Description

The wxpython Map Display window freezes and becomes unresponsive after changing the display driver from 'default' to 'cairo'.

I have compiled Grass 6.5 from a fresh checkout from svn, set --with-cairo, --with-cairo-libs=/usr/lib, and --with-cairo-includes=/usr/include. One thing I just noticed is that the configure line

checking for cairo linking flags...

appears as it does above, with no confirmation about whether or not it found cairo linking flags. But then I'm not sure it it's supposed to print anything in a successful case, either.

I've checked my package manager, and I have libcairo2 and libcairo2-dev installed, versions 1.8.8.

Anything else I should check? Can anyone confirm this error?

Thanks,

~ Eric.

Change History

follow-up: ↓ 3   Changed 3 years ago by hamish

same here. grass64 and grass7 work fine. I'm on debian/stable amd64, yesterday's svn.

wxGUI freezes after you change the preferences->display mode to cairo and first try to render a map.

I don't know if it's related, but I can get d.mon -L to die:

# grass65
export GRASS_PNGFILE=map.bmp
export GRASS_WIDTH=640
export GRASS_HEIGHT=480
export GRASS_RENDER_IMMEDIATE=TRUE
export GRASS_PNG_MAPPED=TRUE
export GRASS_PNG_READ=TRUE
d.mon -L

name            description                    status
----            -----------                    ------
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: map.bmp,
GRASS_WIDTH=640, GRASS_HEIGHT=480
HTMLMAP         Create HTML Image Map          running
PNG: GRASS_TRUECOLOR status: TRUE
PNG: collecting to file: map.bmp,
GRASS_WIDTH=640, GRASS_HEIGHT=480
*** glibc detected *** /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/etc/mon.status: free(): invalid pointer: 0x00007f06499b3036 ***
======= Backtrace: =========
/lib/libc.so.6[0x7f064802d928]
/lib/libc.so.6(cfree+0x76)[0x7f064802fa36]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.so(G_free+0x15)[0x7f0649072611]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_pngdriver.so[0x7f06494d89fe]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_pngdriver.so(PNG_Graph_set+0x3f8)[0x7f06494d8e1f]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_driver.so(COM_Graph_set+0x39)[0x7f06492cabc9]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_driver.so(LIB_init+0x1be)[0x7f06492cc426]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_raster.so(LOC_open_driver+0x62)[0x7f06496e4fdc]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_raster.so(R_open_driver+0x18)[0x7f06496e41ff]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/etc/mon.status(main+0x8f)[0x400b4b]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7f0647fd81a6]
/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/etc/mon.status[0x4009f9]
======= Memory map: ========
00400000-00401000 r-xp 00000000 09:02 34916230                           /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/etc/mon.status
00601000-00602000 rw-p 00001000 09:02 34916230                           /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/etc/mon.status
02496000-024b7000 rw-p 02496000 00:00 0                                  [heap]
7f0640000000-7f0640021000 rw-p 7f0640000000 00:00 0 
7f0640021000-7f0644000000 ---p 7f0640021000 00:00 0 
7f0647b9f000-7f0647bb5000 r-xp 00000000 09:00 553795                     /lib/libgcc_s.so.1
7f0647bb5000-7f0647db5000 ---p 00016000 09:00 553795                     /lib/libgcc_s.so.1
7f0647db5000-7f0647db6000 rw-p 00016000 09:00 553795                     /lib/libgcc_s.so.1
7f0647db6000-7f0647db8000 r-xp 00000000 09:00 555034                     /lib/libdl-2.7.so
7f0647db8000-7f0647fb8000 ---p 00002000 09:00 555034                     /lib/libdl-2.7.so
7f0647fb8000-7f0647fba000 rw-p 00002000 09:00 555034                     /lib/libdl-2.7.so
7f0647fba000-7f0648104000 r-xp 00000000 09:00 555046                     /lib/libc-2.7.so
7f0648104000-7f0648303000 ---p 0014a000 09:00 555046                     /lib/libc-2.7.so
7f0648303000-7f0648306000 r--p 00149000 09:00 555046                     /lib/libc-2.7.so
7f0648306000-7f0648308000 rw-p 0014c000 09:00 555046                     /lib/libc-2.7.so
7f0648308000-7f064830d000 rw-p 7f0648308000 00:00 0 
7f064830d000-7f0648311000 r-xp 00000000 09:02 34916046                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_psdriver.6.5.svn.so
7f0648311000-7f0648510000 ---p 00004000 09:02 34916046                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_psdriver.6.5.svn.so
7f0648510000-7f0648511000 rw-p 00003000 09:02 34916046                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_psdriver.6.5.svn.so
7f0648511000-7f0648593000 r-xp 00000000 09:00 555051                     /lib/libm-2.7.so
7f0648593000-7f0648792000 ---p 00082000 09:00 555051                     /lib/libm-2.7.so
7f0648792000-7f0648794000 rw-p 00081000 09:00 555051                     /lib/libm-2.7.so
7f0648794000-7f06487b9000 r-xp 00000000 09:00 151710                     /usr/lib/libpng12.so.0.27.0
7f06487b9000-7f06489b8000 ---p 00025000 09:00 151710                     /usr/lib/libpng12.so.0.27.0
7f06489b8000-7f06489b9000 rw-p 00024000 09:00 151710                     /usr/lib/libpng12.so.0.27.0
7f06489b9000-7f0648a38000 r-xp 00000000 09:00 151676                     /usr/lib/libfreetype.so.6.3.18
7f0648a38000-7f0648c37000 ---p 0007f000 09:00 151676                     /usr/lib/libfreetype.so.6.3.18
7f0648c37000-7f0648c3d000 rw-p 0007e000 09:00 151676                     /usr/lib/libfreetype.so.6.3.18
7f0648c3d000-7f0648c53000 r-xp 00000000 09:00 148994                     /usr/lib/libz.so.1.2.3.3
7f0648c53000-7f0648e53000 ---p 00016000 09:00 148994                     /usr/lib/libz.so.1.2.3.3
7f0648e53000-7f0648e54000 rw-p 00016000 09:00 148994                     /usr/lib/libz.so.1.2.3.3
7f0648e54000-7f0648e5d000 r-xp 00000000 09:02 34915909                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_datetime.6.5.svn.so
7f0648e5d000-7f064905d000 ---p 00009000 09:02 34915909                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_datetime.6.5.svn.so
7f064905d000-7f064905e000 rw-p 00009000 09:02 34915909                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_datetime.6.5.svn.so
7f064905e000-7f06490c2000 r-xp 00000000 09:02 34915953                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.6.5.svn.so
7f06490c2000-7f06492c2000 ---p 00064000 09:02 34915953                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.6.5.svn.so
7f06492c2000-7f06492c4000 rw-p 00064000 09:02 34915953                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_gis.6.5.svn.so
7f06492c4000-7f06492c6000 rw-p 7f06492c4000 00:00 0 
7f06492c6000-7f06492d2000 r-xp 00000000 09:02 34916041                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_driver.6.5.svn.so
7f06492d2000-7f06494d2000 ---p 0000c000 09:02 34916041                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_driver.6.5.svn.so
7f06494d2000-7f06494d3000 rw-p 0000c000 09:02 34916041                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_driver.6.5.svn.so
7f06494d3000-7f06494d5000 rw-p 7f06494d3000 00:00 0 
7f06494d5000-7f06494dc000 r-xp 00000000 09:02 34916043                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_pngdriver.6.5.svn.so
7f06494dc000-7f06496dc000 ---p 00007000 09:02 34916043                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_pngdriver.6.5.svn.so
7f06496dc000-7f06496dd000 rw-p 00007000 09:02 34916043                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_pngdriver.6.5.svn.so
7f06496dd000-7f06496de000 rw-p 7f06496dd000 00:00 0 
7f06496de000-7f06496ea000 r-xp 00000000 09:02 34916048                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_raster.6.5.svn.so
7f06496ea000-7f06498e9000 ---p 0000c000 09:02 34916048                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_raster.6.5.svn.so
7f06498e9000-7f06498eb000 rw-p 0000b000 09:02 34916048                   /usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-gnu/lib/libgrass_raster.6.5.svn.so
7f06498eb000-7f0649907000 r-xp 00000000 09:00 555038                     /lib/ld-2.7.so
7f06499b3000-7f0649ae0000 rw-s 00000000 09:02 34760511                   /usr/local/src/grass/tests/imgview/map.bmp
7f0649ae0000-7f0649ae5000 rw-p 7f0649ae0000 00:00 0 
7f0649b00000-7f0649b06000 rw-p 7f0649b00000 00:00 0 
7f0649b06000-7f0649b08000 rw-p 0001b000 09:00 555038                     /lib/ld-2.7.so
7fff50ba7000-7fff50bbc000 rw-p 7ffffffea000 00:00 0                      [stack]
7fff50bff000-7fff50c00000 r-xp 7fff50bff000 00:00 0                      [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

apparently GRASS_PNG_READ being set is what triggers it.

?, Hamish

  Changed 3 years ago by hamish

(and I never started the HTMLMAP driver manually)

in reply to: ↑ 1   Changed 3 years ago by glynn

Replying to hamish:

I don't know if it's related, but I can get d.mon -L to die:

...
export GRASS_RENDER_IMMEDIATE=TRUE
...
d.mon -L

I wouldn't expect GRASS_RENDER_IMMEDIATE and d.mon to work well together.

In particular, mon.status calls R_open_driver() repeatedly, which may not work with direct rendering (i.e. R_close_driver() may not restore everything sufficiently for a subsequent R_open_driver() to work; this case won't have had much testing).

in reply to: ↑ description   Changed 3 years ago by glynn

Replying to epatton:

I have compiled Grass 6.5 from a fresh checkout from svn, set --with-cairo, --with-cairo-libs=/usr/lib, and --with-cairo-includes=/usr/include.

You should never need to specify /usr/lib or /usr/include explicitly (however, recent versions of GCC will explicitly ignore them, so it's harmless).

On Linux, you should only need --with-cairo, which obtains the compiling and linking flags via pkg-config. The --with-cairo-includes, --with-cairo-libs, and --with-cairo-ldflags switches are there for platforms lacking pkg-config.

One thing I just noticed is that the configure line

checking for cairo linking flags...

appears as it does above, with no confirmation about whether or not it found cairo linking flags. But then I'm not sure it it's supposed to print anything in a successful case, either.

It prints whatever you specified for --with-cairo-ldflags. If you didn't use it, then it won't print anything.

If the cairo driver gets built, there's nothing wrong with the configure switches. If it doesn't work, that suggests a bug in either the driver or the GUI.

follow-up: ↓ 7   Changed 3 years ago by hamish

this still locks up with 64bit grass 6.5 + debian/stable.

I wonder if it is the different enviro vars needed for Cairo in 6.5?

export GRASS_CAIRO_READ=TRUE
export GRASS_CAIRO_MAPPED=TRUE
export GRASS_CAIROFILE=map.png

in 6.4svn & 7svn on the same machine it works. does 6.5svn + 32bit work?

Hamish

follow-up: ↓ 8   Changed 3 years ago by epatton

Yep, still locks up here too - 64bit, 6.5.svn on Ubuntu 9.10.

I tried exporting the variables you posted to .grass.bashrc, to no avail.

I have no way of testing on a 32-bit system.

~ Eric.

in reply to: ↑ 5   Changed 3 years ago by glynn

Replying to hamish:

this still locks up with 64bit grass 6.5 + debian/stable. I wonder if it is the different enviro vars needed for Cairo in 6.5?

export GRASS_CAIRO_READ=TRUE
export GRASS_CAIRO_MAPPED=TRUE
export GRASS_CAIROFILE=map.png

GRASS_CAIRO_MAPPED only works with BMP images, not any of the other formats. If the filename doesn't end in ".bmp", GRASS_CAIRO_MAPPED is silently ignored.

The file must have the correct size (width * height * 4 + HEADER_SIZE bytes).

in reply to: ↑ 6   Changed 3 years ago by hamish

  • cpu changed from x86-64 to All

Replying to epatton:

I have no way of testing on a 32-bit system.

ok, tried on 32-bit debian/lenny (stable). locks up, need to use xkill.

so both 32 and 64 bit, ubuntu and debian, grass 6.5 only.

do any non-.deb family users have cairo working with the wxGUI?

Hamish

  Changed 3 weeks ago by hamish

  • priority changed from normal to critical
  • component changed from Display to wxGUI
  • milestone changed from 6.5.0 to 6.4.3

ok, seems like two bugs,

[debian/squeeze on amd64, testing in both relbr64 and devbr6, cairo 1.10]

with GRASS_PNG_READ as in the example in comment:1, d.mon still crashes with,

G643svn> export GRASS_PNGFILE=map.bmp
G643svn> export GRASS_PNG_READ=TRUE
G643svn> d.mon -L
*** glibc detected *** status: free(): invalid pointer:
...
G643svn> echo $?
1

(as above)

If I touch map.bmp first then d.mon runs ok. So it either needs to test if the file exists and exit with an error, or test if it exists and skip trying to read it, or create it if it's missing. (maybe d.mon shouldn't be creating it..)

---

in the wxGUI preferences, after changing the Map Display -> Display driver to "cairo" I get this error in the command console:

Settings applied to current session but not saved                               
ERROR: Rendering failed. Details: File </tmp/tmpsF0WNE.ppm>
not found

however, there is an empty file in /tmp/ called tmpsF0WNE. (no .ppm)

?, Hamish

  Changed 6 days ago by hamish

the following patch against devbr6 changes the error message from "File <...> not found" to "ERROR: Rendering failed. Details: Error reading PPM file" (the file exists but is empty).

Index: gui/wxpython/core/render.py
===================================================================
--- gui/wxpython/core/render.py	(revision 56191)
+++ gui/wxpython/core/render.py	(working copy)
@@ -87,13 +87,14 @@
                         self.opacity, self.hidden))
         
         # generated file for each layer
-        self.gtemp = tempfile.mkstemp()[1]
-        self.maskfile = self.gtemp + ".pgm"
         if self.type == 'overlay':
-            self.mapfile  = self.gtemp + ".png"
+            tempfile_sfx =".png"
         else:
-            self.mapfile  = self.gtemp + ".ppm"
-        
+            tempfile_sfx =".ppm"
+        self.mapfile = tempfile.mkstemp(suffix = tempfile_sfx)[1]
+        # do we need to `touch` the maskfile so it exists?
+        self.maskfile = self.mapfile.rsplit(".",1)[0] + ".pgm"
+
     def __del__(self):
         Debug.msg (3, "Layer.__del__(): layer=%s, cmd='%s'" %
                    (self.name, self.GetCmd(string = True)))

shooting in the dark: I guess the error means that g.pnmcomp is trying to read from the existing GRASS_CAIROFILE before adding to it as GRASS_CAIRO_READ is set(?), or maybe the GRASS_RENDER_IMMEDIATE=TRUE is causing the PNG driver to be used instead?

(I notice GRASS_PNG_READ is referenced in a few places, but GRASS_CAIRO_READ is not at all)

Hamish

  Changed 5 days ago by hamish

I notice in wxpython/core/render.py sets GRASS_COMPRESSION=0, but that doesn't exist, GRASS_PNG_COMPRESSION does. Having that mis-set probably doesn't help rendering speed & cpu load any.

broken since forever; fixed in all branches.

wrt the tempfiles mentioned in comment:10, I wonder if we can at least mitigate the left-over-file problem (#560) by putting them in the GISRC tempdir with something like:

tempfile.mkstemp(suffix = '.ppm',
   prefix = os.path.basename(os.path.dirname(os.getenv('GISRC'))) + os.sep + 'tmp_')

(? is the GISRC enviro var reset in core/render.py there for the GCP tool, or..?)

Hamish

Note: See TracTickets for help on using tickets.