schroot fails for source chroots with 'std:bad_alloc' on groovy
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
schroot (Ubuntu) |
Fix Released
|
High
|
Unassigned |
Bug Description
After upgrading to groovy or installing fresh from the beta, schroot fails to enter a source: chroot with std:bad_alloc:
$ schroot -c source:bionic-amd64
E: std::bad_alloc
Running this with debugging symbols under gdb we get the following backtrace:
amurray@slate:~$ gdb --ex='break std::bad_
GNU gdb (Ubuntu 9.2-0ubuntu2) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://
Find the GDB manual and other documentation resources online at:
<http://
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from schroot...
Reading symbols from /usr/lib/
Catchpoint 1 (throw)
Function "std::bad_
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (std::bad_
Starting program: /usr/bin/schroot -c source:bionic-amd64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_
Catchpoint 1 (exception thrown), 0x00007fd231965762 in __cxa_throw () from /lib/x86_
(gdb) bt full
#0 0x00007fd231965762 in __cxa_throw () from /lib/x86_
No symbol table info available.
#1 0x00007fd231959562 in ?? () from /lib/x86_
No symbol table info available.
#2 0x00005596c26b8a2f in __gnu_cxx:
No locals.
#3 std::allocator_
No locals.
#4 std::_Vector_
No locals.
#5 std::vector<char, std::allocator<
__old_size = 0
__tmp = <optimised out>
#6 0x00005596c26b5996 in sbuild:
size = 34359738368
error = <optimised out>
grp_result = 0x0
#7 0x00005596c26b5abf in sbuild:
No locals.
#8 sbuild:
No locals.
#9 0x00005596c26a463f in sbuild:
grp = {<group> = {gr_name = 0x7fd1b0416010 <error: Cannot access memory at address 0x7fd1b0416010>, gr_passwd = 0x7fd1b041601e <error: Cannot access memory at address 0x7fd1b041601e>, gr_gid = 138,
gr_mem = 0x7fd1b0416028}, buffer = std::vector of length 0, capacity 17179869184, valid = false}
#10 0x00005596c26a49eb in sbuild:
in_
gp = "admin"
users = std::vector of length 0, capacity 0
root_users = <optimised out>
groups = <optimised out>
root_groups = std::vector of length 3, capacity 3 = {"root", "sbuild", "admin"}
upos = <optimised out>
rupos = <optimised out>
#11 0x00005596c26a4cd1 in sbuild:
in_users = false
in_groups = false
#12 0x00005596c26a3ae1 in sbuild:
cur = {alias = "source:
status = sbuild:
#13 0x00005596c26a3fba in sbuild:
No locals.
#14 0x00005596c2731fb9 in schroot:
sess_op = <optimised out>
#15 0x00005596c272b392 in schroot_
status = <optimised out>
#16 0x00005596c269a2f0 in schroot_
opts = std::shared_
kit = {<schroot:
This shows sbuild is querying for the group 'admin' - however this does not exist on my groovy install:
amurray@slate:~$ getent group | grep ^admin
amurray@slate:~$
The reason it is checking for admin comes from the following 2 references for setting up schroot etc - https:/
SCHROOT_
source-
preserve-
So in this case, sbuild will allow users in the root, sbuild or admin groups to be root in the source schroot.
The actual failure seems to be because the sbuild code does not check for appropriate errors from getpwnam_r / getpwuid_r - in sbuild-utilc.cc there is 4 variants of code like:
while ((error = getgrnam_r(name, this,
{
size <<= 1;
buffer.
}
However, this should only try and reallocate a larger buffer if these return ERANGE. Otherwise, if it fails for some other reason (like the group does not exist) it will continue to try and allocate a larger and larger buffer until it fails due to lack of memory.
This would appear to be the same bug as https:/
Changed in schroot (Ubuntu): | |
status: | New → Confirmed |
importance: | Undecided → High |
tags: | added: rls-ff-incoming |
Hi Alex,This is failing here:https:/ /gitlab. com/codelibre/ schroot/ -/blob/ schroot- 1.6/sbuild/ sbuild- util.cc# L757Is there something unusual about the group being checked? getgrnam_r has returned ERANGE and schroot increased the buffer size to accommodate this until it ran out of memory. The cause of failure is clear but the reason is not.Are you using LDAP, AD or is this all local users and groups?Kind regards,Roger Leigh bionic- amd64E: std::bad_ allocRunning this with debugging symbols under gdb we get the followingbacktr ace:amurray@ slate:~ $ gdb --ex='break std::bad_ alloc:: bad_alloc( )' --ex=run --args schroot -c source: bionic- amd64GNU gdb (Ubuntu 9.2-0ubuntu2) 9.2Copyright (C) 2020 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http:// gnu.org/ licenses/ gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.Type "show copying" and "show warranty" for details.This GDB was configured as "x86_64- linux-gnu" .Type "show configuration" for configuration details.For bug reporting instructions, please see:<http:// www.gnu. org/software/ gdb/bugs/>.Find the GDB manual and other documentation resources online at: <http:// www.gnu. org/software/ gdb/documentati on/>.For help, type "help".Type "apropos word" to search for commands related to "word"...Reading symbols from schroot...Reading symbols from /usr/lib/ debug/. build-id/ 70/4469864df39e d3af1f8a23bd8d2 7adffeb8315. debug.. .Catchpoint 1 (throw)Function "std::bad_ alloc:: bad_alloc( )" not defined.Make breakpoint pending on future shared library load? (y or [n]) yBreakpoint 2 (std::bad_ alloc:: bad_alloc( )) pending.Starting program: /usr/bin/schroot -c source: bionic- amd64[Thread debugging using libthread_db enabled]Using host libthread_db library "/lib/x86_ 64-linux- gnu/libthread_ db.so.1" .Catchpoint 1 (exception thrown), 0x00007fd231965762 in __cxa_throw () from /lib/x86_ 64-linux- gnu/libstdc+ +.so.6( gdb) bt full#0 0x00007fd231965762 in __cxa_throw () from /lib/x86_ 64-linux- gnu/libstdc+ +.so.6No symbol table info available.#1 0x00007fd231959562 in ?? () from /lib/x86_ 64-linux- gnu/libstdc+ +.so.6No symbol table info available.#2 0x00005596c26b8a2f in __gnu_cxx: :new_allocator< char>:: allocate (this=0x7ffd3b1 89dd0, __n=34359738368) at /usr/include/ c++/9/ext/ new_allocator. h:102No locals.#3 std::allocator_ traits< std::allocator< char> >::allocate (__a=..., __n=34359738368) at /usr/include/ c++/9/bits/ alloc_traits. h:444No locals.#4 std::_Vector_ base<char, std::allocator< char> >::_M_allocate (this=0x7ffd3b1 89dd0, __n=34359738368) at /usr/include/ c++/9/bits/ stl_vector. h:343No locals.#5 std::vector<char, std::allocator< char> >::reserve (this=this@ entry=0x7ffd3b1 89dd0, __n=__n@ entry=343597383 68) at /usr/include/ c++/9/bits/ vector. tcc:78 ...
-------- Original message --------From: Alex Murray <email address hidden> Date: 12/10/2020 06:20 (GMT+00:00) To: <email address hidden> Subject: [Bug 1899414] [NEW] schroot fails for source chroots with
'std:bad_alloc' on groovy Public bug reported:After upgrading to groovy or installing fresh from the beta, schrootfails to enter a source: chroot with std:bad_alloc:$ schroot -c source: