memray
memray copied to clipboard
Memray ERROR: Invalid record subtype when creating new Thread in v.1.13.4
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
Can you please give us the code in "my_module" so we can try to reproduce on our end?
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
- Clone example code:
- 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 - Spawn a bash, inspect processes and attach
memrayto 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 - Make a HTTP request to function from bash spawned at bullet 3:
$ curl http://localhost/api/my_trigger - Detach
memrayand 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
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 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