This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Code cleanup-like: Do not open Python scripts twice


On 01/23/2012 04:13 PM, Jan Kratochvil wrote:
> @@ -531,7 +542,7 @@ source_script_from_stream (FILE *stream, const char *file)
>  	{
>            /* The python support reopens the file using python functions,
>               so there's no point in passing STREAM here.  */
> -	  source_python_script (file);
> +	  source_python_script (stream, file);
>  	}

The comment looks obsolete after the change.

On 01/23/2012 04:13 PM, Jan Kratochvil wrote:
> -  /* Because we have a string for a filename, and are using Python to
> -     open the file, we need to expand any tilde in the path first.  */
> -  full_path = tilde_expand (filename);
> -  cleanup = make_cleanup (xfree, full_path);
> -  python_file = PyFile_FromString (full_path, "r");
> +  /* Deconstification of FILENAME is a Python bug.  */
> +  python_file = PyFile_FromFile (file, (char *) filename, "r",
> +				 NULL /* close */);

IIUC, this `FILE *' is result of an fopen/fdopen call from gdb.
If so, this reintroduces the same problem discussed and addressed
in last year's "[RFC] Crash sourcing Python script on Windows" discussion.

http://old.nabble.com/-RFC--Crash-sourcing-Python-script-on-Windows-td32558767.html#a32558767

In a nutshell, gdb and python may be linked with different libc's, so we
can't pass a FILE* opened in gdb's libc to python, which will use it with
its own libc, making demons fly out of your nose.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]