Skip Menu |

This queue is for tickets about the Inline-Python CPAN distribution.

Report information
The Basics
Id: 128999
Status: new
Priority: 0/
Queue: Inline-Python

People
Owner: Nobody in particular
Requestors: CYGA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: calls to numpy lib and segmentation faults
Very interesting library you wrote, great work. Nonetheless, I can't start using numpy, because of weird segmentation faults: ``` #!/usr/bin/env perl use Test::More qw(no_plan); require_ok('Inline::Python'); is(py_sub(1,2), -1, "test simple function"); diag(py_add()); exit; use Inline Python => <<'END_OF_PYTHON_CODE'; import numpy as np def py_sub(x,y): return x - y def py_add(): t = 0.0 s = 1.0 # work with: s = ... #s = np.add(t,s) t = np.add(t,s) return t END_OF_PYTHON_CODE ``` I tried it under docker with ubuntu and python3.5 and numpy installed system wide and under centos 7 and python2.7 and numpy installed per user (pip install --user numpy). Any ideas where to dig?
I forgot to include results for execution of the aforementioned code: ``` ok 1 - require Inline::Python; ok 2 - test simple function Segmentation fault (core dumped) ``` And if I comment it like: ```def py_add(): t = 0.0 s = 1.0 # work with: s = ... s = np.add(t,s) #t = np.add(t,s) return t ``` It runs ok: ``` ok 1 - require Inline::Python; ok 2 - test simple function # 0 1..2 ``` Same code for same python works in the system: ``` python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. Show quoted text
>>> import numpy as np >>> t = 0.0 >>> s = 1.0 >>> t = np.add(s,t) >>> t
1.0 ``` So, it looks like some sort of the memory issue. Because np.add code has to be called in the successfull code. Ok, I decided to think of another prove for np.add was called: ``` #!/usr/bin/env perl use Test::More qw(no_plan); require_ok('Inline::Python'); diag(py_add(1.0)); diag(py_add(-21.0)); exit; use Inline Python => <<'END_OF_PYTHON_CODE'; import numpy as np def py_add(s): t = 1.0 s = np.add(t,s) if s > 0.0: return t return 997.0 END_OF_PYTHON_CODE ``` Ends up in: ``` ok 1 - require Inline::Python; # 1 # 997 1..1 ``` So, this has to be a problem with memory. On Tue Apr 02 06:44:42 2019, CYGA wrote: Show quoted text
> Very interesting library you wrote, great work. > > Nonetheless, I can't start using numpy, because of weird segmentation > faults: > > ``` > #!/usr/bin/env > perl > use > Test::More qw(no_plan); > > require_ok('Inline::Python'); > > is(py_sub(1,2), -1, "test simple function"); > > diag(py_add()); > > exit; > > use Inline Python => <<'END_OF_PYTHON_CODE'; > import numpy as np > > def py_sub(x,y): > return x - y > > def py_add(): > t = 0.0 > s = 1.0 > # work with: s = ... > #s = np.add(t,s) > t = np.add(t,s) > return t > > END_OF_PYTHON_CODE > ``` > > I tried it under docker with ubuntu and python3.5 and numpy installed > system wide > and under centos 7 and python2.7 and numpy installed per user (pip > install --user numpy). > > Any ideas where to dig?