Giter Site home page Giter Site logo

cgo runtime panic about gogeos HOT 5 OPEN

paulsmith avatar paulsmith commented on August 16, 2024
cgo runtime panic

from gogeos.

Comments (5)

compiledpanda avatar compiledpanda commented on August 16, 2024

Environment:
Mac OSX Mavericks
I have geos installed via brew, version 3.4.2

uname -a
Darwin johns-mbp.home 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64

from gogeos.

compiledpanda avatar compiledpanda commented on August 16, 2024

Looks like it is being caused by point, err := shell.Point(j), whic sometimes returns the error Argument is not a LineString

from gogeos.

paulsmith avatar paulsmith commented on August 16, 2024

I can't recreate this, though I only have go 1.4 and the development version (pre-1.5) installed at the moment.

Looks like it might be a race condition with the finalizers being called during a gc.

from gogeos.

paulsmith avatar paulsmith commented on August 16, 2024

And now I am able to recreate it using the -race flag.

from gogeos.

Kooper avatar Kooper commented on August 16, 2024

Hello,

I observed the same problem, on very similar code:

shape, _ := geos.FromWKT(wkt)
box, _ := shape.Envelope()
boundingLine, _ := box.Shell()
geosCoordinates, _ := boundingLine.Coords()

for _, val := range geosCoordinates {
    coordinates = append(coordinates, s2.LatLngFromDegrees(val.X, val.Y))
}

Which produces SIGSEGV under heavy load (10 goroutines, database queries, millions of WKT strings). The typical stacktrace was:

[signal 0xb code=0x80 addr=0x0 pc=0x7f726b9f0375]

runtime stack:
runtime.throw(0xa52ae0, 0x2a)
        /usr/lib/go-1.6/src/runtime/panic.go:547 +0x90
runtime.sigpanic()
        /usr/lib/go-1.6/src/runtime/sigpanic_unix.go:12 +0x5a

goroutine 103 [syscall, locked to thread]:
runtime.cgocall(0x834dd0, 0xc82013b5b0, 0xc800000000)
        /usr/lib/go-1.6/src/runtime/cgocall.go:123 +0x11b fp=0xc82013b560 sp=0xc82013b530
.../vendor/github.com/paulsmith/gogeos/geos._Cfunc_GEOSCoordSeq_getY_r(0x28ae900, 0x7f7238010030, 0x1, 0xc8202700d0, 0x0)
        .../vendor/github.com/paulsmith/gogeos/geos/_obj/_cgo_gotypes.go:418 +0x41 fp=0xc82013b5b0 sp=0xc82013b560
.../vendor/github.com/paulsmith/gogeos/geos.cGEOSCoordSeq_getY(0x7f7238010030, 0xc800000001, 0xc8202700d0, 0xc800000000)
        .../vendor/github.com/paulsmith/gogeos/geos/cwrappers.go:139 +0x132 fp=0xc82013b610 sp=0xc82013b5b0
.../vendor/github.com/paulsmith/gogeos/geos.(*coordSeq).y(0xc82013b710, 0x1, 0xc114d7e68f5c28f6, 0x0, 0x0)
        .../vendor/github.com/paulsmith/gogeos/geos/coordseq.go:93 +0x61 fp=0xc82013b640 sp=0xc82013b610
.../vendor/github.com/paulsmith/gogeos/geos.coordSlice(0xc82013b710, 0x0, 0x0, 0x0, 0x0, 0x0)
        .../vendor/github.com/paulsmith/gogeos/geos/coord.go:34 +0x191 fp=0xc82013b6e0 sp=0xc82013b640
.../vendor/github.com/paulsmith/gogeos/geos.(*Geometry).Coords(0xc8202b2fd8, 0x0, 0x0, 0x0, 0x0, 0x0)
        .../vendor/github.com/paulsmith/gogeos/geos/geom.go:760 +0x97 fp=0xc82013b720 sp=0xc82013b6e0

As far as I can tell it is an attempt to dereference invalid pointer in C function GEOSCoordSeq_getY_r. Sometimes it was from GEOSCoordSeq_getX_r, several errors were from 'size'-functions. But it is always pointer dereference problem during geos.Coords() call.

As otherwise structures are correct (and I can't reproduce bug if no concurrency involved) my guess was garbage collector, which comes in between calls to geos.FromWKT(wkt)/shape.Envelope()/box.Shell()/boundingLine.Coords() and frees geometries involved in geos.Coords() computations.

To workaround the problem I added silly code to hold variables until after geos.Coords()

geosCoordinates, _ := boundingLine.Coords()
if nil != err {
    log.Printf("%d %d %d", shape, box, boundingLine)
}

Surprisingly this worked well. However I would like to see a correct solution to the pointer ownership problem.

from gogeos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.