Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#4177 closed patch (fixed)

Building against PostgreSQL HEAD fails on Linux

Reported by: Laurenz Albe Owned by: pramsey
Priority: medium Milestone: PostGIS 2.4.6
Component: postgis Version: master
Keywords: Cc:

Description

When building PostGIS HEAD against PostgreSQL HEAD on Linux, I get this:

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -DWAL_DEBUG -O0 -ggdb -fno-omit-frame-pointer -fPIC -fPIC -I../liblwgeom -g -O2 -fno-math-errno -fno-signed-zeros -I../libpgcommon  -I/usr/include   -I/usr/include/libxml2 -I/usr/include -DHAVE_SFCGAL    -fPIC -I/usr/include -DHAVE_SFCGAL -I. -I./ -I/home/laurenz/pg/include/postgresql/server -I/home/laurenz/pg/include/postgresql/internal  -D_GNU_SOURCE -I/usr/include/libxml2   -c -o gserialized_estimate.o gserialized_estimate.c -MMD -MP -MF .deps/gserialized_estimate.Po
gserialized_estimate.c: In function ‘nd_box_array_distribution’:
gserialized_estimate.c:765:2: error: ISO C90 forbids variable length array ‘counts’ [-Werror=vla]
  int counts[num_bins];
  ^~~
cc1: some warnings being treated as errors

The problematic code is from this commit.

The new gcc flag was added to the PostgreSQL build process in this commit.

I have the impression that Paul Ramsey was thinking Java when he coded this.

The attached patch fixes the problem.

Attachments (2)

fix-build-for-postgresql-v12.patch (1.9 KB ) - added by Laurenz Albe 6 years ago.
more-fixes-for-build-with-PGv12.patch (15.6 KB ) - added by Laurenz Albe 6 years ago.

Download all attachments as: .zip

Change History (9)

by Laurenz Albe, 6 years ago

comment:1 by komzpa, 6 years ago

Resolution: fixed
Status: newclosed

In 16777:

Postgres 12 disallows variable length arrays in C

Patch by Laurenz Albe

Closes #4177

comment:2 by komzpa, 6 years ago

In 16778:

Postgres 12 disallows variable length arrays in C

Patch by Laurenz Albe

Closes #4177

by Laurenz Albe, 6 years ago

comment:3 by Laurenz Albe, 6 years ago

Resolution: fixed
Status: closedreopened

Unfortunalely I have found a couple more similar probleems; see the attached patch.

I only fixed what I encountered while building, I didn't check if there are more elsewhere.

comment:4 by komzpa, 6 years ago

The first patch applied on Travis made https://trac.osgeo.org/postgis/ticket/2985 reoccur almost always:

