From owner-freebsd-dtrace@freebsd.org Wed Dec 14 22:53:42 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FAD8C77428 for ; Wed, 14 Dec 2016 22:53:42 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.allbsd.org", Issuer "RapidSSL SHA256 CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 125E6D70 for ; Wed, 14 Dec 2016 22:53:38 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail-d.allbsd.org (p2027-ipbf1605funabasi.chiba.ocn.ne.jp [123.225.191.27]) (authenticated bits=56) by mail.allbsd.org (8.15.2/8.15.2) with ESMTPSA id uBEMrDEh010660 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) (Client CN "/OU=GT07882699/OU=See+20www.rapidssl.com/resources/cps+20+28c+2915/OU=Domain+20Control+20Validated+20-+20RapidSSL+28R+29/CN=*.allbsd.org", Issuer "/C=US/O=GeoTrust+20Inc./CN=RapidSSL+20SHA256+20CA+20-+20G3") for ; Thu, 15 Dec 2016 07:53:33 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from alph.allbsd.org (alph.allbsd.org [192.168.0.10]) by mail-d.allbsd.org (8.15.2/8.15.2) with ESMTPS id uBEMpwcq033205 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 15 Dec 2016 07:51:58 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.allbsd.org (8.15.2/8.15.2) with ESMTPA id uBEMpuUH033202 for ; Thu, 15 Dec 2016 07:51:57 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Thu, 15 Dec 2016 07:51:24 +0900 (JST) Message-Id: <20161215.075124.1459885758696268380.hrs@allbsd.org> To: freebsd-dtrace@FreeBSD.org Subject: malformed symbol From: Hiroki Sato X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart0(Thu_Dec_15_07_51_24_2016_391)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-4.4.3 (mail.allbsd.org [133.31.130.32]); Thu, 15 Dec 2016 07:53:34 +0900 (JST) X-Spam-Status: No, score=-99.7 required=13.0 tests=CONTENT_TYPE_PRESENT, QENCPTR1,QENCPTR2,USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gatekeeper.allbsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Dec 2016 22:53:42 -0000 ----Security_Multipart0(Thu_Dec_15_07_51_24_2016_391)-- Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Dec_15_07_51_24_2016_877)--" Content-Transfer-Encoding: 7bit ----Next_Part(Thu_Dec_15_07_51_24_2016_877)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I noticed that a simple USDT definition caused an odd error. The source files in question are as follows (a complete tarball is attached to this email): sample.c: | #include | #include | #include | | #include "sample_probes.h" | | int | main(void) | { | ssize_t i; | char buf[80]; | | i = read(STDIN_FILENO, buf, sizeof(buf)); | SAMPLE_FIRST_READ(i, buf); | | return (0); | } sample_probes.d: | provider sample { | probe first__read(ssize_t, char *); | }; Makefile: | PROG= sample | MAN= | SRCS= sample.c sample_probes.d | |.include Note that the program itself is useless because this is a minimal working example to reproduce the symptom. It causes the following error: | dtrace -C -x nolibs -h -s sample_probes.d | rm -f .depend | echo sample.full: /usr/lib/libc.a >> .depend | cc -O2 -pipe -g -I/var/home/hrs/sample -MD -MF.depend.sample.o -MTsample.o -std=gnu99 -fstack-protector-strong -Qunused-arguments -c sample.c -o sample.o | dtrace -C -x nolibs -G -o sample_probes.o -s sample_probes.d sample.o | cc -O2 -pipe -g -I/var/home/hrs/sample -std=gnu99 -fstack-protector-strong -Qunused-arguments -o sample.full sample.o sample_probes.o | sample.o: In function `main': | /var/home/hrs/sample/sample.c:13: undefined reference to `ead' | cc: error: linker command failed with exit code 1 (use -v to see invocation) | *** Error code 1 A symbol "read" in sample.o seems to be rewritten in the "dtrace -G" line. Sample.o just after compilation of sample.c had the correct symbol name like the following: % nm sample.o U __dtrace_sample___first__read U __stack_chk_fail U __stack_chk_guard 0000000000000000 T main U read % dtrace -C -x nolibs -G -o sample_probes.o -s sample_probes.d sample.o % nm sample.o 0000000000000000 A __dtrace_sample___first-read U __stack_chk_fail U __stack_chk_guard U ead 0000000000000000 T main And it worked when I changed the probe name with "first__readx". This was reproducible on 11.x and 12.x, not on 10.x. Could anyone try this and let me know if this is reproducible on your 11.x or 12.x box? I guess this is a regression of symbol rewrite routine such as s/__/-/ in the dtrace utility while I have not investigated the details yet. Or am I missing something here? -- Hiroki ----Next_Part(Thu_Dec_15_07_51_24_2016_877)-- Content-Type: Application/Octet-Stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="sample-20161215-1.tar.gz" H4sIAPnHUVgAA+2VW2vCMBSA+9r8iuBe2iE1vdmBU5DphuAN69sYpdo4g1olaQfb2H9fqvUKW2Gs Dlm+l6anSZP05Dtl/mI1xyUpTxBCjmNDCVkOsvSD6x6om8iwTMt0bBMi3UDIlqCd66pSYhb5lC9l Stm3/bKep/vYXS8Etsl/x5/hCZnjXObg36Nctr7Ov64b+/xbFs9/0pAgymU1J/zz/PcHvYeqvDkF oFPvVmXgDu7cbUgbw03DW9HlCDMtAEAj4XgeBxjejlig8fiztpjVwF/vRPATUv+32c5ljiz/Teug /pvOxn9d+H8OrnYys1dWWvnUX2jTGjgIR8GcjI5jcUh4OIntg4XjOjEtAEDCCCx8EiovSxKo4B3I jJE37EWQVIA8nvoUjuLJ4w16qgAgE1iFFPuB4g4bra5332o3u71i0qMIk2HLicLbqsqHuvVOv93k XQbu0Bs06w2FrDuqyXsojmIaQgXxuw9RlTI48n9X5H93jiz/kWOc+G/zEcL/c8Az/kICTNPfPOSS rg8BnBDKIs9bG5lqW4RrZ68TsSrCLIFAILhoPgGJ7BmNABIAAA== ----Next_Part(Thu_Dec_15_07_51_24_2016_877)---- ----Security_Multipart0(Thu_Dec_15_07_51_24_2016_391)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlhRzOwACgkQTyzT2CeTzy2XtQCcDwMUh4c/6mH1PKeikadIGmE/ yE4AnRHx+4kh1/jFsxvigfS2wDRkAQd/ =i9jC -----END PGP SIGNATURE----- ----Security_Multipart0(Thu_Dec_15_07_51_24_2016_391)---- From owner-freebsd-dtrace@freebsd.org Wed Dec 14 22:56:16 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36261C77459 for ; Wed, 14 Dec 2016 22:56:16 +0000 (UTC) (envelope-from rm@joyent.com) Received: from mail-pg0-x234.google.com (mail-pg0-x234.google.com [IPv6:2607:f8b0:400e:c05::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 133A4DEE for ; Wed, 14 Dec 2016 22:56:16 +0000 (UTC) (envelope-from rm@joyent.com) Received: by mail-pg0-x234.google.com with SMTP id f188so12576533pgc.3 for ; Wed, 14 Dec 2016 14:56:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joyent.com; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=MP0GQSVi3DG4dfO9PHRcnccaA3KSMKUXDWrbm66iDxM=; b=WywVcDsyyICPFOJFNmBz1JZAvI0if1U001jJ7cdertSjnqJPBZhMJKdVn4YqadhvyT wzbI+XQbMB3MTPE4xGQskY2QHB7dZ2G1/LET6CwjK9EfSapFxCoox2RDcZc0r94uuJ+Q S0n5Y8XY3+c2J3CqJrHeuR+ocgrvj2geJTXUs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=MP0GQSVi3DG4dfO9PHRcnccaA3KSMKUXDWrbm66iDxM=; b=NO7zakvodp36niAqPaFBiqbvZvpB7zWsLVYrq1A+PjSBFwUWCENJs4BEytj5leZJ3n rCZDkjgCydf+nNxCYMgLx/hepH8owGl1AKvpSRfagmZVetY1LkfNhkXrYCWcwLu1MBjs wkISmMPSZ8uVPp6riSY3ZauNRgul3yz1gy4utjpQD2X+XK+E8tjRx7oDL7XeYB2cEGAM 14pwxC2hkzy/dBRbQYyqopmh9rQXU22eHcscru5iUShzkaJ3N1Vk4hK8r8z5kF92HCCP tZzzOVB/qAc3KAvZY9MfYPms9BwDQAB3yIrwnCwkwRkhzPIXclSqPKOellepct5Q232Y n0Ow== X-Gm-Message-State: AKaTC02d28ebYCSwP3dFznzjeFrlsEDPtPVeWALKw2BB9S+sG1Ui5JjdKs9RtPgp92ySWqOK X-Received: by 10.99.151.1 with SMTP id n1mr189779198pge.122.1481756175118; Wed, 14 Dec 2016 14:56:15 -0800 (PST) Received: from zanarkand.local ([208.184.5.170]) by smtp.gmail.com with ESMTPSA id b12sm89501206pfb.78.2016.12.14.14.56.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 14:56:13 -0800 (PST) Subject: Re: malformed symbol To: freebsd-dtrace@freebsd.org References: <20161215.075124.1459885758696268380.hrs@allbsd.org> From: Robert Mustacchi Message-ID: <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com> Date: Wed, 14 Dec 2016 14:56:12 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: <20161215.075124.1459885758696268380.hrs@allbsd.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Dec 2016 22:56:16 -0000 On 12/14/16 14:51 , Hiroki Sato wrote: > This was reproducible on 11.x and 12.x, not on 10.x. Could anyone > try this and let me know if this is reproducible on your 11.x or 12.x > box? I guess this is a regression of symbol rewrite routine such as > s/__/-/ in the dtrace utility while I have not investigated the > details yet. Or am I missing something here? We've seen something similar on illumos that corresponds with newer binutils versions (2.26). See https://www.illumos.org/issues/6653. Robert From owner-freebsd-dtrace@freebsd.org Thu Dec 15 05:56:20 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E279C800CC for ; Thu, 15 Dec 2016 05:56:20 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.allbsd.org", Issuer "RapidSSL SHA256 CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8DD7019EF for ; Thu, 15 Dec 2016 05:56:18 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail-d.allbsd.org (p2027-ipbf1605funabasi.chiba.ocn.ne.jp [123.225.191.27]) (authenticated bits=56) by mail.allbsd.org (8.15.2/8.15.2) with ESMTPSA id uBF5tqx6096144 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) (Client CN "/OU=GT07882699/OU=See+20www.rapidssl.com/resources/cps+20+28c+2915/OU=Domain+20Control+20Validated+20-+20RapidSSL+28R+29/CN=*.allbsd.org", Issuer "/C=US/O=GeoTrust+20Inc./CN=RapidSSL+20SHA256+20CA+20-+20G3"); Thu, 15 Dec 2016 14:56:13 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from alph.allbsd.org (alph.allbsd.org [192.168.0.10]) by mail-d.allbsd.org (8.15.2/8.15.2) with ESMTPS id uBF5sZt9036175 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 15 Dec 2016 14:54:35 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.allbsd.org (8.15.2/8.15.2) with ESMTPA id uBF5sZCP036172; Thu, 15 Dec 2016 14:54:35 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Thu, 15 Dec 2016 14:54:24 +0900 (JST) Message-Id: <20161215.145424.2283983185637049413.hrs@allbsd.org> To: rm@joyent.com Cc: freebsd-dtrace@freebsd.org Subject: Re: malformed symbol From: Hiroki Sato In-Reply-To: <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com> References: <20161215.075124.1459885758696268380.hrs@allbsd.org> <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com> X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart(Thu_Dec_15_14_54_24_2016_334)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-4.4.3 (mail.allbsd.org [133.31.130.32]); Thu, 15 Dec 2016 14:56:14 +0900 (JST) X-Spam-Status: No, score=-99.9 required=13.0 tests=CONTENT_TYPE_PRESENT, QENCPTR1,USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gatekeeper.allbsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2016 05:56:20 -0000 ----Security_Multipart(Thu_Dec_15_14_54_24_2016_334)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Robert Mustacchi wrote in <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com>: rm> On 12/14/16 14:51 , Hiroki Sato wrote: rm> > This was reproducible on 11.x and 12.x, not on 10.x. Could anyone rm> > try this and let me know if this is reproducible on your 11.x or 12.x rm> > box? I guess this is a regression of symbol rewrite routine such as rm> > s/__/-/ in the dtrace utility while I have not investigated the rm> > details yet. Or am I missing something here? rm> rm> We've seen something similar on illumos that corresponds with newer rm> binutils versions (2.26). See https://www.illumos.org/issues/6653. Thank you for the info. Certainly passing -no-integrated-as flag to clang to make it use an old gas avoids this issue. Simply doing objcopy sample.o before "dtrace -G" is another workaround. -- Hiroki ----Security_Multipart(Thu_Dec_15_14_54_24_2016_334)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlhSMBAACgkQTyzT2CeTzy1nigCgy8pQrp41RhIx4PfouUN1H5yV vAcAnin5e6sgQE8k33gqAYpVWzDgS4/x =h6MM -----END PGP SIGNATURE----- ----Security_Multipart(Thu_Dec_15_14_54_24_2016_334)---- From owner-freebsd-dtrace@freebsd.org Thu Dec 15 22:57:08 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE9F0C820E5 for ; Thu, 15 Dec 2016 22:57:08 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from smtp.hungerhost.com (smtp.hungerhost.com [216.38.51.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7E8D3E5; Thu, 15 Dec 2016 22:57:08 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from pool-108-46-177-117.nycmny.fios.verizon.net ([108.46.177.117]:60615 helo=[192.168.1.4]) by vps.hungerhost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cHexW-0003l9-Q0; Thu, 15 Dec 2016 17:57:06 -0500 From: "George Neville-Neil" To: "Hiroki Sato" Cc: rm@joyent.com, freebsd-dtrace@freebsd.org Subject: Re: malformed symbol Date: Thu, 15 Dec 2016 17:57:05 -0500 Message-ID: <0921189E-481D-4F8D-BAEA-6B656EE5ECFB@neville-neil.com> In-Reply-To: <20161215.145424.2283983185637049413.hrs@allbsd.org> References: <20161215.075124.1459885758696268380.hrs@allbsd.org> <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com> <20161215.145424.2283983185637049413.hrs@allbsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=_MailMate_7844CD1C-DEA1-4736-B262-9469CD1E0B1B_="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Mailer: MailMate (1.9.6r5310) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vps.hungerhost.com X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - neville-neil.com X-Get-Message-Sender-Via: vps.hungerhost.com: authenticated_id: gnn@neville-neil.com X-Authenticated-Sender: vps.hungerhost.com: gnn@neville-neil.com X-Source: X-Source-Args: X-Source-Dir: X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2016 22:57:08 -0000 This is an OpenPGP/MIME signed message (RFC 3156 and 4880). --=_MailMate_7844CD1C-DEA1-4736-B262-9469CD1E0B1B_= Content-Type: text/plain; markup=markdown On 15 Dec 2016, at 0:54, Hiroki Sato wrote: > Robert Mustacchi wrote > in <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com>: > > rm> On 12/14/16 14:51 , Hiroki Sato wrote: > rm> > This was reproducible on 11.x and 12.x, not on 10.x. Could anyone > rm> > try this and let me know if this is reproducible on your 11.x or 12.x > rm> > box? I guess this is a regression of symbol rewrite routine such as > rm> > s/__/-/ in the dtrace utility while I have not investigated the > rm> > details yet. Or am I missing something here? > rm> > rm> We've seen something similar on illumos that corresponds with newer > rm> binutils versions (2.26). See https://www.illumos.org/issues/6653. > > Thank you for the info. Certainly passing -no-integrated-as flag to > clang to make it use an old gas avoids this issue. Simply doing > objcopy sample.o before "dtrace -G" is another workaround. > Can you open a PR for this one, so we can track it? Thanks, George --=_MailMate_7844CD1C-DEA1-4736-B262-9469CD1E0B1B_= Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iEYEARECAAYFAlhTH8IACgkQYdh2wUQKM9Kd0gCgoEMl57mebuSFC7OeCu5+yxqb 13EAoOUYa4W2J2FgIhGDbiYvk70DmXC+ =DXci -----END PGP SIGNATURE----- --=_MailMate_7844CD1C-DEA1-4736-B262-9469CD1E0B1B_=-- From owner-freebsd-dtrace@freebsd.org Sat Dec 17 06:13:30 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3205DC84D41 for ; Sat, 17 Dec 2016 06:13:30 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.allbsd.org", Issuer "RapidSSL SHA256 CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 96D821CCD for ; Sat, 17 Dec 2016 06:13:28 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail-d.allbsd.org (p2027-ipbf1605funabasi.chiba.ocn.ne.jp [123.225.191.27]) (authenticated bits=56) by mail.allbsd.org (8.15.2/8.15.2) with ESMTPSA id uBH6D28g045696 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) (Client CN "/OU=GT07882699/OU=See+20www.rapidssl.com/resources/cps+20+28c+2915/OU=Domain+20Control+20Validated+20-+20RapidSSL+28R+29/CN=*.allbsd.org", Issuer "/C=US/O=GeoTrust+20Inc./CN=RapidSSL+20SHA256+20CA+20-+20G3") for ; Sat, 17 Dec 2016 15:13:22 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from alph.allbsd.org (alph.allbsd.org [192.168.0.10]) by mail-d.allbsd.org (8.15.2/8.15.2) with ESMTPS id uBH6BlBO060177 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sat, 17 Dec 2016 15:11:47 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.allbsd.org (8.15.2/8.15.2) with ESMTPA id uBH6BiSd060171 for ; Sat, 17 Dec 2016 15:11:46 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Sat, 17 Dec 2016 15:10:14 +0900 (JST) Message-Id: <20161217.151014.1579687141761225852.hrs@allbsd.org> To: freebsd-dtrace@freebsd.org Subject: clause-local variable with copyin() From: Hiroki Sato X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart0(Sat_Dec_17_15_10_14_2016_904)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-4.4.3 (mail.allbsd.org [133.31.130.32]); Sat, 17 Dec 2016 15:13:23 +0900 (JST) X-Spam-Status: No, score=-99.9 required=13.0 tests=CONTENT_TYPE_PRESENT, QENCPTR1,USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gatekeeper.allbsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2016 06:13:30 -0000 ----Security_Multipart0(Sat_Dec_17_15_10_14_2016_904)-- Content-Type: Multipart/Mixed; boundary="--Next_Part(Sat_Dec_17_15_10_14_2016_434)--" Content-Transfer-Encoding: 7bit ----Next_Part(Sat_Dec_17_15_10_14_2016_434)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I have trouble with clause-local variable. A minimum working example is attached. The "sample" program simply displays a string in an infinite loop with a USDT named as "dump-str", sample_debug.d does copyin() and printf() the whole buffer assuming it is nul-terminated: | sample$target:::dump-str | { | this->st = copyin(arg0, 1024); | | printf("(1)st = %s, %p\n", stringof(this->st), | (char *)this->st); | } | sample$target:::dump-str | { | printf("(2)st = %s, %p\n", stringof(this->st), | (char *)this->st); | printf("(3)st = %s\n", stringof(copyin(arg0, 1024))); | } The odd part is that it does not work with splitting the probe into the two as above but works fine without the split. The result was as follows: | % sudo make test | dtrace -C -I/var/home/hrs/sample_str -s sample_debug.d -c /var/home/hrs/sample_str/sample | dtrace: script 'sample_debug.d' matched 5 probes | CPU ID FUNCTION:NAME | 0 61714 main:dump-str (1)st = test-uname, fffffe0001a19118 | | 0 61714 main:dump-str (2)st = , fffffe0001a19118 | (3)st = test-uname this->st became empty at the beginning of the second probe. The symptom varied depending on the address of this->st, so I am guessing that this->st was incorrectly freed at the end of the first probe. If I use copyinstr(arg0) instead of copyin(), this problem does not occur. Do I misunderstand clause-local variable? I noticed this when I use if-then clause which was recently implemented as a syntax sugar to split a probe automatically. The following ended up with the same result: | sample$target:::dump-str | { | this->st = copyin(arg0, 1024); | | printf("(1)st = %s, %p\n", stringof(this->st), | (char *)this->st); | if (0) { | } | printf("(2)st = %s, %p\n", stringof(this->st), | (char *)this->st); | printf("(3)st = %s\n", stringof(copyin(arg0, 1024))); | } -- Hiroki ----Next_Part(Sat_Dec_17_15_10_14_2016_434)-- Content-Type: Application/Octet-Stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="sample_str.tar.gz" H4sIAF3RVFgAA+1XbW/aMBDma/wrTqxVk4mkTkiIBKNS105Tp7EiWD+1FQqJgagQotip1FX97zvT hJexlg+jTKh5hJTofLmzfff4MdybxGPW4yI5Lr0VKKWu60CJ2i61zaXnAmBWqeWYDrUdF6hp1dxq CZw3m9ESUi68BKcySvirfpvGs3XMn3sCvqh/y7tjg3DMtp4D96NWs1+uv2Vl9cefi3tHTbtqOiWg W5/JX/DO69/uXH5tKs9dQFqnP5oK6XbOurnJ8CHrkDiZ9hk3AkIE46JOlEAkns9APwP94uDROLvq nF90nkDn+RcB66dDIwDdBxy//PxNjh9nqYgRRv44DRh86vPAwOhDY3J3Qv73frw3LPE/r/jWc2zi v2OaOf+tquXO+E/dgv+7wIc5DfkDP469xJsYoxOyZBbBOOyv2cLpn6YkjIartjQK0VPaFsby6nEy KhMSRoJMvDBS76dhoJFHovgjLwEurk1q2bcNQhSMHvnxg8pFBcry/NHTyJuwcgV4+ItNBzigaQ3p d70wgA7mLTTh6IYe4dhgmoDaaGiACZTuaav9/Uvv/KrV7nV/dlR1lvKjhp+hqxLjYsRALR/ym0gm ebbyMWOxasr3J5xUwkSaRKBSNDzt68G1xv/5Qb+9HJv4T/HOl/PfqpnIfwf9C/7vAljt+zBgSSba khyzBoAgncQ92Rc5NbDJG/va5QVewjr/s2vbFnNs4r9tW/P/f9Wa1H/HrhX6vxM8F/0A92DIRL1e l7TXsRukDItRyPUTLlBD/Wn8gAqNXrQCUpY1Kcu5TKImzrwOeQUO40wy5X0AhTgPolWIAoj8OJnb pXi+Not5EuufkiziVPM4qzHWl6jts7AXKFCgwAb8Bpa19lwAFgAA ----Next_Part(Sat_Dec_17_15_10_14_2016_434)---- ----Security_Multipart0(Sat_Dec_17_15_10_14_2016_904)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlhU1sYACgkQTyzT2CeTzy31swCdFKup6gWMlbd1JO9eO2QV1g5k ju4AoNFUotWuD5DthI1AtegovL6dFUHL =gBnV -----END PGP SIGNATURE----- ----Security_Multipart0(Sat_Dec_17_15_10_14_2016_904)---- From owner-freebsd-dtrace@freebsd.org Sat Dec 17 06:13:29 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38624C84D36 for ; Sat, 17 Dec 2016 06:13:29 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.allbsd.org", Issuer "RapidSSL SHA256 CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B705C1CCE for ; Sat, 17 Dec 2016 06:13:28 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail-d.allbsd.org (p2027-ipbf1605funabasi.chiba.ocn.ne.jp [123.225.191.27]) (authenticated bits=56) by mail.allbsd.org (8.15.2/8.15.2) with ESMTPSA id uBH6D2hp045697 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) (Client CN "/OU=GT07882699/OU=See+20www.rapidssl.com/resources/cps+20+28c+2915/OU=Domain+20Control+20Validated+20-+20RapidSSL+28R+29/CN=*.allbsd.org", Issuer "/C=US/O=GeoTrust+20Inc./CN=RapidSSL+20SHA256+20CA+20-+20G3"); Sat, 17 Dec 2016 15:13:24 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from alph.allbsd.org (alph.allbsd.org [192.168.0.10]) by mail-d.allbsd.org (8.15.2/8.15.2) with ESMTPS id uBH6BlxZ060178 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 17 Dec 2016 15:11:47 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.allbsd.org (8.15.2/8.15.2) with ESMTPA id uBH6BiSc060171; Sat, 17 Dec 2016 15:11:46 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Sat, 17 Dec 2016 15:07:59 +0900 (JST) Message-Id: <20161217.150759.295686080150201223.hrs@allbsd.org> To: gnn@neville-neil.com Cc: rm@joyent.com, freebsd-dtrace@freebsd.org Subject: Re: malformed symbol From: Hiroki Sato In-Reply-To: <0921189E-481D-4F8D-BAEA-6B656EE5ECFB@neville-neil.com> References: <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com> <20161215.145424.2283983185637049413.hrs@allbsd.org> <0921189E-481D-4F8D-BAEA-6B656EE5ECFB@neville-neil.com> X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart(Sat_Dec_17_15_07_59_2016_309)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-4.4.3 (mail.allbsd.org [133.31.130.32]); Sat, 17 Dec 2016 15:13:26 +0900 (JST) X-Spam-Status: No, score=-99.9 required=13.0 tests=CONTENT_TYPE_PRESENT, QENCPTR1,USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gatekeeper.allbsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2016 06:13:29 -0000 ----Security_Multipart(Sat_Dec_17_15_07_59_2016_309)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit "George Neville-Neil" wrote in <0921189E-481D-4F8D-BAEA-6B656EE5ECFB@neville-neil.com>: gn> gn> gn> On 15 Dec 2016, at 0:54, Hiroki Sato wrote: gn> gn> > Robert Mustacchi wrote gn> > in <6b0842f5-46e8-e90e-0cc6-ec0cbe74669a@joyent.com>: gn> > gn> > rm> On 12/14/16 14:51 , Hiroki Sato wrote: gn> > rm> > This was reproducible on 11.x and 12.x, not on 10.x. Could anyone gn> > rm> > try this and let me know if this is reproducible on your 11.x or 12.x gn> > rm> > box? I guess this is a regression of symbol rewrite routine such as gn> > rm> > s/__/-/ in the dtrace utility while I have not investigated the gn> > rm> > details yet. Or am I missing something here? gn> > rm> gn> > rm> We've seen something similar on illumos that corresponds with newer gn> > rm> binutils versions (2.26). See https://www.illumos.org/issues/6653. gn> > gn> > Thank you for the info. Certainly passing -no-integrated-as flag to gn> > clang to make it use an old gas avoids this issue. Simply doing gn> > objcopy sample.o before "dtrace -G" is another workaround. gn> > gn> gn> Can you open a PR for this one, so we can track it? Sure. I will. -- Hiroki ----Security_Multipart(Sat_Dec_17_15_07_59_2016_309)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlhU1j8ACgkQTyzT2CeTzy2DXwCgwi+vVYke3eLx4+kuKi09jZzD MlYAn398kCtRgAuh+VqCNaMxhDAUm0y5 =c6D2 -----END PGP SIGNATURE----- ----Security_Multipart(Sat_Dec_17_15_07_59_2016_309)---- From owner-freebsd-dtrace@freebsd.org Sat Dec 17 18:38:25 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CEB9C8522D for ; Sat, 17 Dec 2016 18:38:25 +0000 (UTC) (envelope-from matthew.ahrens@delphix.com) Received: from mail-it0-x22c.google.com (mail-it0-x22c.google.com [IPv6:2607:f8b0:4001:c0b::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5DC55A89 for ; Sat, 17 Dec 2016 18:38:25 +0000 (UTC) (envelope-from matthew.ahrens@delphix.com) Received: by mail-it0-x22c.google.com with SMTP id b132so18910640iti.1 for ; Sat, 17 Dec 2016 10:38:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphix.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8b+ARpGUkb7P5Kjr6ZRaTJ4wXaAba19P4WVMsISeyco=; b=Awz3z1zzcy9Wim7GtgXvstQcZeZAvcpWu3BGalJk91ixwrDb4/bziyRAPiFBLOCpoI V/6XqFHprOm6nDDwVIV/tmrGJ8cR2fapevXD7rrDf0R/IlAllFXBO2YPqD2OKmWKKpoU 0WEJ5+myMS/0nT5gEZOYB8vgdcfMSZ4NN8Gvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8b+ARpGUkb7P5Kjr6ZRaTJ4wXaAba19P4WVMsISeyco=; b=cKkmksYt5HNuAlZLESqjDbgiToDwWfqsC7KCMCwWcSV3X21ZODP/LbWPgWpHmVwXS4 vAKoycWV6cPpapWglIlKaSwWFWJBsfkmo4ixMMCEuNH/zkliQs7iTNqN22VtZZOkQQyS nvPLHgK1r3dbyfqjwVv3iTHNNKZvoOV2Q1ys7VdFqT4MIjo6sS13qsiChLiHScFfnS/z XxQyo2ndEecp8NP2Y6pdEgajFA2nH7559VSgcQP2DQQbFkmcOELI3qs5kPaGgf1koJmj mgIkYS/fUHNUyqb58Egj5Fqvbj40yV4r7vWZ+Un8TgFnS9sGV+HNRHHCYJcC8XvsaZk1 BF3Q== X-Gm-Message-State: AKaTC02+R77LX7Z/e59xDgYGnO9JHV07TqUbktw6T7XsQPOL2JtXVB0TP6BNbEYxTygG9q4qnwHZkxFEST7LhV2Z X-Received: by 10.36.184.194 with SMTP id m185mr8721624ite.3.1481999903585; Sat, 17 Dec 2016 10:38:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.224.132 with HTTP; Sat, 17 Dec 2016 10:38:23 -0800 (PST) In-Reply-To: <20161217.151014.1579687141761225852.hrs@allbsd.org> References: <20161217.151014.1579687141761225852.hrs@allbsd.org> From: Matthew Ahrens Date: Sat, 17 Dec 2016 10:38:23 -0800 Message-ID: Subject: Re: clause-local variable with copyin() To: Hiroki Sato Cc: freebsd-dtrace@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2016 18:38:25 -0000 On Fri, Dec 16, 2016 at 10:10 PM, Hiroki Sato wrote: > Hi, > > I have trouble with clause-local variable. A minimum working example > is attached. The "sample" program simply displays a string in an > infinite loop with a USDT named as "dump-str", sample_debug.d does > copyin() and printf() the whole buffer assuming it is > nul-terminated: > > | sample$target:::dump-str > | { > | this->st = copyin(arg0, 1024); > | > | printf("(1)st = %s, %p\n", stringof(this->st), > | (char *)this->st); > | } > | sample$target:::dump-str > | { > | printf("(2)st = %s, %p\n", stringof(this->st), > | (char *)this->st); > | printf("(3)st = %s\n", stringof(copyin(arg0, 1024))); > | } > > The odd part is that it does not work with splitting the probe into > the two as above but works fine without the split. The result was as > follows: > > | % sudo make test > | dtrace -C -I/var/home/hrs/sample_str -s sample_debug.d -c > /var/home/hrs/sample_str/sample > | dtrace: script 'sample_debug.d' matched 5 probes > | CPU ID FUNCTION:NAME > | 0 61714 main:dump-str (1)st = test-uname, > fffffe0001a19118 > | > | 0 61714 main:dump-str (2)st = , fffffe0001a19118 > | (3)st = test-uname > > this->st became empty at the beginning of the second probe. > > The symptom varied depending on the address of this->st, so I am > guessing that this->st was incorrectly freed at the end of the first > probe. If I use copyinstr(arg0) instead of copyin(), this problem > does not occur. > Perhaps this is a bug (or at least, unexpected behavior) with copyin(). I assume that it works fine with simple data types (e.g. numbers). > > Do I misunderstand clause-local variable? No, it should work as you are doing. So-called "clause-local" variables are actually implemented as "enabled-probe-local" variables I tried to test out your script on illumos but I got as far as this before running out of time: dtrace -h -s sample_probes.d gcc -c sample.c dtrace -G -s sample_probes.d sample.o gcc -o sample sample.o dtrace -s sample_debug.d -c ./sample dtrace: failed to compile script sample_debug.d: line 1: 'dump-str' is an invalid probe name --matt > I noticed this when I use > if-then clause which was recently implemented as a syntax sugar to > split a probe automatically. The following ended up with the same > result: > > | sample$target:::dump-str > | { > | this->st = copyin(arg0, 1024); > | > | printf("(1)st = %s, %p\n", stringof(this->st), > | (char *)this->st); > | if (0) { > | } > | printf("(2)st = %s, %p\n", stringof(this->st), > | (char *)this->st); > | printf("(3)st = %s\n", stringof(copyin(arg0, 1024))); > | } > > -- Hiroki > From owner-freebsd-dtrace@freebsd.org Sat Dec 17 18:48:59 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 121A5C8544F for ; Sat, 17 Dec 2016 18:48:59 +0000 (UTC) (envelope-from domagoj.stolfa@gmail.com) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 99C46F06; Sat, 17 Dec 2016 18:48:58 +0000 (UTC) (envelope-from domagoj.stolfa@gmail.com) Received: by mail-wm0-x242.google.com with SMTP id g23so11342848wme.1; Sat, 17 Dec 2016 10:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=do4OGJ/RzeMoLZyI93hEmqveXlFKDg2uYPU6dEJZUBo=; b=Jg+m6deHCBabbY/rY/hwyW/XP+gGktRsZ1JvtQwOkC2CwYaIkrE22/Hrc8WJ2nQaRX zuqR6XpIbxW5LilMTqDOk/6JjmiP3FWi3r/QR6Ne4r8UM5qbVuVnAYmvU35/XL6CxaKW OzQQFZkxbRojGGYvBDSnv0Y8CzOKG2rply9jCYKs3FuznG5PeMHQms/z4Yug62qjX+Gl XW6R7H4njfXUixQaIQqlhTBmq7oLq4eRBJ4eXtevqB85tQrkgO65veNA5dNlaXLU35qp VK7rAdA03kCWfc77+Ralv4Kvl/5dTxNhPpkp6tqpiTrg1Ew4y6UHMZuBbWEUfrYySnbk weFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=do4OGJ/RzeMoLZyI93hEmqveXlFKDg2uYPU6dEJZUBo=; b=Ph0TfB9DY6jwltuqCnAkf30LsnAtCmqHz+pThJMHwBWOgG4UA9rFPrBQCwBh9yKh53 5qwHef5518C0WcC4aLruiAXNjHWqCA4O1OB37Ai9H04PwLyKqtC8WDaQs9CsRRKi5p6I w6sURVGNFNFeOZEUJo+N8IdtpEZ+Z+1LsL5aB6S6j4kwCkFTmzhKorVxGJ4qezzsFOLd SiqVLjkSVIOIAXmgu/gKo8bPyM/o/t948u79QCISnmG6X7KrpadMfN8pZjPZ9856Lid/ GKGGi8tavijKUhSE6BS1eLDpV50sa8yxKCAFl7BF/uxDIB3KaKDEaG2xIeWmUAKHW3dD PVtg== X-Gm-Message-State: AIkVDXJLv2f/iHfS/u+Sr0bOFE3SeSsMlTJ0Anqbi9U2o0Drc0syx081/1d+fvmRelaI+g== X-Received: by 10.28.131.72 with SMTP id f69mr7061665wmd.135.1482000536864; Sat, 17 Dec 2016 10:48:56 -0800 (PST) Received: from freebsd-laptop (213-202-70-33.dsl.iskon.hr. [213.202.70.33]) by smtp.gmail.com with ESMTPSA id l2sm12582394wji.7.2016.12.17.10.48.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Dec 2016 10:48:55 -0800 (PST) Date: Sat, 17 Dec 2016 19:48:53 +0100 From: Domagoj Stolfa To: Hiroki Sato Cc: freebsd-dtrace@freebsd.org Subject: clause-local variable with copyin() Message-ID: <20161217184853.GA11338@freebsd-laptop> References: <20161217.151014.1579687141761225852.hrs@allbsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oyUTqETQ0mS9luUI" Content-Disposition: inline In-Reply-To: <20161217.151014.1579687141761225852.hrs@allbsd.org> User-Agent: Mutt/1.7.1 (2016-10-04) X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2016 18:48:59 -0000 --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, > I have trouble with clause-local variable. A minimum working example > is attached. The "sample" program simply displays a string in an > infinite loop with a USDT named as "dump-str", sample_debug.d does > copyin() and printf() the whole buffer assuming it is > nul-terminated: >=20 > | sample$target:::dump-str > | { > | this->st =3D copyin(arg0, 1024); > | > | printf("(1)st =3D %s, %p\n", stringof(this->st), > | (char *)this->st); > | } > | sample$target:::dump-str > | { > | printf("(2)st =3D %s, %p\n", stringof(this->st), > | (char *)this->st); > | printf("(3)st =3D %s\n", stringof(copyin(arg0, 1024))); > | } >=20 > The odd part is that it does not work with splitting the probe into > the two as above but works fine without the split. The result was as > follows: >=20 > | % sudo make test > | dtrace -C -I/var/home/hrs/sample_str -s sample_debug.d -c /var/home/hr= s/sample_str/sample > | dtrace: script 'sample_debug.d' matched 5 probes > | CPU ID FUNCTION:NAME > | 0 61714 main:dump-str (1)st =3D test-uname, ffff= fe0001a19118 > | > | 0 61714 main:dump-str (2)st =3D , fffffe0001a191= 18 > | (3)st =3D test-uname >=20 > this->st became empty at the beginning of the second probe. >=20 > The symptom varied depending on the address of this->st, so I am > guessing that this->st was incorrectly freed at the end of the first > probe. If I use copyinstr(arg0) instead of copyin(), this problem > does not occur. That does seem like what's happening based on the described behaviour and running the examples you've provided. > Do I misunderstand clause-local variable? I noticed this when I use > if-then clause which was recently implemented as a syntax sugar to > split a probe automatically. The following ended up with the same > result: >=20 > | sample$target:::dump-str > | { > | this->st =3D copyin(arg0, 1024); > | > | printf("(1)st =3D %s, %p\n", stringof(this->st), > | (char *)this->st); > | if (0) { > | } > | printf("(2)st =3D %s, %p\n", stringof(this->st), > | (char *)this->st); > | printf("(3)st =3D %s\n", stringof(copyin(arg0, 1024))); > | } No, the clause-local variables should remain intact eventhough the probe is split up into two clauses. See [1] for an example. This is reproducible on FreeBSD 12.0-CURRENT and seems like a bug. [1] http://dtrace.org/guide/chp-variables.html#chp-variables-4 --=20 Best regards, Domagoj Stolfa. --oyUTqETQ0mS9luUI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEHQB+y96lmmv+IXofwxT+ikb0YU4FAlhViJUACgkQwxT+ikb0 YU6iXAf9EtBXQ42BBrV+826ki1qk5tHaq0AYFZucRh3W3RdyrGYVKtW5sTKmt1Ap Z0qDUNbz9qwDr53gLBJAi/T8ngFvILnAkFfs1dzisLwFJM0ntoIqHrYKhgV7QsFG hZM9VK3waE39MKvoUv2SEAKULUZn6vjlvUgJfvU0CKnLGjYO7DChSTv4PoSo/U8i CQvbywPCLgkQpHsRAK3H2Qa+7MujPFxN+MKkrENG08ossUxxGdR724V5krX+MXTb y0Z0tLLUw23Up58weMzCSxWUyd6fT5beoy1fbO9uUwAMqtar0jfPmsBINmz/ZDMZ D+kmvRM7w47xPcDdNIQSOzyMfNSMRA== =iFwy -----END PGP SIGNATURE----- --oyUTqETQ0mS9luUI--