bh107 / bohrium

Automatic parallelization of Python/NumPy, C, and C++ codes on Linux and MacOSX
http://www.bh107.org
Apache License 2.0
220 stars 31 forks source link

Error in 'python -m bohrium classifyMRELBY.py': free(): invalid pointer: 0x00007f16e0f85c00 #636

Open OscarVanL opened 4 years ago

OscarVanL commented 4 years ago

Hi,

I'm getting an invalid pointer error after taking a (working) script utilising numpy and running it with -m bohrium.

Full error ``` *** Error in `python -m bohrium classifyMRELBP.py -l -a': free(): invalid pointer: 0x00007f16e0f85c00 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x816b9)[0x7f171310d6b9] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/./.libs/libbh_ve_openmp.so(create+0x9a)[0x7 f16c6c2172a] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/.libs/libbh-2bcae67d.so(_ZN7bohrium9compone nt13ComponentFaceC1ERKSsi+0x8d)[0x7f16e0c3005d] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/./.libs/libbh_vem_node.so(create+0x11f)[0x7 f16c6e42cef] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/.libs/libbh-2bcae67d.so(_ZN7bohrium9compone nt13ComponentFaceC1ERKSsi+0x8d)[0x7f16e0c3005d] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/./.libs/libbh_filter_bccon.so(create+0x2ed) [0x7f16c705cfdd] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/.libs/libbh-2bcae67d.so(_ZN7bohrium9compone nt13ComponentFaceC1ERKSsi+0x8d)[0x7f16e0c3005d] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/./.libs/libbh_filter_bcexp.so(create+0x27d) [0x7f16c728255d] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/.libs/libbh-2bcae67d.so(_ZN7bohrium9compone nt13ComponentFaceC1ERKSsi+0x8d)[0x7f16e0c3005d] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/.libs/libbhxx-4473dd8d.so(_ZN4bhxx7RuntimeC 1Ev+0x95)[0x7f16e067f9b5] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/.libs/libbhc-6ad8b2e7.so(_ZN4bhxx7Runtime8i nstanceEv+0x43)[0x7f16e10d1da3] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/.libs/libbhxx-4473dd8d.so(_ZN4bhxx5rangeERN S_7BhArrayImEE+0x134)[0x7f16e07ac514] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium/_bh.cpython-37m-x86_64-linux-gnu.so(array_op+0x 3b3)[0x7f17097811d3] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium/_bh.cpython-37m-x86_64-linux-gnu.so(PyArrayOp+0 x65)[0x7f17097812d5] python -m bohrium classifyMRELBP.py -l -a (_PyMethodDef_RawFastCallKeywords+0x264)[0x55e5038df114] python -m bohrium classifyMRELBP.py -l -a (_PyCFunction_FastCallKeywords+0x21)[0x55e5038df231] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x4e9d)[0x55e503943a5d] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallDict+0x400)[0x55e503899a30] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium/bhary.cpython-37m-x86_64-linux-gnu.so(+0x8c9a)[ 0x7f170984cc9a] python -m bohrium classifyMRELBP.py -l -a (_PyObject_FastCallKeywords+0x48b)[0x55e5038f418b] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x5817)[0x55e5039443d7] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallDict+0x1d5)[0x55e503899805] /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium/bhary.cpython-37m-x86_64-linux-gnu.so(+0x8c9a)[ 0x7f170984cc9a] python -m bohrium classifyMRELBP.py -l -a (_PyObject_FastCallKeywords+0x48b)[0x55e5038f418b] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x52cf)[0x55e503943e8f] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallDict+0x400)[0x55e503899a30] python -m bohrium classifyMRELBP.py -l -a (_PyObject_Call_Prepend+0x63)[0x55e5038b4943] python -m bohrium classifyMRELBP.py -l -a (+0x17506a)[0x55e5038f306a] python -m bohrium classifyMRELBP.py -l -a (_PyObject_FastCallKeywords+0x128)[0x55e5038f3e28] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x5817)[0x55e5039443d7] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (PyEval_EvalCodeEx+0x44)[0x55e5038995f4] python -m bohrium classifyMRELBP.py -l -a (PyEval_EvalCode+0x1c)[0x55e50389961c] python -m bohrium classifyMRELBP.py -l -a (+0x1d07b1)[0x55e50394e7b1] python -m bohrium classifyMRELBP.py -l -a (_PyMethodDef_RawFastCallKeywords+0xe9)[0x55e5038def99] python -m bohrium classifyMRELBP.py -l -a (_PyCFunction_FastCallKeywords+0x21)[0x55e5038df231] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x4764)[0x55e503943324] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallKeywords+0x325)[0x55e5038de8b5] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x416)[0x55e50393efd6] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallKeywords+0x387)[0x55e5038de917] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x14e6)[0x55e5039400a6] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallKeywords+0x387)[0x55e5038de917] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x14e6)[0x55e5039400a6] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallDict+0x10b)[0x55e50389973b] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x1e35)[0x55e5039409f5] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x5da)[0x55e5038989da] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallKeywords+0x387)[0x55e5038de917] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x416)[0x55e50393efd6] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (PyEval_EvalCodeEx+0x44)[0x55e5038995f4] python -m bohrium classifyMRELBP.py -l -a (PyEval_EvalCode+0x1c)[0x55e50389961c] python -m bohrium classifyMRELBP.py -l -a (+0x1d08bd)[0x55e50394e8bd] python -m bohrium classifyMRELBP.py -l -a (_PyMethodDef_RawFastCallKeywords+0xe9)[0x55e5038def99] python -m bohrium classifyMRELBP.py -l -a (_PyCFunction_FastCallKeywords+0x21)[0x55e5038df231] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalFrameDefault+0x4764)[0x55e503943324] python -m bohrium classifyMRELBP.py -l -a (_PyEval_EvalCodeWithName+0x2f9)[0x55e5038986f9] python -m bohrium classifyMRELBP.py -l -a (_PyFunction_FastCallKeywords+0x325)[0x55e5038de8b5] ======= Memory map: ======== 55e50377e000-55e5037d9000 r--p 00000000 00:38 9766622500 /home/ojvl1g17/.conda/envs/IP/bin/python 3.7 55e5037d9000-55e5039a7000 r-xp 0005b000 00:38 9766622500 /home/ojvl1g17/.conda/envs/IP/bin/python 3.7ls ```
python -m bohrium --info ``` ---- Bohrium version: 0.11.0.post54 ---- Bohrium API version: 0.11.0.post54 Installed through PyPI: True Config file: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/config.ini Header dir: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include Backend stack: ---- OpenMP: Main memory: 128847 MB Hardware threads: 16 Malloc cache limit: 19101 MB (80% of unused memory) Cache dir: "/home/ojvl1g17/.bohrium/cache" Temp dir: "/tmp/bh_4c96_e4cc8" Codegen flags: OpenMP: true OpenMP+SIMD: false Index-as-var: true Strides-as-var: true Const-as-var: true JIT Command: "gcc -x c -fPIC -shared -std=gnu99 -O3 -march=native -Werror -fopenmp -I/home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include {IN} -o {OUT}" ---- Note: in order to activate and retrieve GPU info, set the `BH_STACK=opencl` or `BH_STACK=cuda` environment variable. Sanity Check: "import bohrium as bh; import numpy as np; assert((bh.arange(10) == np.arange(10)).all())" - success! ```
BH_STACK=cuda python -m bohrium --info ``` ---- Bohrium version: 0.11.0.post54 ---- Bohrium API version: 0.11.0.post54 Installed through PyPI: True Config file: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/config.ini Header dir: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include Backend stack: ---- OpenMP: Main memory: 128847 MB Hardware threads: 16 Malloc cache limit: 19101 MB (80% of unused memory) Cache dir: "/home/ojvl1g17/.bohrium/cache" Temp dir: "/tmp/bh_4c96_e4cc8" Codegen flags: OpenMP: true OpenMP+SIMD: false Index-as-var: true Strides-as-var: true Const-as-var: true JIT Command: "gcc -x c -fPIC -shared -std=gnu99 -O3 -march=native -Werror -fopenmp -I/home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include {IN} -o {OUT}" ---- Note: in order to activate and retrieve GPU info, set the `BH_STACK=opencl` or `BH_STACK=cuda` environment variable. Sanity Check: "import bohrium as bh; import numpy as np; assert((bh.arange(10) == np.arange(10)).all())" - success! (IP) [ojvl1g17@srv02441 Documents]$ python -m bohrium --info^C (IP) [ojvl1g17@srv02441 Documents]$ BH_STACK=cuda python -m bohrium --info ---- Bohrium version: 0.11.0.post54 ---- Bohrium API version: 0.11.0.post54 Installed through PyPI: True Config file: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/config.ini Header dir: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include Backend stack: ---- CUDA: Device: GeForce GTX 1080 Ti (SM 6.1 compute capability)" Memory: 11178 MB Malloc cache limit: 10060 MB (90%) JIT Command: /usr/local/cuda/bin/nvcc --cubin -m64 -arch=sm_61 -O3 --disable-warnings -I/home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include {IN} -o {OUT} Cache dir: "/home/ojvl1g17/.bohrium/cache" Temp dir: "/tmp/bh_4e43_590c0" Codegen flags: Index-as-var: true Strides-as-var: true const-as-var: true ---- OpenMP: Main memory: 128847 MB Hardware threads: 16 Malloc cache limit: 19115 MB (80% of unused memory) Cache dir: "/home/ojvl1g17/.bohrium/cache" Temp dir: "/tmp/bh_4e43_b851e" Codegen flags: OpenMP: true OpenMP+SIMD: false Index-as-var: true Strides-as-var: true Const-as-var: true JIT Command: "gcc -x c -fPIC -shared -std=gnu99 -O3 -march=native -Werror -fopenmp -I/home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include {IN} -o {OUT}" ---- Sanity Check: "import bohrium as bh; import numpy as np; assert((bh.arange(10) == np.arange(10)).all())" - success! ```
BH_STACK=opencl python -m bohrium --info ``` ---- Bohrium version: 0.11.0.post54 ---- Bohrium API version: 0.11.0.post54 Installed through PyPI: True Config file: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/config.ini Header dir: /home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include Backend stack: ---- OpenCL: Device[0]: NVIDIA CUDA / GeForce GTX 1080 Ti (OpenCL C 1.2 ) Available devices: [0] NVIDIA CUDA / GeForce GTX 1080 Ti (OpenCL C 1.2 ) [1] NVIDIA CUDA / GeForce GTX 1080 Ti (OpenCL C 1.2 ) [2] NVIDIA CUDA / GeForce GTX 1080 Ti (OpenCL C 1.2 ) [3] NVIDIA CUDA / GeForce GTX 1080 Ti (OpenCL C 1.2 ) Memory: 11178 MB Malloc cache limit: 1117 MB (90%) Cache dir: "/home/ojvl1g17/.bohrium/cache" Temp dir: "/tmp/bh_44fe_11462" Codegen flags: Index-as-var: true Strides-as-var: true const-as-var: true ---- OpenMP: Main memory: 128847 MB Hardware threads: 16 Malloc cache limit: 15578 MB (80% of unused memory) Cache dir: "/home/ojvl1g17/.bohrium/cache" Temp dir: "/tmp/bh_44fe_9d964" Codegen flags: OpenMP: true OpenMP+SIMD: false Index-as-var: true Strides-as-var: true Const-as-var: true JIT Command: "gcc -x c -fPIC -shared -std=gnu99 -O3 -march=native -Werror -fopenmp -I/home/ojvl1g17/.conda/envs/IP/lib/python3.7/site-packages/bohrium_api/include {IN} -o {OUT}" ---- Sanity Check: "import bohrium as bh; import numpy as np; assert((bh.arange(10) == np.arange(10)).all())" - success! ```

Other Info:

Any ideas?

OscarVanL commented 4 years ago

OK I've been tracing at what point in my code this free(): invalid pointer error occurs.

I seem to have traced it to this line within my class init function:

        print("Debug setting radial angles")
        self.radial_angles = np.arange(0, self.p) * -(2 * math.pi) / self.p
        print("Debug completed radial angles")

As you can see from my new output:

Debug setting radial angles
free(): invalid pointer
./startProjAsHost.sh: line 6:   235 Aborted

It seems to have failed on this line.

The self.p variable is set to 8, so there's nothing edge-case about that.

OscarVanL commented 4 years ago

This is odd.

If I change the following line:

self.radial_angles = np.linspace(0, p) * - (2 * np.pi) / p)

into:

self.radial_angles = [(x * - (2 * np.pi) / p) for x in range (0, p)]

It fixes the error.

After fixing this error, later lines of code in my project result in the same error. Another line this happened on was:

filtered_image = np.zeros((width, height), dtype=np.float32)

I'm rather confused by these arbitrary seeming errors, so I'm hoping you know what might be causing this.