Bug 15810 - gdb 7.3.1/7.5 unlinks and creates .pyc-files in non-user directories
Summary: gdb 7.3.1/7.5 unlinks and creates .pyc-files in non-user directories
Status: RESOLVED INVALID
Alias: None
Product: gdb
Classification: Unclassified
Component: corefiles (show other bugs)
Version: 7.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-01 12:16 UTC by Stefan
Modified: 2013-08-02 19:15 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan 2013-08-01 12:16:16 UTC
./configure --prefix=/tmp/loc2
make
make install
strace -fFeunlink /tmp/loc2/bin/gdb

Output:

unlink("/tmp/loc2/share/gdb/python/gdb/command/__init__.pyc") = 0
unlink("/tmp/loc2/share/gdb/python/gdb/command/explore.pyc") = 0
unlink("/tmp/loc2/share/gdb/python/gdb/command/prompt.pyc") = 0
unlink("/tmp/loc2/share/gdb/python/gdb/prompt.pyc") = 0
unlink("/tmp/loc2/share/gdb/python/gdb/command/pretty_printers.pyc") = 0

Starting or running gdb shall never unlink files in the fs subtree where software is installed. gdb at least of version 7.3.1 performs some additional unlinks in the part of the filesystem where the compiler is installed when the "run" command is issued:

unlink </.../gcc-4.6.4/lib64/../share/gcc-4.6.4/python/libstdcxx/__init__.pyc>
unlink </.../gcc-4.6.4/lib64/../share/gcc-4.6.4/python/libstdcxx/v6/__init__.pyc>
unlink </.../gcc-4.6.4/lib64/../share/gcc-4.6.4/python/libstdcxx/v6/printers.pyc>

which cannot be straced but be intercepted with a preloaded shared object.

All this can be circumvented by using "--with-python=no" as configuration parameter.
Comment 1 Tom Tromey 2013-08-02 14:19:04 UTC
These unlinks come from libpython, not gdb.
They are part of Python's byte-compilation approach.
I don't think there is anything we can do about them.
So, I'm closing this.
Comment 2 Stefan 2013-08-02 14:40:28 UTC
(In reply to Tom Tromey from comment #1)
> These unlinks come from libpython, not gdb.

libpython is compiled/linked into gdb therefore these unlinks come from gdb.

> They are part of Python's byte-compilation approach.

And who has "bought" that?

> I don't think there is anything we can do about them.

You can to lots of different things only limited by your imagination:

1. You may warn the user who compiles gdb or the end user about this side
   effects.
2. You can make --with-python=no the default.
3. You can remove the python support.

> So, I'm closing this.

Can you tell me a side effect in libpython which would be strong enough to motivate you not to close this bug?
Comment 3 Tom Tromey 2013-08-02 16:44:17 UTC
My point is that this is a generic problem with Python.
If a fix must be made, it must be made there.
I don't think any of your proposed solutions are realistic.
Please don't reopen this bug.
Comment 4 Stefan 2013-08-02 18:16:26 UTC
(In reply to Tom Tromey from comment #3)
> My point is that this is a generic problem with Python.

I doubt that python considers its own documented behavior [1] as problem. The problem stems from the integration of python into gdb.

> I don't think any of your proposed solutions are realistic.

This fixes the issue:

gdb/python/python.c:
   1230   setenv ("PYTHONDONTWRITEBYTECODE", "1", 1);
   1231   Py_Initialize ();
   1232   PyEval_InitThreads ();

[1] http://docs.python.org/2/tutorial/modules.html#compiled-python-files
Comment 5 Tom Tromey 2013-08-02 18:43:15 UTC
>>   setenv ("PYTHONDONTWRITEBYTECODE", "1", 1);

Why should gdb in particular do this?
I think most things linked against libpython do not.
Comment 6 Stefan 2013-08-02 19:15:24 UTC
(In reply to Tom Tromey from comment #5)
> >>   setenv ("PYTHONDONTWRITEBYTECODE", "1", 1);
> 
> Why should gdb in particular do this?

In order to switch off the undesired side effect which may even be a security issue (i.e. symlink attack, have not checked this yet).

> I think most things linked against libpython do not.

I think most of the things linked against libpython are not debuggers run by root.