Failure to serialize long numbers

Bug #1879100 reported by Eugene Morozov
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Meliae
New
Undecided
Unassigned

Bug Description

When trying to find memory leak in my Django application, meliae fails immediately with the following traceback:

ERROR: django.request: Internal Server Error: /play/dump/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/project/apps/play/views.py", line 238, in get
    meliae.scanner.dump_all_objects('/opt/project/heap.dump')
  File "/usr/local/lib/python2.7/site-packages/meliae/scanner.py", line 141, in dump_all_objects
    dump_all_referenced(outf, all_objs, is_pending=True)
  File "/usr/local/lib/python2.7/site-packages/meliae/scanner.py", line 72, in dump_all_referenced
    for ref in get_referents(next):
OverflowError: Python int too large to convert to C long

After compiling python with debug information and stepping through the code in gdb, I found out that this happens because meliae attempts to serialize Python long integers as C long. But Python long has an unlimited range and cannot be cast to C long.

I'm attaching a small patch that attempts to serialize Python long as C long long and returning -1 in case if Python long is too large for C long.

I was able to generate dump successfully after building meliae with this change.

Revision history for this message
Eugene Morozov (emorozov) wrote :
description: updated
description: updated
Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 1879100] Re: Failure to serialize long numbers

Can you add a test case for this? It should be pretty straight forward to
add a test of dumping a long that is bigger than 32bits and probably also
one for bigger than 64 bits. I'm not really sure how to represent numbers
that are >> 64 bits but having a stable answer at least would be good.

On Sun, May 17, 2020 at 2:35 AM Eugene Morozov <email address hidden>
wrote:

> ** Patch added: "meliae.patch"
>
> https://bugs.launchpad.net/meliae/+bug/1879100/+attachment/5372759/+files/meliae.patch
>
> --
> You received this bug notification because you are a member of Meliae
> Development Team, which is subscribed to Meliae.
> https://bugs.launchpad.net/bugs/1879100
>
> Title:
> Failure to serialize long numbers
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/meliae/+bug/1879100/+subscriptions
>

Revision history for this message
Eugene Morozov (emorozov) wrote :
Revision history for this message
Eugene Morozov (emorozov) wrote :

Patch with a trivial test.

Revision history for this message
Eugene Morozov (emorozov) wrote :

Attached a patch with a trivial test that attempts to serialize large integer.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.