1. 28 May, 2015 1 commit
    • Kevin Modzelewski's avatar
      Update isValidGCObject to check the allocation kind · d48961f6
      Kevin Modzelewski authored
      ie make sure both that it's a valid allocation, but also that
      it will have Python destructor semantics applied when it is freed
      (as opposed to, say, STLCompatAllocator-allocated memory).
      
      This is to make sure that extension modules don't use a different
      allocation routine than we expected.
      
      There are only a few specialized places that I could find that we
      actually want the old-behavior; in dump(), and in PyObject_Init right
      before we call setIsPythonObject.  So for those cases, add a new
      isValidGCMemory call that doesn't do the allocation-kind check.
      d48961f6
  2. 27 May, 2015 6 commits
    • Kevin Modzelewski's avatar
      Switch to CPython's format for PyCFunctionObject · cb7533ae
      Kevin Modzelewski authored
      We were using a slightly different (flattened) version; not sure why.
      cb7533ae
    • Kevin Modzelewski's avatar
      Switch to CPython's implementation of thread._local · f2b5a640
      Kevin Modzelewski authored
      CPython's implementation has quite a bit more features than our
      old one.  We only particularly need one of them (call __init__
      when accessed from a new thread), but it looks like there are
      some other features in there that have a decent chance of biting
      us in annoying ways (some gc-related stuff).
      
      That implementation forced some of the other work in this PR, of
      supporting weakrefs on extension objects (which this uses), and
      making object.tp_init get set the same way it does in CPython.
      f2b5a640
    • Kevin Modzelewski's avatar
      Debugging helper: invalidate freed objects · 6fa582e4
      Kevin Modzelewski authored
      Without this, one could use freed objects without issues,
      until something else was allocated in that space.  And even then,
      it would still be a valid object.
      
      So, in debug mode overwrite the data with garbage to try to surface
      these issues.
      
      This exposed an issue with our "nonheap roots" handling, where we
      weren't scanning all of the memory that they pointed to.  This is
      mostly fine, but there are some cases (time.gmtime) where gc-allocated
      memory would be stored in these objects.  So, now you have to register
      the size of the object, and the memory range will be scanned conservatively.
      6fa582e4
    • Kevin Modzelewski's avatar
      3e8f2520
    • Kevin Modzelewski's avatar
      Check destructors and weakrefs for extension objects · 0c0a7da1
      Kevin Modzelewski authored
      Add a new allocation type CONSERVATIVE_PYTHON for extensions objects, for which
      we don't have heap maps, but should still have Python finalization semantics
      (ie destructors and weakrefs).  Previously we were just marking them as
      CONSERVATIVE and skipping them during the sweep phase, and not running destructors
      or handling weakrefs.
      
      It's a bit tricky to figure out when to mark an allocation as conservative vs
      conservative-python; the approach in this commit is to mark all capi-originated
      allocations as conservative, and then when we call PyObject_Init or PyObject_InitVar,
      switch them from conservative to conservative-python.  I think this is more expensive
      but safer than assuming that certain apis will always/never be used as object
      memory.
      
      Unfortunately there are quite a few extension classes that request a custom tp_dealloc,
      and this commit just keeps the old (bad) behavior of ignoring those.  I tried to verify
      as many as I could and they all seem benign, but it will be nice to have
      real destructor support :)
      0c0a7da1
    • Kevin Modzelewski's avatar
  3. 26 May, 2015 15 commits
  4. 25 May, 2015 4 commits
  5. 24 May, 2015 1 commit
  6. 22 May, 2015 13 commits