Comments (9)
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.
Oops. Just for hygiene, the referenced fix was for issue #8. #8
from numba.
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.
I will test this for my code tomorrow.
from numba.
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.
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.
And one last syntactic question:
Is it preferred to use numba.double[:,:] over [['d']]? Either way, why is one preferred?
from numba.
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.
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)
- Cannot cache function with jitclass as argument
- Test failure on LLVM15: `test_remainder_float` HOT 7
- ~~True return True HOT 1
- Numba functions do not consider global variables from other modules as compile time constant. HOT 12
- RuntimeError: cannot cache function '_make_tree': no locator available HOT 5
- Can't execute python tests directly without using runtests.py HOT 2
- Memory leak when applying numba to an inner function HOT 1
- Errors not being raised when running code in parallel HOT 1
- Source/AST Frontend for Numba HOT 10
- typed.List __repr__() HOT 3
- Bug in the compiler in 0.60 : 'tuple' object has no attribute 'name' HOT 1
- Numba much slower than `np.sum`, and more sensitive to summation axis HOT 1
- First-class function type initializes too late
- inefficient matrix multiplication with its transpose HOT 4
- np.count_nonzero is incorrect when setting axis=0 for 1-dimensional array HOT 2
- Installation fails on termux Python 3.11 HOT 3
- Compilation failure with NumPy 2.0.1 HOT 2
- isfinite(inf) raises FloatingPointError in vectorized functions HOT 5
- TypingError When Accessing Attributes of Nested JitClasses HOT 4
- Jitted and non-jitten function give different output HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numba.