Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free(): invalid pointer with numpy and cv2 #245

Closed
NiuBlibing opened this issue Feb 6, 2025 · 10 comments · Fixed by #244
Closed

free(): invalid pointer with numpy and cv2 #245

NiuBlibing opened this issue Feb 6, 2025 · 10 comments · Fixed by #244

Comments

@NiuBlibing
Copy link

NiuBlibing commented Feb 6, 2025

I got a problem with pulsar when using numpy and cv2, it throws free(): invalid pointer and kill my program.

# load pulsar firstly, it doesn't work, throws "free(): invalid pointer"
import pulsar
import numpy as np
import cv2

binary_matrix = np.ones((3, 2), dtype=np.uint8)
print(cv2.connectedComponentsWithStats(
        binary_matrix, connectivity=4
    ))

But if I load pulsar latter than numpy, it works:

import numpy as np
import cv2
import pulsar


binary_matrix = np.ones((3, 2), dtype=np.uint8)
print(cv2.connectedComponentsWithStats(
        binary_matrix, connectivity=4
    ))

My environment:

Python 3.13.1
pulsar-client v3.6.0
numpy v2.2.2
opencv-python v4.11.0.86
@NiuBlibing
Copy link
Author

Thread 1 "python3" received signal SIGABRT, Aborted.
0x00007ffff7e2c334 in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7e2c334 in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff7dd3120 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff7dba4c3 in abort () from /usr/lib/libc.so.6
#3  0x00007ffff7dbb354 in ?? () from /usr/lib/libc.so.6
#4  0x00007ffff7e366a5 in ?? () from /usr/lib/libc.so.6
#5  0x00007ffff7e38b8c in ?? () from /usr/lib/libc.so.6
#6  0x00007ffff7e3b50e in free () from /usr/lib/libc.so.6
#7  0x00007ffff64a164a in std::locale::_Impl::~_Impl() ()
   from /app-test/.venv/lib/python3.13/site-packages/pulsar_client.libs/libpulsar-6092c95d.so
#8  0x00007ffff56c4267 in std::locale::_Impl::_M_remove_reference (this=0x7ffff68016c0 <(anonymous namespace)::c_locale_impl>)
    at /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/locale_classes.h:601
#9  std::locale::_Impl::_M_remove_reference (this=0x7ffff68016c0 <(anonymous namespace)::c_locale_impl>)
    at /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/locale_classes.h:593
#10 std::locale::~locale (this=<optimized out>, __in_chrg=<optimized out>) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++98/locale.cc:94
#11 0x00007fffe0a34793 in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#12 0x00007fffe0a34a65 in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#13 0x00007fffe0a4611c in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#14 0x00007fffe0a46275 in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#15 0x00007fffe0a33705 in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#16 0x00007fffe0c76cee in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#17 0x00007fffe0c7d276 in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#18 0x00007fffe0c7d35b in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#19 0x00007fffe06fdeba in ?? () from /app-test/.venv/lib/python3.13/site-packages/cv2/cv2.abi3.so
#20 0x00007ffff799499c in cfunction_call (func=0x7ffff35e48b0, args=0x7ffff6f5ca60, kwargs=0x7ffff6a36380) at Objects/methodobject.c:540
#21 0x00007ffff795d02c in _PyObject_MakeTpCall (tstate=0x7ffff7d20e90 <_PyRuntime+283024>, callable=0x7ffff35e48b0, args=<optimized out>, nargs=<optimized out>, 
    keywords=0x7ffff6ef09d0) at Objects/call.c:242
#22 0x00007ffff797c430 in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at Python/generated_cases.c.h:1502
#23 0x00007ffff7a40ce5 in PyEval_EvalCode (co=0x7ffff764ae20, globals=<optimized out>, locals=0x7ffff6ef4400) at Python/ceval.c:601
#24 0x00007ffff7a62870 in run_eval_code_obj (tstate=tstate@entry=0x7ffff7d20e90 <_PyRuntime+283024>, co=co@entry=0x7ffff764ae20, globals=globals@entry=0x7ffff6ef4400, 
    locals=locals@entry=0x7ffff6ef4400) at Python/pythonrun.c:1337
