Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 153295 - x11-libs/libSM-1.0.2 prerm function failure
Summary: x11-libs/libSM-1.0.2 prerm function failure
Status: RESOLVED WORKSFORME
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 147007
  Show dependency tree
 
Reported: 2006-10-29 07:10 UTC by Fab
Modified: 2006-11-01 00:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
portage error ? (bug,1.00 KB, text/plain)
2006-10-29 07:10 UTC, Fab
Details
emerge --info (infos,2.83 KB, text/plain)
2006-10-29 07:11 UTC, Fab
Details
libSM-1.0.2.tar (libSM-1.0.2.tar,70.00 KB, application/x-tar)
2006-10-29 07:27 UTC, Fab
Details
exclude non-string values from the environment (environ.patch,677 bytes, patch)
2006-10-29 14:31 UTC, Zac Medico
Details | Diff
full log (bug,28.66 KB, text/plain)
2006-10-29 17:14 UTC, Fab
Details
binary (binary,24 bytes, text/plain)
2006-10-30 01:45 UTC, Fab
Details
myargs (myargs,151 bytes, text/plain)
2006-10-30 01:45 UTC, Fab
Details
env (env,9.74 KB, text/plain)
2006-10-30 01:46 UTC, Fab
Details
env (env,9.74 KB, text/plain)
2006-10-30 01:59 UTC, Fab
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fab 2006-10-29 07:10:03 UTC
Hi,

Today is the day of updates : emerge -uDN world
Everything is fine, except with libSM 1.0.1 removing step, after installing 1.0.2 : portage is unable to remove the old version.
See attached log file. Is this a portage issue ? (portage-2.1.2_rc1-r1)

Thanks.
Comment 1 Fab 2006-10-29 07:10:49 UTC
Created attachment 100715 [details]
portage error ?
Comment 2 Fab 2006-10-29 07:11:25 UTC
Created attachment 100716 [details]
emerge --info
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2006-10-29 07:19:46 UTC
Tarball /var/db/pkg/x11-libs/libSM-1.0.2 directory and attach it here.
Comment 4 Fab 2006-10-29 07:27:03 UTC
Created attachment 100719 [details]
libSM-1.0.2.tar

here it is.
Comment 5 Jakub Moc (RETIRED) gentoo-dev 2006-10-29 07:49:56 UTC
Reopen.
Comment 6 Zac Medico gentoo-dev 2006-10-29 14:01:02 UTC
It seems that a non-string object leaked into the config somehow.  Please post emrege --info.
Comment 7 Zac Medico gentoo-dev 2006-10-29 14:31:17 UTC
Created attachment 100742 [details, diff]
exclude non-string values from the environment

This patch should solve the problem and also help us diagnose the cause.  It will cause the specific non-string value to be written to stderr. If the patch is saved as /tmp/environ.patch, then it can be applied as follows:

cd /usr/lib/portage
patch -p0 < /tmp/environ.patch

Please post any warning messages that this patch generates.
Comment 8 Fab 2006-10-29 17:14:38 UTC
Created attachment 100751 [details]
full log

Patch applied, but it changed nothing : I don't see any difference. Very strange.
Any suggestion ?

