Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

geom: avoid racing with GC when calling Coords() on shell/hole #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pmezard
Copy link

@pmezard pmezard commented Jan 10, 2017

The problem is twofold:

  • In Geometry.Coords() we have to make sure the parent Geometry outlives
    the processing of the coordinates array.
  • The previous condition is not enough when the geometry comes from
    Shell() or Holes(), which return internal objects. We have to make
    sure the shell/hole parent geometry outlives the shell/hole instance.

The fix is similar to the one suggested in #11. There are probably a lot
of places where either previous conditions are required, I have not
checked all the code.

Note: this change the minimum required Go version to 1.7. I tried to
play build tag games to have empty versions of the runtime.KeepAlive
call, and failed.

Fixes #8

The problem is twofold:
- In Geometry.Coords() we have to make sure the parent Geometry outlives
  the processing of the coordinates array.
- The previous condition is not enough when the geometry comes from
  Shell() or Holes(), which return internal objects. We have to make
  sure the shell/hole parent geometry outlives the shell/hole instance.

The fix is similar to the one suggested in paulsmith#11. There are probably a lot
of places where either previous conditions are required, I have not
checked all the code.

Note: this change the minimum required Go version to 1.7. I tried to
play build tag games to have empty versions of the runtime.KeepAlive
call, and failed.

Fixes paulsmith#8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cgo runtime panic
1 participant