Bug report #5067

QGIS crashes on Linux when adding MySQL layers

Added by Liam Veitch over 12 years ago. Updated about 9 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Data Provider/OGR
Affected QGIS version:master Regression?:No
Operating System:Linux Easy fix?:No
Pull Request or Patch supplied:No Resolution:not reproducable
Crashes QGIS or corrupts data:Yes Copied to github as #:14834

Description

Modifications to attributes or geometry on MySQL layers are not commited to the database. This occurs using the QGIS UI and also when using python. No error messages are generated in either system.

Within python, provider.changeAttributeValues() returns true, however values do not change in the database. The provider.capabilityString() also returns 'Add Features, Delete Features, Change Attribute Values, Change Geometries'.

History

#1 Updated by Giovanni Manghi over 12 years ago

  • Status changed from Open to Feedback
  • Priority changed from High to Normal

How do you connect to mysql, ODBC?

#2 Updated by Liam Veitch over 12 years ago

Using the OGR provider (Add Vector Layer) and specifying MySQL database and entering in the parameters of the connection, I'm not using ODBC but I can try this as a workaround to determine the source of the issue.

#3 Updated by Jürgen Fischer over 12 years ago

  • Status changed from Feedback to Open

#4 Updated by Paolo Cavallini about 12 years ago

  • Target version set to Version 2.0.0

#5 Updated by Vaclav Cermak over 10 years ago

  • Target version changed from Version 2.0.0 to Version 2.2

Same problem here with 2.2.0. Also, vector layer from database is often not displayed at all and zoom to extent not working. When I try to save layer from db to ESRI shapefile and attach saved file, all geometry (points in my case) is displayed correctly and zoom to layer extent works fine.

#6 Updated by Jürgen Fischer over 10 years ago

  • Category set to Data Provider/OGR

#7 Updated by Jürgen Fischer over 10 years ago

  • Target version changed from Version 2.2 to Future Release - Lower Priority

#8 Updated by D. Hiepler about 10 years ago

I experience the same issue. Layers loaded via OGR/MySQL don't get drawn.

To reproduce:

  • create mysql db:
     echo "CREATE DATABASE qgis_test;" | mysql -u dbuser -p dbpass
    
  • import shapefile:
     wget http://data.biogeo.ucdavis.edu/data/gadm2/shp/AFG_adm.zip
     unzip -d /tmp/qgistest AFG_adm.zip
     ogr2ogr -f MySQL MySQL:qgis_test,user=dbuser,password='dbpass' /tmp/qgistest/AFG_adm2.shp -nln AFG_adm2 -update -overwrite -lco SPATIAL_INDEX=YES -lco engine=MYISAM -progress -gt 65535
    
  • add vector layer in QGIS:
    • Layer -> Add -> Vector
      • Source: Database, Encoding: System
      • Database type: MySQL
      • add/select connection
      • Open

The layer seems to import correctly, but it isn't drawn. Loading the shapefile directly works as expected.

#9 Updated by Giovanni Manghi about 10 years ago

  • Status changed from Open to Feedback
  • Crashes QGIS or corrupts data changed from No to Yes
  • Operating System set to Linux
  • Target version deleted (Future Release - Lower Priority)
  • Priority changed from Normal to High
  • Subject changed from Editing MySQL layer attribute or geometry fails to QGIS crashes on Linux when adding MySQL layers

I have set up mysql in my linux (ubuntu) box and added the suggested layer.

I then added this layer using qgis 2.4/master on Windows, and it works everything as expected, including editing. So the original issue seems to me that is no longer valid.

Anyway I tested also qgis 2.4/master as client, and in this case I can add the layer, but qgis then immediately crashes:

QGIS died on signal 11Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No thread selected
No stack.
gdb returned 0
Aborted

#10 Updated by Jürgen Fischer about 10 years ago

Giovanni Manghi wrote:

I have set up mysql in my linux (ubuntu) box and added the suggested layer.

I then added this layer using qgis 2.4/master on Windows, and it works everything as expected, including editing. So the original issue seems to me that is no longer valid.

Anyway I tested also qgis 2.4/master as client, and in this case I can add the layer, but qgis then immediately crashes:

QGIS died on signal 11Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No thread selected
No stack.
gdb returned 0
Aborted

Master works fine from Linux and Windows here.

BTW please change kernel.yama.ptrace_scope to 0 in /etc/sysctl.d/10-ptrace.conf (or /etc/sysctl.conf) and run sysctl -p to enable backtraces...

#11 Updated by D. Hiepler about 10 years ago

  • Target version set to Future Release - Lower Priority

#12 Updated by D. Hiepler about 10 years ago

I forgot to mention the QGIS version: I tried master cc5d3bc (I don't get a crash)
MariaDB: 10.0.14 and 5.5.39
GDAL: 1.11.1

I'm beginning to think that this is an OGR error (caused by some mysql/mariadb incompatibility?) ...
OGR_L_GetNextFeature() returns not a single feature for mysql layers but all features for ESRI Shapefile layers.

#13 Updated by D. Hiepler about 10 years ago

I nailed it down to gdal/ogr/ogrsf_frmts/mysql/ogrmysqltablelayer.cpp: OGRMySQLTableLayer::BuildWhere() for my case...

there, the query

SELECT `OGR_FID`, `SHAPE` `SHAPE`, `id_0`, `iso`, `name_0`, `id_1`, `name_1`, `id_2`, `name_2`, `varname_2`, `nl_name_2`, `hasc_2`, `cc_2`, `type_2`, `engtype_2`, `validfr_2`, `validto_2`, `remarks_2`, `shape_leng`, `shape_area` FROM `claims` WHERE MBRIntersects(GeomFromText('POLYGON((60,1451354699999996 29,0025819600000005, 75,2538595299999997 29,0025819600000005, 75,2538595299999997 38,8499150399999991, 60,1451354699999996 38,8499150399999991, 60,1451354699999996 29,0025819600000005))'), `SHAPE`);
is used to get all features that intersect with the displayed area.

Notice the ',' decimal separators which are caused by an snprintf() in line 422 respecting my locale. If I start QGIS with

# LC_NUMERIC="C" qgis

everything works as expected.

EDIT: I wonder why there are so many setlocale()s in the code (gdal & QGIS).
LC_NUMERIC is quite often set to "C" and back to the current locale. Is there a reason why LC_NUMERIC isn't kept "C"? Do users expect their local representation in the GUI?
Leaving LC_NUMERIC="C" globally would squash the whole bug class (and save quite some setlocale() calls ;)

#14 Updated by Giovanni Manghi over 9 years ago

please tr y the latest master and report back, there have been big commits that also are affecting improvements with mysql.

#15 Updated by Giovanni Manghi about 9 years ago

  • Resolution set to not reproducable
  • Status changed from Feedback to Closed

Closing for lack of feedback. Reopen if necessary.

Also available in: Atom PDF