Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Joel Brobecker <brobecker@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [patch] Do not open Python scripts twice #2  [Re: [RFC] Crash sourcing Python script on Windows]
Date: Mon, 23 Jan 2012 18:41:00 -0000	[thread overview]
Message-ID: <4F1DA92A.4020207@redhat.com> (raw)
In-Reply-To: <20120123181125.GA26683@host2.jankratochvil.net>

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 <stdio.h>],
> +	[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


  reply	other threads:[~2012-01-23 18:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-28 23:24 [RFC] Crash sourcing Python script on Windows Joel Brobecker
2011-09-29  2:00 ` Paul_Koning
2011-09-29  2:19   ` John Spencer
2011-09-29  4:47     ` Joel Brobecker
2011-09-29  7:30       ` Eli Zaretskii
2011-09-29  8:54         ` Kai Tietz
2011-09-29  9:48           ` Eli Zaretskii
2011-09-29  9:51             ` Kai Tietz
2011-09-29 10:54       ` Pedro Alves
2011-09-29 12:33         ` Eli Zaretskii
2011-09-29 12:48           ` Kai Tietz
2011-09-29 13:19           ` Pedro Alves
2011-09-29  7:26     ` Eli Zaretskii
2011-10-03 20:05     ` Tom Tromey
2011-09-29  7:20   ` Eli Zaretskii
2011-10-03 20:02 ` Tom Tromey
2011-10-03 20:53   ` Joel Brobecker
2011-10-04 17:08     ` Tom Tromey
2012-01-23 18:14 ` [patch] Do not open Python scripts twice #2 [Re: [RFC] Crash sourcing Python script on Windows] Jan Kratochvil
2012-01-23 18:41   ` Pedro Alves [this message]
2012-01-23 21:55     ` Jan Kratochvil
2012-01-23 22:08       ` Doug Evans
2012-01-23 22:47         ` Jan Kratochvil
2012-01-23 23:47           ` Doug Evans
2012-01-24 14:45             ` Jan Kratochvil
2012-01-24 18:56               ` Doug Evans
2012-01-24 19:41                 ` Jan Kratochvil
2012-01-24 22:20                   ` Doug Evans
2012-01-24 23:49                     ` Jan Kratochvil
2012-01-25 22:30                       ` Jan Kratochvil
2012-01-26  7:18                         ` Joel Brobecker
2012-01-26 22:03                           ` [commit] " Jan Kratochvil
2012-01-24 15:15             ` Pedro Alves
2012-01-23 19:57   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F1DA92A.4020207@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox