Opened 6 years ago

Closed 5 years ago

#4383 closed defect (fixed)

Sanitizer warnings

Reported by: Algunenano Owned by: Algunenano
Priority: medium Milestone: PostGIS 3.0.0
Component: postgis Version: master
Keywords: Cc:

Description

While investigating #4381 I've come up with a bunch of warnings from using different sanitizers from the ones we have already setup in Travis.

There are both memory issues (mostly false positives) as implicit integer conversions that might mean a change in value.

WIP in https://github.com/postgis/postgis/pull/395 but I might push commits individually for clarity and only backport those where I'm positive it can be an issue.

Change History (6)

comment:1 by Algunenano, 6 years ago

Owner: changed from pramsey to Algunenano

comment:2 by algunenano, 6 years ago

In 17411:

Fix several issues when building cunit tests

  • loader cunit: Add missing $(CFLAGS) to the main binary
  • liblwgeom cunit: Avoid link issues with some sanitizers

References #4383

comment:3 by algunenano, 6 years ago

In 17412:

lwout_wkb.c: Address implicit type conversion with value change

lwout_wkb.c:288:16: runtime error: implicit conversion from type 'char' of value -16 (8-bit, signed) to type 'uint8_t' (aka 'unsigned char') changed the value to 240 (8-bit, unsigned)
lwout_wkb.c:654:27: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 2147483663 (32-bit, unsigned) to type 'int' changed the value to -2147483633 (32-bit, signed)
lwout_wkb.c:213:16: runtime error: implicit conversion from type 'char' of value -128 (8-bit, signed) to type 'uint8_t' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
lwout_wkb.c:607:27: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 2147483651 (32-bit, unsigned) to type 'int' changed the value to -2147483645 (32-bit, signed)

References #4383

comment:4 by algunenano, 6 years ago

In 17413:

lwout_twkb.c: Address implicit type conversion with value change

lwout_twkb.c:170:9: runtime error: implicit conversion from type 'long long' of value 10000000000 (64-bit, signed) to type 'int' changed the value to 1410065408 (32-bit, signed)

References #4383

comment:5 by algunenano, 6 years ago

In 17414:

Multiple fixes for undefined behaviour in implicit conversions

shp2pgsql-core.c:839:22: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'DBFFieldType' changed the value to 4294967295 (32-bit, unsigned)

runtime error: implicit conversion from type 'int32' (aka 'int') of value -1 (32-bit, signed) to type 'uint32' (aka 'unsigned int') changed the value to 4294967295 (32-bit, unsigned)
UndefinedBehaviorSanitizer: undefined-behavior lwgeom_functions_basic.c:2237:10 in

runtime error: implicit conversion from type 'unsigned int' of value 4294967295 (32-bit, unsigned) to type 'int' changed the value to -1 (32-bit, signed)
UndefinedBehaviorSanitizer: undefined-behavior ptarray.c:333:13 in

runtime error: implicit conversion from type 'unsigned int' of value 4294967295 (32-bit, unsigned) to type 'int' changed the value to -1 (32-bit, signed)
UndefinedBehaviorSanitizer: undefined-behavior ptarray.c:333:13 in

References #4383

comment:6 by algunenano, 5 years ago

Resolution: fixed
Status: newclosed

In 17480:

Fix undefined behaviour in implicit conversions

Cleans up errors in raster and topology and adds an
extra sanitizer build in Travis

Closes #4383
Closes https://github.com/postgis/postgis/pull/398

Note: See TracTickets for help on using tickets.