[logbt] saw 'make' exit with code:2 (INT)
[logbt] Found corefile (non-tracked) at /tmp/logbt-coredumps/core.1192.!usr!lib!postgresql!11!bin!postgres
[logbt] Processing cores...
[New LWP 1192]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `postgres: 11/main: travis postgis_reg [local] ANALYZE                         '.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

Thread 1 (Thread 0x7f4e9c8a8b00 (LWP 1192)):
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f4ea42a3535 in __GI_abort () at abort.c:79
#2  0x00007f4ea430a516 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f4ea442e9ee "*** %s ***: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007f4ea43ae431 in __GI___fortify_fail_abort (need_backtrace=need_backtrace@entry=false, msg=msg@entry=0x7f4ea442e9cc "stack smashing detected") at fortify_fail.c:33
#4  0x00007f4ea43ae3f2 in __stack_chk_fail () at stack_chk_fail.c:29
#5  0x00007f4e9291d8d8 in compute_gserialized_stats_mode (stats=stats@entry=0x562e82128780, fetchfunc=fetchfunc@entry=0x562e808c6970 <std_fetch_func>, sample_rows=sample_rows@entry=1, total_rows=total_rows@entry=1, mode=mode@entry=2) at gserialized_estimate.c:1755
#6  0x00007f4e9291d8fd in compute_gserialized_stats (stats=0x562e82128780, fetchfunc=0x562e808c6970 <std_fetch_func>, sample_rows=1, total_rows=1) at gserialized_estimate.c:1841
#7  0x0000562e808c9071 in do_analyze_rel (onerel=onerel@entry=0x562e8235d400, options=options@entry=2, params=params@entry=0x7ffd6d3e6fa0, va_cols=va_cols@entry=0x0, acquirefunc=<optimized out>, relpages=1, inh=false, in_outer_xact=false, elevel=13) at ./build/../src/backend/commands/analyze.c:579
#8  0x0000562e808ca6fc in analyze_rel (relid=18637, relation=0x562e81524738, options=options@entry=2, params=params@entry=0x7ffd6d3e6fa0, va_cols=0x0, in_outer_xact=<optimized out>, bstrategy=0x562e817ba610) at ./build/../src/backend/commands/analyze.c:310
#9  0x0000562e80938f25 in vacuum (options=2, relations=0x562e817ba770, params=params@entry=0x7ffd6d3e6fa0, bstrategy=<optimized out>, bstrategy@entry=0x0, isTopLevel=isTopLevel@entry=true) at ./build/../src/backend/commands/vacuum.c:357
#10 0x0000562e80939290 in ExecVacuum (vacstmt=vacstmt@entry=0x562e81524808, isTopLevel=isTopLevel@entry=true) at ./build/../src/backend/commands/vacuum.c:141
#11 0x0000562e80a9ea60 in standard_ProcessUtility (pstmt=0x562e815248a8, queryString=0x562e81523d40 "ANALYZE test_analyze_crash;", context=<optimized out>, params=0x0, queryEnv=0x0, dest=0x562e81524b68, completionTag=0x7ffd6d3e72e0 "") at ./build/../src/backend/tcop/utility.c:667
#12 0x0000562e80a9b6e9 in PortalRunUtility (portal=0x562e815a9880, pstmt=0x562e815248a8, isTopLevel=<optimized out>, setHoldSnapshot=<optimized out>, dest=<optimized out>, completionTag=0x7ffd6d3e72e0 "") at ./build/../src/backend/tcop/pquery.c:1178
#13 0x0000562e80a9c1e7 in PortalRunMulti (portal=portal@entry=0x562e815a9880, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x562e81524b68, altdest=altdest@entry=0x562e81524b68, completionTag=completionTag@entry=0x7ffd6d3e72e0 "") at ./build/../src/backend/tcop/pquery.c:1331
#14 0x0000562e80a9ce8e in PortalRun (portal=portal@entry=0x562e815a9880, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x562e81524b68, altdest=altdest@entry=0x562e81524b68, completionTag=0x7ffd6d3e72e0 "") at ./build/../src/backend/tcop/pquery.c:799
#15 0x0000562e80a98b27 in exec_simple_query (query_string=0x562e81523d40 "ANALYZE test_analyze_crash;") at ./build/../src/backend/tcop/postgres.c:1122
#16 0x0000562e80a9ab36 in PostgresMain (argc=<optimized out>, argv=argv@entry=0x562e8156de78, dbname=<optimized out>, username=<optimized out>) at ./build/../src/backend/tcop/postgres.c:4153
#17 0x0000562e80a25bed in BackendRun (port=0x562e81567250) at ./build/../src/backend/postmaster/postmaster.c:4361
#18 BackendStartup (port=0x562e81567250) at ./build/../src/backend/postmaster/postmaster.c:4033
#19 ServerLoop () at ./build/../src/backend/postmaster/postmaster.c:1706
#20 0x0000562e80a26c2f in PostmasterMain (argc=5, argv=0x562e8151e870) at ./build/../src/backend/postmaster/postmaster.c:1379
#21 0x0000562e807b3cdb in main (argc=5, argv=0x562e8151e870) at ./build/../src/backend/main/main.c:228

travis_time:end:1c2705c6:start=1536850966762588593,finish=1536851027772766991,duration=61010178398
[0K
[31;1mThe command "logbt -- make check "RUNTESTFLAGS=--verbose"" exited with 2.[0m

comment:5 by komzpa, 6 years ago

Resolution: fixed
Status: reopenedclosed

In 16779:

Postgres 12 disallows variable length arrays in C, raster part

Patch by Laurenz Albe

Closes #4177

comment:6 by komzpa, 6 years ago

In 16780:

Postgres 12 disallows variable length arrays in C, raster part

Patch by Laurenz Albe

Closes #4177

comment:7 by pramsey, 6 years ago

In 16971:

Remove use of variable length arrays
References #4177

Note: See TracTickets for help on using tickets.