Opened 14 years ago

Closed 13 years ago

#465 closed defect (wontfix)

st_makevalid segfault

Reported by: pramsey Owned by: strk
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: master
Keywords: osx, opensuse Cc:

Description

In OS/X 10.5, running caseno == 3 result in a backend crash, though not, curiously before it has a change to return a result…?

	 1: st_astext = "MULTIPOLYGON(((2 4,2 6,4 4,2 4)),((4 4,6 6,6 4,4 4)))"(typeid = 25, len = -1, typmod = -1, byval = f)
	----

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x00000001039b3a74 in geos::geom::GeometryCollection::apply_ro () at atomicity.h:51
51	  { return __sync_fetch_and_add(__mem, __val); }
(gdb) bt
#0  0x00000001039b3a74 in geos::geom::GeometryCollection::apply_ro () at atomicity.h:51
#1  0x00000001039b3a80 in geos::geom::GeometryCollection::apply_ro () at atomicity.h:51
#2  0x0000000100746c30 in GEOSGeom_extractUniquePoints_r (extHandle=0x100604b80, g=0x100604c60) at geos_ts_c.cpp:4784
#3  0x0000000103693919 in lwgeom_make_valid (lwgeom_in=0x100908530) at lwgeom_geos_clean.c:766
#4  0x0000000103693e00 in ST_MakeValid (fcinfo=0x7fff5fbfe810) at lwgeom_geos_clean.c:913
#5  0x0000000100111201 in ExecMakeFunctionResultNoSets (fcache=0x1008f81c8, econtext=0x1008f7c80, isNull=0x7fff5fbfef50 "\006", isDone=0x7fff5fbfeb51) at execQual.c:1412
#6  0x0000000100111172 in ExecMakeFunctionResultNoSets (fcache=0x1008f7db0, econtext=0x1008f7c80, isNull=0x1008f9250 "", isDone=<value temporarily unavailable, due to optimizations>) at execQual.c:1387
#7  0x000000010010cadf in ExecTargetList [inlined] () at /Users/pramsey/Code/postgresql-8.3.8/src/backend/executor/execQual.c:4610
#8  0x000000010010cadf in ExecProject (projInfo=<value temporarily unavailable, due to optimizations>, isDone=0x7fff5fbff0ac) at execQual.c:4811
#9  0x0000000100113cef in ExecScan (node=0x1008f7b68, accessMtd=0x100121260 <SeqNext>) at execScan.c:143
#10 0x000000010010c4f2 in ExecProcNode (node=0x1008f7b68) at execProcnode.c:334
#11 0x000000010010b21c in ExecutePlan [inlined] () at /Users/pramsey/Code/postgresql-8.3.8/src/backend/executor/execMain.c:1335
#12 0x000000010010b21c in ExecutorRun (queryDesc=<value temporarily unavailable, due to optimizations>, direction=ForwardScanDirection, count=0) at execMain.c:270
#13 0x00000001001bee79 in PortalRunSelect (portal=0x1008f5838, forward=<value temporarily unavailable, due to optimizations>, count=0, dest=0x1003d24a0) at pquery.c:943
#14 0x00000001001c09af in PortalRun (portal=0x1008f5838, count=9223372036854775807, isTopLevel=1 '\001', dest=0x1003d24a0, altdest=0x1003d24a0, completionTag=0x7fff5fbff460 "") at pquery.c:769
#15 0x00000001001bb5ca in exec_simple_query (query_string=0x1008c0438 "select st_astext(st_makevalid(orig)) from clean_cases where caseno = 3;\n") at postgres.c:1004
#16 0x00000001001bc861 in PostgresMain (argc=1, argv=0x1006004f8, username=0x1006011d0 "pramsey") at postgres.c:3631
#17 0x00000001001317ae in main (argc=3, argv=0x1006004f0) at main.c:186
Current language:  auto; currently c++

SQL was

select st_astext(st_makevalid(orig)) from clean_cases where caseno = 3;

Attachments (3)

makecheckvalgrind.log (155.1 KB ) - added by robe 14 years ago.
strk, Not sure I did this valgrind thing right. Attached is what I get if I do a valgrind —leak-check=full —show-reachable=yes -v make check 2>&1 | tee build.log
valgrind.log (11.7 KB ) - added by robe 14 years ago.
after single user mode
valgrind_case3.log (33.1 KB ) - added by robe 14 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 by strk, 14 years ago

Any chance to get a valgrind log ? My run of that is valgrind clean, with current GEOS code (2937).

comment:2 by strk, 14 years ago

bts, line 766 of lwgeom_geos_clean.c isn't the ST_MakeValid call, could it be you'll need an update/rebuild ?

comment:3 by pramsey, 14 years ago

No, after the crash I was careful to update/clean/build both PostGIS and GEOS because i know we have a moving target right now.