#25 0x00007ffff7a5cc7a in run_mod (mod=mod@entry=0x555555617548, filename=filename@entry=0x7ffff6f06c30, globals=globals@entry=0x7ffff6ef4400, locals=locals@entry=0x7ffff6ef4400, 
    flags=flags@entry=0x7fffffffd598, arena=arena@entry=0x7ffff762fcf0, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1422
#26 0x00007ffff7a7fc77 in pyrun_file (fp=fp@entry=0x5555555702b0, filename=filename@entry=0x7ffff6f06c30, start=start@entry=257, globals=globals@entry=0x7ffff6ef4400, 
    locals=locals@entry=0x7ffff6ef4400, closeit=closeit@entry=1, flags=0x7fffffffd598) at Python/pythonrun.c:1255
#27 0x00007ffff7a7f6d2 in _PyRun_SimpleFileObject (fp=fp@entry=0x5555555702b0, filename=filename@entry=0x7ffff6f06c30, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffd598)
    at Python/pythonrun.c:490
#28 0x00007ffff7a7f493 in _PyRun_AnyFileObject (fp=fp@entry=0x5555555702b0, filename=filename@entry=0x7ffff6f06c30, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffd598)
    at Python/pythonrun.c:77
#29 0x00007ffff7a757d1 in pymain_run_file_obj (program_name=0x7ffff6f06f30, filename=0x7ffff6f06c30, skip_source_first_line=0) at Modules/main.c:409
#30 pymain_run_file (config=0x7ffff7cf3588 <_PyRuntime+96392>) at Modules/main.c:428
#31 pymain_run_python (exitcode=0x7fffffffd58c) at Modules/main.c:696
#32 Py_RunMain () at Modules/main.c:775
#33 0x00007ffff7a3057c in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:829
#34 0x00007ffff7dbbe08 in ?? () from /usr/lib/libc.so.6
#35 0x00007ffff7dbbecc in __libc_start_main () from /usr/lib/libc.so.6
#36 0x0000555555555045 in _start ()

@laurent-chriqui
Copy link
Contributor

I have the same issue without numpy or cv2 on python 3.11.11
Pulsar crashes on init with free(): invalid pointer
Logging at Debug level doesn't show anything more.

@BewareMyPower
Copy link
Contributor

@NiuBlibing @laurent-chriqui It seems like an issue with Python client 3.6.0. Do you have a chance to test the wheels here?

@BewareMyPower
Copy link
Contributor

It should be a similar issue with #242 and #243

@laurent-chriqui
Copy link
Contributor

@NiuBlibing @laurent-chriqui It seems like an issue with Python client 3.6.0. Do you have a chance to test the wheels here?

I'll try the 3.11 wheel

@laurent-chriqui
Copy link
Contributor

The manylinux2014 cp311 wheel seems to be working fine!

@BewareMyPower
Copy link
Contributor

Okay, them I will verify the wheels by myself tomorrow and mark #244 as ready to review. After that I will release a patched 3.6.1 release

@BewareMyPower
Copy link
Contributor

I've verified pulsar_client-3.6.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

BewareMyPower added a commit that referenced this issue Feb 8, 2025
…dc++ (#244)

Fixes #242
Fixes #243
Fixes #245

Add a patch to avoid linking to libgcc and libstdc++.

(cherry picked from commit 4a4ac3f)
@NiuBlibing
Copy link
Author

@BewareMyPower Could you publish a new version release to pypi?

@BewareMyPower
Copy link
Contributor

Currently the 3.6.1 release is in the vote phase, you can download these wheels to verify if it works. https://lists.apache.org/thread/s3qq7krzsl5lvsj7d0hg7c3xg251xhrd

After the release is completed, these wheels will be uploaded to pypi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants