Bug 2639

Summary: groupadd: malloc(): memory corruption
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Robert Yang <liezhi.yang>
Component: devtools / tool chainAssignee: Seebs <seebs>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: Medium CC: liezhi.yang, meta.mr.watcher, meta.watcher, sgw, song.liu, yi.zhao, zhenfeng.zhao
Version: 1.3   
Target Milestone: 1.3 M4   
Hardware: x86   
OS: Multiple   
Whiteboard: (P2)
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---
Bug Depends on:    
Bug Blocks: 2434    

Description Robert Yang 2012-06-21 05:46:26 UTC
groupadd, useradd and rpm.real have the similar error.

when set the length of builddir longer than 266(maybe smaller), there are such errors:

NOTE: package dbus-1.4.20-r3.0: task do_install: Started
*** glibc detected *** groupadd: malloc(): memory corruption: 0x000000000101da70 ***
*** glibc detected *** groupadd: malloc(): memory corruption: 0x000000000101da70 ***

Then the build would hang, this is caused by the command:

PSEUDO_PREFIX=/too/long/path/tmp/sysroots/x86_64-linux/usr
PSEUDO_LOCALSTATEDIR=... PSEUDO_PASSWD=...
PSEUDO_NOSYMLINKEXP=1 PSEUDO_DISABLED=0 PSEUDO_LOCALSTATEDIR
... /too/long/path/to/tmp/sysroots/x86_64-linux/usr/bin/pseudo
groupadd --root /too/long/path/to/tmp/sysroots/qemux86 -r netdev -f

1) I had looked into the code of groupadd, and found that this would
happen when it used the glibc function which needs malloc(for example,
the access()), so it seemed this was caused by the glibc or pseudo,
but I didn't know why it only happened to groupadd/useradd.

2) I had tried not to use pseudo, it worked well:

sudo groupadd --root /too/long/path/to/tmp/sysroots/qemux86 -r netdev -f

From this, it seemed that the glibc was ok

3) I had tried to write a small piece of code which used the access(), and
used pseudo to run it, it worked well:

/too/long/path/for/pseudo/settings/and/then/run/pseudo my_app
Comment 1 Robert Yang 2012-06-28 03:31:38 UTC
It's a bug of pseudo, re-assign it to Peter, he will send a patch sooner.
Comment 2 Robert Yang 2012-06-28 04:42:27 UTC
Here is the code that can reproduce the problem simply:

The too_long_line path should be longer than 300.

#include <unistd.h>
#include <stdio.h>

main()
{
        if(chroot(too_long_line)){
                printf("OOOOOOOOOOOO\n");
        }
        else   
                printf("NNNNNNNNNNN\n");

        access("/etc/gshadow", F_OK);
}

Compile it and use the pseudo to run it, then we can see the error.
Comment 3 Seebs 2012-06-28 22:38:03 UTC
Fixed in pseudo 1.3.1. Updating tar balls and such, will send out an oe-core update for this Real Soon.
Comment 5 Yi Zhao 2012-08-01 08:48:57 UTC
Verified with 1.3 master branch
git info: bd726660a3b365b8f0f702771afef30dcd05b6d7

Create a build directory, the length is 410. No errors when running "bitbake core-image-sato".