NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: port-amd64/51700: exect(NULL,NULL,NULL) generates 15859 times SIGTRAP on amd64
The following reply was made to PR port-amd64/51700; it has been noted by GNATS.
From: Kamil Rytarowski <n54%gmx.com@localhost>
To: Paul Goyette <paul%whooppee.com@localhost>, gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: port-amd64/51700: exect(NULL,NULL,NULL) generates 15859 times
SIGTRAP on amd64
Date: Fri, 9 Dec 2016 11:38:48 +0100
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--X10K5woipbiTnFcQ0PpAEGSNpqeiHCgO2
Content-Type: multipart/mixed; boundary="9fVl8TJuCd2CMJaA5T2QXqnRS7hsS0VBC"
From: Kamil Rytarowski <n54%gmx.com@localhost>
To: Paul Goyette <paul%whooppee.com@localhost>, gnats-bugs%NetBSD.org@localhost
Message-ID: <d79c070c-cc13-e1f5-b599-e39a9fd38a81%gmx.com@localhost>
Subject: Re: port-amd64/51700: exect(NULL,NULL,NULL) generates 15859 times
SIGTRAP on amd64
References: <pr-port-amd64-51700%gnats.netbsd.org@localhost>
<20161209063718.626CA7A364%mollari.NetBSD.org@localhost>
<20161209095501.35ABE7A330%mollari.NetBSD.org@localhost>
<Pine.NEB.4.64.1612091800580.7853%speedy.whooppee.com@localhost>
In-Reply-To: <Pine.NEB.4.64.1612091800580.7853%speedy.whooppee.com@localhost>
--9fVl8TJuCd2CMJaA5T2QXqnRS7hsS0VBC
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable
Good point, if exect(3) is going to be a programmer-friendly utility
(and since it already reserves its entry in libc), I'm for a breakpoint
on the main() function.
In that scenario we would get debugger code like:
int status;
child =3D fork();
if (child =3D=3D 0)
exect("/bin/cat", "cat", NULL);
wait(&status);
ptrace(...)
On 09.12.2016 11:03, Paul Goyette wrote:
> Just curious.... (private response, feel free to forward if you find i=
t
> useful)
>=20
>> This sounds to me like exect(3) should be equivalent to PT_TRACE_ME &
>> execve(2) & raise(SIGTRAP with si_code=3D3DTRAP_TRACE) on first instru=
ction
>=20
> The term "first instruction" could be interpreted as the beginning of
> the executable's main() procedure. Or it could be interpreted as the
> beginning of crt0 code for the executable.
>=20
> I'm not sure which one you mean, but whatever decision is made, it need=
s
> to be clearly and unambiguously documented. :)
>=20
>=20
>=20
>=20
> On Fri, 9 Dec 2016, Kamil Rytarowski wrote:
>=20
>> The following reply was made to PR port-amd64/51700; it has been noted=
>> by GNATS.
>>
>> From: Kamil Rytarowski <n54%gmx.com@localhost>
>> To: gnats-bugs%NetBSD.org@localhost
>> Cc:
>> Subject: Re: port-amd64/51700: exect(NULL,NULL,NULL) generates 15859
>> times
>> SIGTRAP on amd64
>> Date: Fri, 9 Dec 2016 10:47:52 +0100
>>
>> This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
>> --mVDohrfhGJl4KDx3cDu9JiGuBdl9t14uF
>> Content-Type: multipart/mixed;
>> boundary=3D"kwFMJQnhwOSeUsptJJ1MMGmLvXhLtXrTK"
>> From: Kamil Rytarowski <n54%gmx.com@localhost>
>> To: gnats-bugs%NetBSD.org@localhost
>> Message-ID: <2044468e-027f-b38c-b17e-d9a23c55b820%gmx.com@localhost>
>> Subject: Re: port-amd64/51700: exect(NULL,NULL,NULL) generates 15859
>> times
>> SIGTRAP on amd64
>> References: <pr-port-amd64-51700%gnats.netbsd.org@localhost>
>> <20161209063718.626CA7A364%mollari.NetBSD.org@localhost>
>> <20161209064000.613C97A364%mollari.NetBSD.org@localhost>
>> In-Reply-To: <20161209064000.613C97A364%mollari.NetBSD.org@localhost>
>>
>> --kwFMJQnhwOSeUsptJJ1MMGmLvXhLtXrTK
>> Content-Type: text/plain; charset=3Dwindows-1252
>> Content-Transfer-Encoding: quoted-printable
>>
>> Since this interface is apparently unclear I will add few sentences.
>>
>> The exect(3) call is an extension to execve(2), it's added
>> functionality is to raise SIGTRAP with si_code TRAP_TRACE.
>>
>> Currently mainly vax, i386 and amd64 implement this interface through
>> libc, however with this is more a hack, as these port set machine flag=
>> used to step the code and resumes with execve(2).
>>
>> If we want to keep its implementation in libc I think the best solutio=
n
>> is to switch this code to the sequence of raise(3) && execve(2) for al=
l
>> ports (how to set si_code to TRAP_TRACE in this case?).
>>
>> However I think it's little point to trace libc's internals and it mig=
ht
>> be more useful to raise signal just before executing the first
>> instruction and this is doable
>>
>> The exect(3) function was added on day0 (inherited from 386bsd) and
>> perhaps unused since then. The man-page describes it as follows (text
>> unmodified since that time):
>>
>> The function exect() executes a file with the program tracing
>> facilities enabled (see ptrace(2)).
>>
>> This sounds to me like exect(3) should be equivalent to PT_TRACE_ME &
>> execve(2) & raise(SIGTRAP with si_code=3D3DTRAP_TRACE) on first
>> instruction=3D
>>
>> of the new image.
>>
>> This call is currently unimplemented port-wide and perhaps not really
>> functional with ports that implement it either, if we want to fix it I=
>> think we are free to alter its meaning and make it more useful now.
>>
>> I checked 386bsd sources and it's the same as the current i386 version=
>> -- without particular users. I think the proposed scenario with
>> PT_TRACE_ME is the only variation that might be useful.
>>
>> exect(3) is kept in FreeBSD with the original questionable behavior an=
d
>> absent in OpenBSD
>>
>>
>> --kwFMJQnhwOSeUsptJJ1MMGmLvXhLtXrTK--
>>
>> --mVDohrfhGJl4KDx3cDu9JiGuBdl9t14uF
>> Content-Type: application/pgp-signature; name=3D"signature.asc"
>> Content-Description: OpenPGP digital signature
>> Content-Disposition: attachment; filename=3D"signature.asc"
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v2
>>
>> iQIcBAEBCAAGBQJYSn3cAAoJEEuzCOmwLnZs4y4QAKcHFYX0J2Wo1on76Km9Fsb8
>> I+KjWqL7yv322xPurEeeRmzPYgxHGGaFachh/J9zJJlQwzrzsaelab3JLgidN6Uw
>> 2odgpNsLh+5MsRFPEXlXEMR06fawHLwUFa+Yw6nCzp2W+4wgPBgaleWsEhq6NI88
>> ltaqZxFwGbp/bjxDxodoKxVqdtMOslJEXOTXBFanfWRCPVgnMq8QLP8lW/WQD/Qm
>> ldcpN/Lyh6KOX+eIkc9DkkO82/bBqkeohP5nUY+fFo/57T4088fRqx5JVOT7ywvx
>> i3/ut1XOzOWlFkD5yWQ75bALHtZwlOJO4pbx/3yHhzDyYmNtJsXCpGYTpUc5WLdM
>> /KnxeWlYFuXgazMjC/Mr8Zbkv3jOAp+CSYFjgnW1nQ9NnYmERlOTiY+h4w2WWuZK
>> zr3E+K6QPZ/KJqteZwMmr8SdTkCpT2IrdU1Jrk1U8zaHOSa8NljJQ5VIyeOJkdpx
>> x60FD7oGsxvGCavBofdxbQYEmi5+PRMQ6YzohqQ+kfFQWq+4ShWLoy340Bz1OGk8
>> M8dimONdNIKNVwET8Z/RAkaWajlJARao3EsVkHlmNZgK30V/kSyqz4K5un6E19JG
>> 8V82wI+oQvLwRKst/du7zz01rBqHFVa8M+fuPvkbE1RGj0ycgH7b9Aq+deQKz0Uf
>> mEafBuagI2tNqiV/odZ1
>> =3Dltx4
>> -----END PGP SIGNATURE-----
>>
>> --mVDohrfhGJl4KDx3cDu9JiGuBdl9t14uF--
>>
>>
>> !DSPAM:584a7fa116007695620486!
>>
>>
>=20
> +------------------+--------------------------+------------------------=
+
> | Paul Goyette | PGP Key fingerprint: | E-mail addresses: =
|
> | (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com =
|
> | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org =
|
> +------------------+--------------------------+------------------------=
+
--9fVl8TJuCd2CMJaA5T2QXqnRS7hsS0VBC--
--X10K5woipbiTnFcQ0PpAEGSNpqeiHCgO2
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJYSonAAAoJEEuzCOmwLnZsyecQAJVNrLtV8ijnrz/ibsb2Nxq2
/paXU4zvMdFBbi6zuDpG7wRW3fWgU/iBgvAtXdH+EgALqH8moz0IjYrvevRYmahm
rRAc8LqKrMpuSwbZ6DyknkQoiEowUl6X/aFsynCUBrkYUKQgy/3hEobYamp08qXN
IFSPXloeS6pz8pfMUV4QpuXZ6i9rGNzTgHMe6hh7zq0RmGVJlkhSW/MFGHoJzlFV
gsV1llKD4L5NxYCHZhqu6q9qF2d7SXC9tje/vuNKQOey8UShX6wrUX/LU91huWil
C4idQ7XsIohEY9QPMtjt8cUJI1qPgYMo3fOlogrReW8nYf2Gw09R3xplsJWmHw7X
sjCWoY0gCgPWlo0ucvz38OINNXS9NGHcQEGFsVQH83AcnGsR2KOWxE9bU5BOKij8
kldJZ7TRud9M6AP1NOVR+ZMWnScrY8pFivGymDHNVzNPRNYHdKQpUvEgEezy8Fn9
E1xJ5SuHaa16GTCszVoQ1C29n/msvFmle66coXxPo7ctdS4GLuODrgduuTXIoAyV
zeN3lIrsV4t+Yc3wN5maF2q/MPEtnwz5212JKNRqGhlydRKookvD6iUegRcM+VZs
0Wt8GfYZta0gcmbf7PrsEkVJpH3OcovFnra4XnRjiYgGq98dz0WWwlUoNzUri7QP
eTo2+2WSj5oUmtZwscqu
=BgQR
-----END PGP SIGNATURE-----
--X10K5woipbiTnFcQ0PpAEGSNpqeiHCgO2--
Home |
Main Index |
Thread Index |
Old Index