Giter Site home page Giter Site logo

Comments (9)

jriehl avatar jriehl commented on August 24, 2024

Good catch. James submitted (and I pushed) that example knowing that it was causing segmentation faults, but we didn't have time to debug it at the SciPy sprint.

(Conjecture, but feels spot on:) This code (along with other code posted on the discussion list) returns the output parameter. Since the generated code doesn't increment the reference count, the output array gets free()'d when the return value is ignored and popped off the interpreter's value stack. Subsequent uses of that array are writing to unmapped memory, causing segmentation faults, or double free()'s.

See if removing the "return output" line fixes it, and I'll try the same.

As far as the prognosis for fixing this goes, I can most likely write a quick fix that detects escaping array objects, and increments the reference count before returning to Python (taking care to remove the reference count increment added to fix issue 2). This complicates LLVM-to-LLVM code calls, however, since nesting calls will return an incorrect reference count (for example, a JIT'ed function returning the array returned by another JIT'ed function would have 1 more reference count than needed, causing a memory leak).

from numba.

jriehl avatar jriehl commented on August 24, 2024

Oops. Just for hygiene, the referenced fix was for issue #8. #8

from numba.

jriehl avatar jriehl commented on August 24, 2024

See the commit for my modified version of the fbcorr example. This works for me, but note that the return type has changed, in addition to removing the return statement (when Numba currently tries to cast None to a 4-d array of doubles, it hits a LLVM assertion and dies).

from numba.

alexbw avatar alexbw commented on August 24, 2024

I will test this for my code tomorrow.

from numba.

alexbw avatar alexbw commented on August 24, 2024

Works for me now! I don't know how you want to inform users of this quirk. Outside of Numba, these pointer problems are either hyper-explicit (Cython) or completely transparent (Python/Numpy).

I wouldn't mind Numba throwing an error if I tried to return an array. I also can't allocate arrays of arbitrary sizes (np.zeros() et al don't work right now, I think), so it seems reasonable to beep at the user if a return statement will cause problems.

from numba.

alexbw avatar alexbw commented on August 24, 2024

This is what I was writing it all for: http://nbviewer.ipython.org/3407544

It now works quite well! So astoundingly fast for how readable the code is.

from numba.

alexbw avatar alexbw commented on August 24, 2024

And one last syntactic question:
Is it preferred to use numba.double[:,:] over [['d']]? Either way, why is one preferred?

from numba.

jriehl avatar jriehl commented on August 24, 2024

The [['d']] type notation was an early ad hoc design, and will be deprecated. If you don't like typing "numba.double" all the time, the shorthand "numba.d" is also available.

from numba.

markflorisson avatar markflorisson commented on August 24, 2024

This has been fixed for the ast backend for a while now. SInce the bytecode backend is deprecated, I'm closing this.

from numba.

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.