Attached full log : emerge -1 libSM && emerge --info
Comment 9 Zac Medico gentoo-dev 2006-10-29 18:09:15 UTC
(In reply to comment #8)
> Patch applied, but it changed nothing : I don't see any difference. Very
> strange.
> Any suggestion ?

That doesn't make any sense to me.  The sanity check in the patch should catch any non-string values before they are returned from the config.environ() method.  Between there and the execve call, the environment dictionary is never modified as far as I can see.
Comment 10 Fab 2006-10-30 01:42:42 UTC
Yes, there's something wrong :

-----------------------------------------------

...

	for x, y in env.items():
		if not isinstance(y, basestring):
			print "%s=%s" % (x, y)
			continue
	
	# And switch to the new process.
	os.execve(binary, myargs, env)
...

---------------------------
	
>>> Unmerging x11-libs/libSM-1.0.1...
execve() arg 3 contains a non-string value:
   /bin/bash -c /usr/lib/portage/bin/ebuild.sh prerm
!!! FAILED prerm: 1

---------------------------




Maybe a python problem ? I rebuild it twice a few days ago, for another problem :

------------------------
     Tue Oct 17 22:34:01 2006 >>> dev-lang/python-2.4.3-r4
       merge time: 5 minutes and 6 seconds.

     Wed Oct 18 01:12:51 2006 >>> dev-lang/python-2.4.3-r4
       merge time: 5 minutes and 6 seconds.
------------------------


I'll attach content of the binary, myargs and env variables when the execve call fails.
I'm not expert in python. Is it possible to create a little program which read theses files, and try to run an os.execve() call ? If it fails, portage will be out of the problem.
Maybe you have a better/faster idea ?
Comment 11 Fab 2006-10-30 01:45:06 UTC
Created attachment 100773 [details]
binary
Comment 12 Fab 2006-10-30 01:45:37 UTC
Created attachment 100774 [details]
myargs
Comment 13 Fab 2006-10-30 01:46:09 UTC
Created attachment 100775 [details]
env
Comment 14 Fab 2006-10-30 01:59:39 UTC
Created attachment 100778 [details]
env
Comment 15 Zac Medico gentoo-dev 2006-10-31 13:43:03 UTC
I was able to reproduce the problem(In reply to comment #13)
> Created an attachment (id=100775) [edit]
> env

I was able to reproduce the problem locally using the dictionary from comment #13.  I wrote a script to eliminate values until the os.execve call would succeed.  It succeeded after the following value was removed:

'FEATURES': 'autoconfig buildpkg buildsyspkg candy ccache confcache distlocks metadata-transfer parallel-fetch sandbox sfperms strixt userfetch userpriv usersandbo\x00'
Comment 16 Zac Medico gentoo-dev 2006-10-31 13:48:26 UTC
Here is a minimal script to reproduce the problem:

#!/usr/bin/env python
import os
args=["/usr/bin/echo", "hello world"]
os.execve(args[0], args, {'FEATURES': '\x00'})

Comment 17 Fab 2006-10-31 14:21:18 UTC
Yes, I can repro here with your minimal script.

But I don't understand how this \x00 characters appeared in the FEATURES variable.
My make.conf is clean, I just tried to rewrite the part which is concerned, but I have always the same error. And I don't understand why this bug is only with libSM ?

Here is the FEATURES from my make.conf, from emerge --info and from the env dictionnary :
-----------------
FEATURES="parallel-fetch candy buildpkg buildsyspkg userfetch userpriv usersandbox splitdebug"
-----------------
FEATURES="autoconfig buildpkg buildsyspkg candy distlocks metadata-transfer parallel-fetch sandbox sfperms splitdebug strict userfetch userpriv usersandbox"
-----------------
'FEATURES': 'autoconfig buildpkg buildsyspkg candy ccache confcache distlocks metadata-transfer parallel-fetch sandbox sfperms strixt userfetch userpriv usersandbo\x00',
-----------------


Is this normal that the splitdebug feature doesn't appear in the env dictionnary ?

Will try to emerge --sync && emerge -uDN world to see if the bug appear with another packages.

Very strange o_O
Comment 18 Zac Medico gentoo-dev 2006-10-31 14:43:29 UTC
(In reply to comment #17)
> Is this normal that the splitdebug feature doesn't appear in the env
> dictionnary ?

That FEATURES value would have been loaded from /var/db/pkg/x11-libs/libSM-1.0.2/FEATURES just prior to the prerm phase.  The usersandbo\x00 looks awfully strange, as if a null terminator somehow leaked into the environment and replaced the x in usersandbox.

I can see why python would disallow null bytes in environment variables, since C strings are terminated by null bytes.  I suppose portage could scan for null bytes and remove them if necessary.  Here's a demonstration of a null byte causing part of an environment variable to be ignored:

#include <unistd.h>
int main()
{
	char *const myargv[] = {"/usr/bin/env", NULL};
	char *const myenvp[] = {"FEATURES=test\0 ignored text here", NULL};
	execve(myargv[0], myargv, myenvp);
}


Comment 19 Fab 2006-10-31 15:02:31 UTC
(In reply to comment #18)
> That FEATURES value would have been loaded from
> /var/db/pkg/x11-libs/libSM-1.0.2/FEATURES just prior to the prerm phase.


Ok, the /var/db/pkg/x11-libs/libSM-1.0.1/FEATURES file seems to be corrupt :

-----------------------------------
$ file /var/db/pkg/x11-libs/libSM-1.0.1/FEATURES
/var/db/pkg/x11-libs/libSM-1.0.1/FEATURES: data

$ file /var/db/pkg/x11-libs/libSM-1.0.2/FEATURES
/var/db/pkg/x11-libs/libSM-1.0.2/FEATURES: ASCII text
-----------------------------------


Can I remove it ?
Comment 20 Zac Medico gentoo-dev 2006-10-31 15:24:21 UTC
(In reply to comment #19)
> Can I remove it ?

Yes, that should be fine.  Portage doesn't strictly need that file. 

Comment 21 Fab 2006-10-31 15:26:43 UTC
Yes, it was that. Thanks for your help. Victory :o)


# cd /var/db/pkg/x11-libs/libSM-1.0.1/
# mv FEATURES ~
# echo 'autoconfig buildpkg buildsyspkg candy ccache confcache distlocks metadata-transfer parallel-fetch sandbox sfperms strict userfetch userpriv usersandbox' > FEATURES

# emerge -1 libSM
Calculating dependencies  ... done!

>>> Emerging (1 of 1) x11-libs/libSM-1.0.2 to /


[...]


 x11-libs/libSM
    selected: 1.0.1 
   protected: 1.0.2 
     omitted: none

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

>>> Waiting 5 seconds before starting...
>>> (Control-C to abort)...
>>> Unmerging in: 5 4 3 2 1 
>>> Unmerging x11-libs/libSM-1.0.1...
No package files given... Grabbing a set.
<<<        obj /usr/share/doc/libSM-1.0.1/ChangeLog.gz
--- !mtime obj /usr/lib/pkgconfig/sm.pc
--- !mtime obj /usr/lib/libSM.so.6.0.0

[...]
Comment 22 Zac Medico gentoo-dev 2006-10-31 15:31:40 UTC
In svn r4893, I've fixed it to skip files with null bytes and print a warning message.
Comment 23 Zac Medico gentoo-dev 2006-11-01 00:30:29 UTC
This has been released in 2.1.2_rc1-r2.