comment:4 by robe, 14 years ago

Keywords: opensuse added

I'm not sure if this is the same as my issue, but I finally successfully built on my Open SUSE 10.3 and got thru the make checks, but it crashes on the clean test.

I'm running PostGIS trunk and GEOS 3.3 and all pass until the last test the clean tests — output of the error file looks like below

! RT|13.1|t|t|t
! RT|13.2|t|t|f
! RT|14|t|t|f
! RT|15|t|t|f
! RT|16.1|t|t|f
! RT|16.2|t|t|f
! RT|16.3|t|t|f
! RT|16.4|t|t|f
! RT|17.1|t|t|f
! PG|1|t|t|f
! PG|2|t|t|f
! PG|3|t|t|f
! SRID1|3
! SRID2|3
! SRID3|3
--- 1,4 ----
! server closed the connection unexpectedly
!       This probably means the server terminated abnormally
!       before or while processing the request.
! connection to server was lost

comment:5 by robe, 14 years ago

Forgot to add this was testing against PostgreSQL 8.3

comment:6 by strk, 14 years ago

Robe, any way to get a backtrace or even better a valgrind report ?

by robe, 14 years ago

Attachment: makecheckvalgrind.log added

strk, Not sure I did this valgrind thing right. Attached is what I get if I do a valgrind —leak-check=full —show-reachable=yes -v make check 2>&1 | tee build.log

comment:7 by robe, 14 years ago

strk,

See attached file

comment:8 by strk, 14 years ago

@pramsey: are you on pgsql 8.3 too ? @robe: that's not what I had in mind for a valgrind log. It's harder than it looks as you should have valgrind only run the single-user postgres feeding it the clean.sql file

comment:9 by strk, 14 years ago

Also, have you guys succeeded at running 'make check' for geos ?

comment:10 by robe, 14 years ago

My make check for geos worked fine. All tests pass.

I'll fiddle some more with valgrind.

comment:11 by robe, 14 years ago

strk,

I tried to follow Paul's instructions here http://blog.cleverelephant.ca/2008_08_01_archive.html

But having a bit of difficulty — mostly cause I don't know what I am doing.

I did this: cat clean.sql | valgrind —leak-check=yes —log-file=valgrind.log /opt/PostgreSQL/8.3/bin/postgres —single -D /opt/PostgreSQL/8.3/data -p 5433 postgis

But I guess cat is not the right command because I get a lot of syntax errors.

The output of the valgrind is attached.

by robe, 14 years ago

Attachment: valgrind.log added

after single user mode

comment:12 by robe, 14 years ago

strk,

And for your info. Evidentally Paul is running 8.3 too if you look at his gdb output up there he is running 8.3.8. What's odd now is that mine is not crashing after I recompiled GEOS and PostGIS with CFLAGS="-g -O0". But I am getting 2 regression failures now

One on measures and one on clean.

*** clean_expected      Fri Mar 19 06:39:05 2010
--- /tmp/pgis_reg_15331/test_50_out     Tue Mar 30 16:09:35 2010
***************
*** 1,3 ****
--- 1,5 ----
+ NOTICE:  Vertices lost in LWGEOM_GEOS_makeValid
+ NOTICE:  Vertices lost in LWGEOM_GEOS_makeValid
  RT|1|t|t|f
  RT|2|t|t|f
  RT|3|t|t|f
***************
*** 23,29 ****
  RT|17.1|t|t|f
  PG|1|t|t|f
  PG|2|t|t|f
! PG|3|t|t|f
  SRID1|3
  SRID2|3
  SRID3|3
--- 25,31 ----

I first installed the clean.sql in my postgis db and then ran that single command Paul had above

echo "select st_astext(st_makevalid(orig)) from clean_cases where caseno = 3;" | valgrind --leak-check=yes --log-file=valgrind.log /opt/PostgreSQL/8.3/bin/postgres --single -D /opt/PostgreSQL/8.3/data -p 5433 postgis

Doesn't crash — but valgrind gives See next attached file. Its all greek to me.

by robe, 14 years ago

Attachment: valgrind_case3.log added

comment:13 by strk, 14 years ago

robe, the valgrind log is good, but you need to build both GEOS and POSTGIS with debugging symbols (-g switch if using gcc).

comment:14 by strk, 13 years ago

I still can't reproduce this one (with postgresql 8.4 on 64bit) A valgrind log with debugging info in postgis might help moving further

comment:15 by robe, 13 years ago

is this still an issue?

comment:16 by robe, 13 years ago

Resolution: wontfix
Status: newclosed

I'm going to close this one out, because the OpenSUSE I had issue with this on is long gone and too anscient to test anyway since it was on 8.2 or 8.3

Note: See TracTickets for help on using tickets.