From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3238 invoked by alias); 23 Jan 2012 18:39:12 -0000 Received: (qmail 3091 invoked by uid 22791); 23 Jan 2012 18:39:11 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 18:38:57 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NIcZe6008877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Jan 2012 13:38:36 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0NIcY0V030563; Mon, 23 Jan 2012 13:38:34 -0500 Message-ID: <4F1DA92A.4020207@redhat.com> Date: Mon, 23 Jan 2012 18:41:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: Jan Kratochvil CC: Joel Brobecker , gdb-patches@sourceware.org Subject: Re: [patch] Do not open Python scripts twice #2 [Re: [RFC] Crash sourcing Python script on Windows] References: <1317251996-12146-1-git-send-email-brobecker@adacore.com> <20120123181125.GA26683@host2.jankratochvil.net> In-Reply-To: <20120123181125.GA26683@host2.jankratochvil.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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/msg00790.txt.bz2 On 01/23/2012 06:11 PM, Jan Kratochvil wrote: > Hello Joel, > > On Thu, 29 Sep 2011 01:19:56 +0200, Joel Brobecker wrote: >> As a result, I decided >> to apply the workaround unconditionally on all platforms. >> I don't see this as a big performance impact in practice. > > follow-up to: > [patch] Code cleanup-like: Do not open Python scripts twice > http://sourceware.org/ml/gdb-patches/2012-01/msg00774.html > > While I agree it was not such a big degradation of GDB I do not find > acceptable degrading normal platforms just due to MS-Windows defects. Agreed. To be honest, it's not a defect, it's a personality trait... > --- a/gdb/configure.ac > +++ b/gdb/configure.ac > @@ -1566,6 +1566,46 @@ aix*) > ;; > esac > > +# 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. The layout of both libc's could be the same, but you'd still (maybe) crash. It's more about the private global state maintained by each of the libc's. E.g., file descriptor N of gdb's libc has no meaning the python's libc -- each libc has its own file descriptor table. > +if test "${have_libpython}" != no; then > + AC_CACHE_CHECK([whether FILE * is compatible with Python], > + [gdb_cv_python_filep_compat], [ > + old_CFLAGS="$CFLAGS" > + CFLAGS="$CFLAGS $PYTHON_CFLAGS" > + old_CPPFLAGS="$CPPFLAGS" > + CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS" > + old_LIBS="$LIBS" > + LIBS="$LIBS $PYTHON_LIBS" > + : >conftest.empty > + gdb_cv_python_filep_compat=no > + AC_RUN_IFELSE( > + AC_LANG_PROGRAM( > + [#include "]${have_libpython}[/Python.h" > + #include ], > + [const char *filename = "conftest.empty"; > + FILE *f = fopen (filename, "r"); > + if (f == NULL) > + return 1; > + Py_Initialize (); > + PyRun_File (f, filename, Py_file_input, PyDict_New (), PyDict_New ()); This is undefined behavior in the supposedly crashing case. Hopefully this doesn't happen to succeed by running some other random program. :-) The patch looks good to me. -- Pedro Alves