Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Lisp Users: Due to the holiday next Monday, there will be no garbage collection.


devel / comp.lang.python / Re: Weird strace of #! python script

SubjectAuthor
o Re: Weird strace of #! python scriptChris Angelico

1
Re: Weird strace of #! python script

<mailman.302.1647293977.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17506&group=comp.lang.python#17506

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Weird strace of #! python script
Date: Tue, 15 Mar 2022 08:39:24 +1100
Lines: 66
Message-ID: <mailman.302.1647293977.2329.python-list@python.org>
References: <CAGGBd_oHbCXgu-q+ANXUh2t1zRqErpNBOVqu74ycd=fP28pLUQ@mail.gmail.com>
<CAPTjJmp4vtJ1h7QK5k5hgnwN-3qU1pHLzzUzJX55AqmdDM6eHA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de mFkTzRSY3MVN8O5lWa7LCAHLGPtlywLK2Tz0jkuaCW+A==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=TeAZPQma;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05;
'subject:python': 0.06; 'mar': 0.07; 'anyway,': 0.09; 'dan': 0.09;
'debian': 0.09; 'grep': 0.09; 'itself,': 0.09; 'linux': 0.09;
'subject:script': 0.09; 'import': 0.15; '1024': 0.16; '1163':
0.16; '1363': 0.16; '1366': 0.16; '1367': 0.16; '3.x': 0.16;
'bash': 0.16; 'cat': 0.16; 'chrisa': 0.16; 'from:addr:rosuav':
0.16; 'from:name:chris angelico': 0.16; 'pid': 0.16; 'porting':
0.16; 'python3.': 0.16; 'received:209.85.221.47': 0.16; 'received
:mail-wr1-f47.google.com': 0.16; 'script.': 0.16; 'to?': 0.16;
'wrote:': 0.16; 'python': 0.16; 'larger': 0.17; 'bug': 0.19;
'tue,': 0.19; 'to:addr:python-list': 0.20; "i've": 0.22;
'command': 0.23; 'thanks!': 0.24; 'follows:': 0.26; 'suspect':
0.26; 'else': 0.27; 'done': 0.28; 'seem': 0.31; "doesn't": 0.32;
'deleted': 0.32; 'guess': 0.32; 'happening': 0.32; 'here,': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; "i'm": 0.33;
'there': 0.33; 'script': 0.33; 'same': 0.34; 'header:In-Reply-
To:1': 0.34; 'received:google.com': 0.34; 'track': 0.35;
'from:addr:gmail.com': 0.35; 'processes': 0.36; 'missing': 0.37;
"it's": 0.37; 'received:209.85': 0.37; 'way': 0.38;
'received:209': 0.39; 'list': 0.39; 'stopped': 0.40; 'try': 0.40;
'security': 0.64; 'down': 0.64; 'in.': 0.64; 'top': 0.65; 'skip:t
20': 0.66; 'heard': 0.67; 'skip:# 10': 0.68; 'skip:/ 10': 0.69;
'implemented': 0.76; 'happens': 0.84; 'handled': 0.84; 'itself.':
0.84; 'subject:Weird': 0.84; 'ancient': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=I8gr85bA6dAWQemFpkgNAc3bEKCJkez1jV+NcpIHI3E=;
b=TeAZPQmaEjHvwQtQJZrLt3kKeHAJ4gEr7+WtKsMD8AJXfWd1lJ1Z+CQjV88OW5U1Ij
SVDlLCIxd25ARITnM3nOYmMBTWY+eix4638cwwzdzdvvfahsMapqGwZBygrFxKeeZ/K8
Wiry0GHahrAaNL/7yQlPV4SQEfbA4KkTLDfQGhm39RMlrrH9ux5mTPo9NgMHg3yCSNjM
GhKDrnXMamzeJzQ5Wh1HCa5Dm52FC3AOEIVMDqqLwnA5rvFAPpkBG9ijCDcGNUXl2MwQ
fj1dyRE27so9lF/8QArymg5w/vGTPLxR6Y9pgmnDQEECTtZHmRm8cLW4DSiegWpTd3mN
5lGg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=I8gr85bA6dAWQemFpkgNAc3bEKCJkez1jV+NcpIHI3E=;
b=hjVX6lNc2vDXi2nfG+fUIHI4Cc6pyARPGT0j6wA7DySam0qXks0RTbIe4dQICbuNz1
ZPopc4sV1/WoeA4UtfFKWOZMxeNpJqKetr9uxzDsfpFU09nJanphK1ezgtB2T5bIwhfi
IAzQi1e6KMDDEHDqekcG4CQERuF96o8KBMz2jXBVXmHzMonAOnJ3vl1tRW0R7ykCad/M
2WtV0fXaGhGujwhG148KRB/+HcCRCdj3KT9CnFIOQ0ruMDxQ4s+EM+Qq8oowuI2x67Nh
Ru9K4RO9u2uG6SqO26011eyHSRtrypWumB4sDsXINKbU4m16VqywURjidc3D/kZT9Lqw
+17w==
X-Gm-Message-State: AOAM532S6FlecxFjv3Nch5O9FcIz12c4n7SoTyGP17RDnN/XcmvEYzeG
BSVvLD9cMcexkc1nyllIEtazw6mA4z/IvI8GF1gxvqzY
X-Google-Smtp-Source: ABdhPJwoSBzBIRktwePb3Ax4Tc6oDxWxIl6p+2UA60p2G/A+St3vrQDy4NXSOqiCQ9jmUT/D8CikTF+bFFj9zAo/nKM=
X-Received: by 2002:adf:db43:0:b0:1ef:7195:43cd with SMTP id
f3-20020adfdb43000000b001ef719543cdmr17995431wrj.495.1647293975360; Mon, 14
Mar 2022 14:39:35 -0700 (PDT)
In-Reply-To: <CAGGBd_oHbCXgu-q+ANXUh2t1zRqErpNBOVqu74ycd=fP28pLUQ@mail.gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmp4vtJ1h7QK5k5hgnwN-3qU1pHLzzUzJX55AqmdDM6eHA@mail.gmail.com>
X-Mailman-Original-References: <CAGGBd_oHbCXgu-q+ANXUh2t1zRqErpNBOVqu74ycd=fP28pLUQ@mail.gmail.com>
 by: Chris Angelico - Mon, 14 Mar 2022 21:39 UTC

On Tue, 15 Mar 2022 at 08:28, Dan Stromberg <drsalists@gmail.com> wrote:
>
> Hi folks.
>
> First off, I know, python2 is ancient history. Porting to 3.x is on my
> list of things to do (though I'm afraid it's not yet at the top of the
> list), and the same thing happens with python3.
>
> So anyway, I'm strace'ing a #!/usr/bin/python2 script.
>
> I expected to see an exec of /usr/bin/python2, but I don't. I just see an
> exec of /tmp/t.
>
> As follows:
> tact@celery_worker:/app$ strace -f -s 1024 -o /tmp/t.strace /tmp/t
> ^Z
> [1]+ Stopped strace -f -s 1024 -o /tmp/t.strace /tmp/t
> tact@celery_worker:/app$ bg
> [1]+ strace -f -s 1024 -o /tmp/t.strace /tmp/t &
> tact@celery_worker:/app$ ps axf
> PID TTY STAT TIME COMMAND
> 1163 pts/0 Ss 0:00 bash
> 1363 pts/0 S 0:00 \_ strace -f -s 1024 -o /tmp/t.strace /tmp/t
> 1366 pts/0 S 0:00 | \_ /usr/bin/python2 /tmp/t
> 1367 pts/0 R+ 0:00 \_ ps axf
> tact@celery_worker:/app$ fg
> bash: fg: job has terminated
> [1]+ Done strace -f -s 1024 -o /tmp/t.strace /tmp/t
> tact@celery_worker:/app$ grep execve /tmp/t.strace
> 1366 execve("/tmp/t", ["/tmp/t"], 0x7ffd89f9c3b8 /* 49 vars */) = 0
> tact@celery_worker:/app$
>
> I've deleted some irrelevant processes from the 'ps axf'.
>
> /tmp/t is actually just:
> tact@celery_worker:/app$ cat /tmp/t
> #!/usr/bin/python2
>
> import time
>
> time.sleep(10)
>
>
> Was this some sort of security feature I never heard about? I'm tracing a
> very simple time.sleep(10) here, but the same thing is (not) happening in a
> larger script that I need to track down a bug in.
>
> Is there a way I can coax Linux and/or strace to show all the exec's, like
> they used to? Not having them makes me wonder what else is missing from
> the strace report.
>
> I'm on a Debian 11.2 system with strace 5.10 and Python 2.7.18.
>
> Thanks!

I'm not sure, but I suspect that strace is skipping the exec into the
process itself. When I try this myself, I can see the trace of the
sleep call itself (it's implemented on top of select()), so it does
seem to be doing the proper trace. My guess is that the shebang is
being handled inside the exec of /tmp/t itself, rather than being a
separate syscall.

In any case, it doesn't seem to be a Python thing; I can trigger the
same phenomenon with other interpreters.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor