memray icon indicating copy to clipboard operation
memray copied to clipboard

Memray ERROR: Invalid record subtype when creating new Thread in v.1.13.4

Open bore-741 opened this issue 1 year ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

No response

Expected Behavior

No response

Steps To Reproduce

1.os is linux 2.run with command :memray run -f --follow-fork -m my module 3.Before creating a new thread, memray can analyze the profile file normally. After creating a new thread, memray summary/stats/flamegraph, etc. will prompt ⠋ Computing statistics... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0% -:--:--Memray ERROR: Invalid record subtype

Memray Version

1.13.4

Python Version

3.7

Operating System

Linux

Anything else?

No response

bore-741 avatar Sep 04 '24 09:09 bore-741

Can you please give us the code in "my_module" so we can try to reproduce on our end?

pablogsal avatar Sep 04 '24 09:09 pablogsal

I encountered the same error while profiling an Azure Function locally.

In the following, I provide steps to reproduce this issue with some Python code that mimics the real scenario in which, a memory-intensive task is submitted to a ProcessPoolExecutor. The function memory_intensive_task_async must be async per project requirements thus, it has been wrapped in asyncio.run

To reproduce

  1. Clone example code:
  2. Build Docker image and start a container:
    $ cd /path/to/memray-record-subtype-error-example
    $ docker build . -t memray-record-subtype-error-example
    $ docker run -d --name memray-error-example memray-record-subtype-error-example
    
  3. Spawn a bash, inspect processes and attach memray to running python process:
    $ docker exec -it memray-error-example /bin/bash
    $ ps aux  # look for python process, typically PID 39 or 40
    $ python -m memray attach PID -o memray_profile.bin
    
  4. Make a HTTP request to function from bash spawned at bullet 3:
    $ curl http://localhost/api/my_trigger
    
  5. Detach memray and generate flamegraph:
    $ python -m memray detach PID
    $ python -m memray flamegraph memray_profile.bin
    

Result

During flamegraph generation, memray raises an error:

 Calculating high watermark... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--Memray ERROR: Invalid record subtype

Memray Version

1.14.0

Operating System

Linux

Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

Python Version

3.12.2

MatteoMeil avatar Oct 09 '24 14:10 MatteoMeil

I tried to reproduce this but I wasn't able to do so. Partially because the setup is so complicated and requires several layers. Could you please provide a reproducer that doesn't rely on the azure runtime?

pablogsal avatar Oct 28 '24 14:10 pablogsal

@pablogsal updated my comment above with simplified steps: basically I created an example and put in a repository. You'll only need to create and start a Docker container as described in the steps

MatteoMeil avatar Nov 27 '24 08:11 MatteoMeil