Changes between Initial Version and Version 2 of Ticket #81
- Timestamp:
- Dec 22, 2007, 1:31:18 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #81
- Property Reporter changed from to
- Property Priority 5 → major
- Property Version 3.0.0 → svn-trunk
- Property Milestone imported → 3.0.0
- Property Resolution none → fixed
-
Ticket #81 – Description
initial v2 1 Today, when I was woring on Unit Tests I found a pretty serious bug causing memory access violation error. Here is the story: 1 2 {{{ 2 Today, when I was woring on Unit Tests I found a pretty serious bug causing memory access violation error. Here is the story:3 4 3 // Factory object preparation 5 4 const int srid = 1; … … 12 11 // ring is empty, but let's see what will happen 13 12 PointPtr x = ring->getStartPoint(); <--- BUM! 13 }}} 14 14 15 15 The line marked with BUM! causes memory access violation error. … … 17 17 Here is descriptive backtrace with complete call chain (lines marked with <--- are executed during step-by-step debugging): 18 18 19 1.20 19 1. 20 {{{ 21 21 PointPtr x = ring->getStartPoint(); <--- 22 23 1.1.24 22 }}} 23 1.1. 24 {{{ 25 25 Point* LineString::getStartPoint() const { 26 26 if (isEmpty()) { … … 29 29 return getPointN(0); 30 30 } 31 }}} 32 2. 33 {{{ 34 Point(NULL, NULL); <--- 35 }}} 31 36 32 2. Point(NULL, NULL); <--- 37 Parameters: 38 * newCoord = NULL 39 * factory = NULL 33 40 34 Parameters: 35 newCoord = NULL 36 factory = NULL 37 38 2.1. 39 41 2.1. 42 {{{ 40 43 Point::Point(CoordinateSequence *newCoords, const GeometryFactory *factory) 41 44 : Geometry(factory) <--- … … 43 46 //... 44 47 } 48 }}} 45 49 46 3.47 50 3. 51 {{{ 48 52 Geometry(factory) 49 53 50 54 factory = NULL 55 }}} 51 56 52 3.1.53 57 3.1. 58 {{{ 54 59 Geometry::Geometry(const GeometryFactory* newFactory) 55 60 { … … 59 64 userData=NULL; 60 65 } 66 }}} 61 67 62 [1] 63 newFactory = NULL, so factory gets becomes null pointer 68 * (1) newFactory = NULL, so factory gets becomes null pointer 64 69 65 [2] BUUUM! 66 factory is a null pointer and calling member on a null pointer value causes undefined behaviour! 70 * (2) BUUUM! factory is a null pointer and calling member on a null pointer value causes undefined behaviour! 67 71 72 {{{ 68 73 SRID=factory->getSRID(); 74 }}} 69 75 70 4. Finally, GeometryFactory::getSRID() throws 71 MEMORY ACCESS VIOLATION ERROR! 76 4. Finally, GeometryFactory::getSRID() throws '''memory access violation error''' 72 77 73 78 74 79 Summary: 75 -the Geometry constructor is used incorrectly76 -or this constructor is incorrectly designed to handle all valid cases77 - This is another example of ***JAVISMS***.80 * the Geometry constructor is used incorrectly 81 * or this constructor is incorrectly designed to handle all valid cases 82 * This is another example of ''JAVISMS''. 78 83 79 84 JTS version of getStartPoint is defined as follows: 80 85 86 {{{ 81 87 public Point getStartPoint() { 82 88 if (isEmpty()) { … … 85 91 return getPointN(0); 86 92 } 93 }}} 87 94 88 [3] returning null reference is completely different semantic of returning pointer to newly allocated object, what happens in GEOS' version of getStartPoint!!! 95 * (3) returning null reference is completely different semantic of returning pointer to newly allocated object, what happens in GEOS' version of getStartPoint! 89 96 90 97 GEOS' version of getStartPoint is buggy in two ways: 91 1. Causes memory access violation 92 2. There is logical bug: how can user expect to get Point object returned from *empty* LinearRing??? Such behaviour does not make sense. 93 It's also, what is most important, incompatible behaviour with that in JTS version!98 99 1. Causes memory access violation 100 2. There is logical bug: how can user expect to get Point object returned from *empty* LinearRing??? Such behaviour does not make sense. It's also, what is most important, incompatible behaviour with that in JTS version! 94 101 95 102 I'm quite confused and I'm really affraid of possible bugs hidding in GEOS. Please, discuss it in details and let's make this software stable! 96 }}}