2

When I run the django manage.py app, I got free(): invalid pointer error.

Example:

>python manage.py check
System check identified no issues (0 silenced).
free(): invalid pointer
Abortado (imagem do núcleo gravada)

The django app is running fine but I'm trying to get rid off this message.

How can I fix this error or get more info to debug it?

Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux (Ubuntu 20.04)
Django==2.2.28
with virtualenv
sinoroc
  • 18,409
  • 2
  • 39
  • 70
Josir
  • 1,282
  • 22
  • 35
  • I also tried different versions of python using pyenv. But I got the same error. – Josir Nov 15 '22 at 20:13
  • I have the same django configuration on another server and the problem does not occurs. – Josir Nov 15 '22 at 20:20
  • Do you have any code using threading, etc.? Related: [Error in `python': free(): invalid pointer: 0x00007fc3c90dc98e](https://stackoverflow.com/questions/46607973/error-in-python-free-invalid-pointer-0x00007fc3c90dc98e) – Abdul Aziz Barkat Nov 21 '22 at 17:55

3 Answers3

1

I have tested with same environment with same Django version and I ran the check command, which did not yield this problem. I assume it is an issue with Pytorch, as mentioned in here: GitHub issue #21018.

To resolve it, you can take the following steps (copy pasted from this SO answer: https://stackoverflow.com/a/56363390/2696165)


There is a known issue with importing both open3d and PyTorch. A few possible workarounds exist:

(1) Some people have found that changing the order in which you import the two packages can resolve the issue, though in my personal testing both ways crash.

(2) Other people have found compiling both packages from source to help.

(3) Still others have found that moving open3d and PyTorch to be called from separate scripts resolves the issue.

Abdul Aziz Barkat
  • 19,475
  • 3
  • 20
  • 33
ruddra
  • 50,746
  • 7
  • 78
  • 101
  • Thanks for replying nuddra. But the project doesn't use pytorch. – Josir Nov 17 '22 at 21:15
  • Okay, but the idea is that there is a library or piece of code which uses C implementation underneath. You need to check why that code is causing this issue. The problem is not related to Python/Django. One more SO question about it: https://stackoverflow.com/questions/20297524/c-free-invalid-pointer – ruddra Nov 19 '22 at 10:49
1

That's a C error related to memory freeing, probably due to a bug from some unpatched dependency package, since you're using an old Django version.

Some options:

  • Check your project at debug level:

    python3 manage.py check --fail-level DEBUG

  • List your dependencies and look online for which one originates that error:

    python3 -m pip freeze

  • Log files.

Jonathan Ciapetti
  • 1,261
  • 3
  • 11
  • 16
  • 1
    Thank you Jonathan but fail-level didn't get any result. What I am looking for is to find which library is returning the error. The app had 40 libraries installed :( If I just remove one of them, the manage.py will raise errors related to the library removal. – Josir Nov 23 '22 at 16:26
0

This usually happens with external dependencies.

You can run the check command on a specific app:

    python manage.py check app1 app2 app3 

For Example:
    python manage.py check auth user myapp

Running on any specific database is also possible.

    python manage.py check --database default --database other

A few similar articles found:

https://github.com/duckietown/apriltags3-py/issues/1

https://github.com/googleapis/python-pubsub/issues/414

https://bugs.python.org/issue41335

  • Thanks RIcha but manage.py check works great. What I want is to find is which library is returning the free command. – Josir Nov 21 '22 at 23:30