SIGABRT of pm2 in a python3 script managed by pm2
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What's going wrong?
I can't run pm2 command in a subprocess created by python3 which is managed by pm2 if I leave the environment untouched.
How could we reproduce this issue?
Run pm2 as root like this pm2 start --interpreter python3 pm2-test.py the script (pm2-in-python.zip) creates two subprocess with shells one which simply runs pm2 jlist and fails with SIGABRT and the other one which removes the environment with the env command and only sets HOME and PATH and works (non-minimal environments, but smaller worked too such as the one incurred by sudo). If you run the script outside of pm2 both variants work. If I only tried a bash script or javascript to run subprocesses which run pm2 jlist they worked, the issue is only with pm2 -> python3 -> pm2.
Here are strace excerpts which will be hopefully helpful:
bad-strace-excerpt.txt
good-strace-excerpt.txt
Here's the diff of environments between sudo pm2 jlist (working under python3 under pm2) and sudo -E pm2 jlist (not working under python3 under pm2):
environment-diff.txt (I redacted PWD but it was a normal absolute path without spaces.)
Supporting information
The system is 4.19.0-10-cloud-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux.
The python3 version is 3.7.3.
The glibc version is ldd (Debian GLIBC 2.28-10) 2.28.
--- PM2 report ----------------------------------------------------------------
Date : Wed Aug 19 2020 11:25:50 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 4.4.1
node version : 10.21.0
node path : /usr/local/bin/pm2
argv : /usr/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : root
uid : 0
gid : 0
uptime : 13min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 4.4.1
node version : 10.21.0
node path : /usr/local/bin/pm2
argv : /usr/bin/node,/usr/local/bin/pm2,report
argv0 : node
user : root
uid : 0
gid : 0
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Xeon(R) CPU @ 2.00GHz
cpus nb : 1
freemem : 673054720
totalmem : 1773883392
home : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ pm2-test │ default │ N/A │ fork │ 0 │ 0 │ 17 │ stopped │ 0% │ 0b │ root │ disabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/root/.pm2/pm2.log last 20 lines:
PM2 | 2020-08-19T11:25:31: PM2 log: App [pm2-test:0] starting in -fork mode-
PM2 | 2020-08-19T11:25:31: PM2 log: App [pm2-test:0] online
PM2 | 2020-08-19T11:25:33: PM2 log: App [pm2-test:0] exited with code [0] via signal [SIGINT]
PM2 | 2020-08-19T11:25:33: PM2 log: App [pm2-test:0] starting in -fork mode-
PM2 | 2020-08-19T11:25:33: PM2 log: App [pm2-test:0] online
PM2 | 2020-08-19T11:25:34: PM2 log: App [pm2-test:0] exited with code [0] via signal [SIGINT]
PM2 | 2020-08-19T11:25:34: PM2 log: App [pm2-test:0] starting in -fork mode-
PM2 | 2020-08-19T11:25:34: PM2 log: App [pm2-test:0] online
PM2 | 2020-08-19T11:25:36: PM2 log: App [pm2-test:0] exited with code [0] via signal [SIGINT]
PM2 | 2020-08-19T11:25:36: PM2 log: App [pm2-test:0] starting in -fork mode-
PM2 | 2020-08-19T11:25:36: PM2 log: App [pm2-test:0] online
PM2 | 2020-08-19T11:25:37: PM2 log: App [pm2-test:0] exited with code [0] via signal [SIGINT]
PM2 | 2020-08-19T11:25:37: PM2 log: App [pm2-test:0] starting in -fork mode-
PM2 | 2020-08-19T11:25:37: PM2 log: App [pm2-test:0] online
PM2 | 2020-08-19T11:25:39: PM2 log: App [pm2-test:0] exited with code [0] via signal [SIGINT]
PM2 | 2020-08-19T11:25:39: PM2 log: App [pm2-test:0] starting in -fork mode-
PM2 | 2020-08-19T11:25:39: PM2 log: App [pm2-test:0] online
PM2 | 2020-08-19T11:25:41: PM2 log: Stopping app:pm2-test id:0
PM2 | 2020-08-19T11:25:41: PM2 log: App [pm2-test:0] exited with code [1] via signal [SIGINT]
PM2 | 2020-08-19T11:25:41: PM2 log: pid=1439 msg=process killed
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the pm2-in-python.zip reproduction and compare bad-strace-excerpt.txt, good-strace-excerpt.txt, and environment-diff.txt to isolate the environment-dependent SIGABRT. Verify the fix by running pm2 under Python 3 with the original environment and confirming that the nested pm2 jlist subprocess completes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100