From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7537 invoked by alias); 23 Jan 2012 22:00:14 -0000 Received: (qmail 7520 invoked by uid 22791); 23 Jan 2012 22:00:13 -0000 X-SWARE-Spam-Status: No, hits=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 21:59:59 +0000 Received: by vbbfd1 with SMTP id fd1so1131355vbb.0 for ; Mon, 23 Jan 2012 13:59:58 -0800 (PST) Received: by 10.52.90.71 with SMTP id bu7mr4899123vdb.63.1327355998874; Mon, 23 Jan 2012 13:59:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.90.71 with SMTP id bu7mr4899113vdb.63.1327355998771; Mon, 23 Jan 2012 13:59:58 -0800 (PST) Received: by 10.220.229.1 with HTTP; Mon, 23 Jan 2012 13:59:58 -0800 (PST) In-Reply-To: <20120123210850.GA28792@host2.jankratochvil.net> References: <1317251996-12146-1-git-send-email-brobecker@adacore.com> <20120123181125.GA26683@host2.jankratochvil.net> <4F1DA92A.4020207@redhat.com> <20120123210850.GA28792@host2.jankratochvil.net> Date: Mon, 23 Jan 2012 22:08:00 -0000 Message-ID: Subject: Re: [patch] Do not open Python scripts twice #2 [Re: [RFC] Crash sourcing Python script on Windows] From: Doug Evans To: Jan Kratochvil Cc: Pedro Alves , Joel Brobecker , gdb-patches@sourceware.org X-System-Of-Record: true X-Gm-Message-State: ALoCoQmPEMX4I7Z8Y6dkxJaYGy0BXtpU7uts9zkLJBhWCaaIpo/eGvfPqkTBuCzKUcP9NacG6kiy4JWw7eaObnQja62YLuByQdKosiQGE/97yYlUSD9h05ZrpVxLXAonm9Wq+zFeraK3SQnaelEMtafi2P8rnuLqkw== Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00796.txt.bz2 On Mon, Jan 23, 2012 at 1:08 PM, Jan Kratochvil wrote: > On Mon, 23 Jan 2012 19:38:34 +0100, Pedro Alves wrote: >> > +# MS-Windows platform may have Python compiled with different libc >> > +# having the FILE structure layout incompatible between libraries. >> >> It is not just about the layout. =A0The layout of both libc's could be t= he >> same, but you'd still (maybe) crash. =A0It's more about the private glob= al >> state maintained by each of the libc's. =A0E.g., file descriptor N of >> gdb's libc has no meaning the python's libc -- each libc has its own >> file descriptor table. > > I have updated the text. > > >> This is undefined behavior in the supposedly crashing case. =A0Hopefully= this >> doesn't happen to succeed by running some other random program. =A0:-) > > Yes, my fear is that if for example the only problem is fd assignments it= may > try to read from a closed descriptor possibly behaving as empty file and = it > would falsely pass. =A0Better test would be it did really read some test = Python > code but a minimal such testcase looks pretty complicated to me for confi= gure. > But when Joel was talking about "crash" this simple test may be enough. > > >> The patch looks good to me. > > These are the reasons why I would prefer a real MS-Windows test of it. > > > Thanks, > Jan > > > gdb/ > 2012-01-23 =A0Jan Kratochvil =A0 > > =A0 =A0 =A0 =A0Do not open script filenames twice. > =A0 =A0 =A0 =A0* cli/cli-cmds.c (source_script_from_stream): Pass to > =A0 =A0 =A0 =A0source_python_script also STREAM. > =A0 =A0 =A0 =A0* config.in: Regenerate. > =A0 =A0 =A0 =A0* configure: Regenerate. > =A0 =A0 =A0 =A0* configure.ac (HAVE_PYTHON_FILEP_COMPAT): New test. > =A0 =A0 =A0 =A0* python/py-auto-load.c (source_section_scripts): Pass to > =A0 =A0 =A0 =A0source_python_script_for_objfile also STREAM. > =A0 =A0 =A0 =A0(auto_load_objfile_script): Pass to source_python_script_f= or_objfile > =A0 =A0 =A0 =A0also INPUT. > =A0 =A0 =A0 =A0* python/python-internal.h (source_python_script_for_objfi= le): New > =A0 =A0 =A0 =A0parameter file, rename parameter file to filename. > =A0 =A0 =A0 =A0* python/python.c (python_run_simple_file): Call PyRun_Sim= pleFile > =A0 =A0 =A0 =A0instead if HAVE_PYTHON_FILEP_COMPAT. > =A0 =A0 =A0 =A0(source_python_script, source_python_script_for_objfile) > =A0 =A0 =A0 =A0(source_python_script): New parameter file, rename paramet= er file to > =A0 =A0 =A0 =A0filename. =A0Pass FILENAME to python_run_simple_file. > =A0 =A0 =A0 =A0* python/python.h (source_python_script): New parameter fi= le, rename > =A0 =A0 =A0 =A0parameter file to filename. Hi. Do you have any data that shows there is a problem with the double opening? [I'm kinda uncomfortable with this patch, as is.]