dazuma/rgeo — Issue #21: segmentation fault in intersection
Author: ghazel
Created: 2012-02-02 11:28:57+00:00
State: open

I know the projection is mismatched, but a segfault seems extreme:

```ruby
require 'rgeo'
f = RGeo::Geographic.simple_mercator_factory
loc = f.line_string([f.point(-123, 37), f.point(-122, 38)])
f2 = f.projection_factory
loc2 = f2.line_string([f2.point(-123, 37), f2.point(-122, 38)])
p loc.envelope.intersection(loc2.envelope)
p loc2.envelope.intersection(loc.envelope)
```

produces:

```
#
rgeo_bug.rb:7: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-linux]

Aborted
```

gdb says:

```gdb
(gdb) bt
#0 0x004e5f20 in rgeo_convert_to_geos_geometry (factory=3085063400, obj=3085036880, type=4) at factory.c:361
#1 0x004e4b46 in method_geometry_intersection (self=3085062080, rhs=3085036880) at geometry.c:660
#2 0x00159a6c in call_cfunc (func=0x4e4b05 , recv=, len=1, argc=1, argv=0xbfffeb10) at eval.c:5784
#3 0x00164850 in rb_call0 (klass=3086034680, recv=3085062080, id=20161, oid=20161, argc=1, argv=0xbfffeb10, body=0xb7f1176c, flags=0) at eval.c:5928
#4 0x001649e5 in rb_call (klass=3086034680, recv=3085062080, mid=20161, argc=1, argv=0xbfffeb10, scope=0, self=) at eval.c:6176
#5 0x00161e23 in rb_eval (self=3086960980, n=0xb7ea1408) at eval.c:3506
#6 0x0015f5cb in rb_eval (self=3086960980, n=0xb7ea13e0) at eval.c:3516
#7 0x00170214 in ruby_exec_internal () at eval.c:1654
#8 0x00170254 in ruby_exec () at eval.c:1674
#9 0x00170289 in ruby_run () at eval.c:1684
#10 0x08048655 in main (argc=2, argv=0xbffff614, envp=0xbffff620) at main.c:48
```

rgeo-0.3.2, libgeos-3.3.1