Bug 224740 - emulators/qemu-user-static: low RLIMIT_VMEM hangs qemu due to GSlice allocation failure
Summary: emulators/qemu-user-static: low RLIMIT_VMEM hangs qemu due to GSlice allocati...
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: Normal Affects Many People
Assignee: Kyle Evans
URL: https://lists.freebsd.org/pipermail/f...
Keywords: needs-patch, regression
Depends on:
Blocks: 231346
  Show dependency treegraph
 
Reported: 2017-12-31 01:48 UTC by Jan Beich
Modified: 2019-11-13 14:32 UTC (History)
7 users (show)

See Also:
bugzilla: maintainer-feedback? (sbruno)
koobs: merge-quarterly?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2017-12-31 01:48:22 UTC
$ cat a.c
#include <sys/resource.h>

int main()
{
  struct rlimit limit;
  limit.rlim_cur = limit.rlim_max = 5000000;
  if (setrlimit (RLIMIT_VMEM, &limit) < 0)
    return 1;
  return 0;
}
$ cc a.c
$ G_SLICE=always-malloc ./a.out
$ ./a.out

***MEMORY-ERROR***: [39424]: GSlice: failed to allocate 496 bytes (alignment: 512): Cannot allocate memory

load: 0.86  cmd: qemu-aarch64-static 39424 [uwait] 1.80r 0.04u 0.00s 0% 12872k

$ gdb -q =qemu-aarch64-static 39424
Reading symbols from /usr/local/bin/qemu-aarch64-static...done.
Attaching to program: /usr/local/bin/qemu-aarch64-static, process 39424
[New LWP 102113 of process 39424]
[Switching to LWP 102337 of process 39424]
_umtx_op_err () at /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37
37      RSYSCALL_ERR(_umtx_op)
(gdb) bt f
#0  _umtx_op_err () at /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37
No locals.
#1  0x000000006026e160 in _thr_umtx_timedwait_uint (mtx=0x62528af0 <default_wake_addr+8>,
    id=<optimized out>, clockid=<optimized out>, abstime=<optimized out>, shared=<optimized out>)
    at /usr/src/lib/libthr/thread/thr_umtx.c:236
        tm_p = 0x6026e57c <_thr_ast+44>
        tm_size = 24
#2  0x000000006027822c in cond_wait_user (abstime=<optimized out>, cancel=1, cvp=<optimized out>,
    mp=<optimized out>) at /usr/src/lib/libthr/thread/thr_cond.c:306
        curthread = 0x860b002b8
        deferred = 0
        recurse = 0
        error = <optimized out>
        sq = <optimized out>
        error2 = <optimized out>
#3  cond_wait_common (cond=<optimized out>, mutex=<optimized out>, abstime=0x0, cancel=1)
    at /usr/src/lib/libthr/thread/thr_cond.c:366
        cvp = 0x860aed320
        mp = 0x860afe560
        error = <optimized out>
#4  0x00000000601c7df4 in qemu_cond_wait (cond=0x6251c450 <exclusive_cond>,
    mutex=0x6251c440 <qemu_cpu_list_lock>) at util/qemu-thread-posix.c:161
        err = 0
#5  0x0000000060120645 in start_exclusive () at cpus-common.c:204
        other_cpu = 0x0
        running_cpus = 1
#6  0x0000000060044819 in stop_all_tasks ()

No locals.
#7  0x0000000060050d93 in force_sig (target_sig=6)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/bsd-user/signal.c:338
        env = 0x860eac758
        cpu = 0x860ea4540
        ts = 0x7ffffffe5490
        core_dumped = 0
        host_sig = 6
        act = {__sigaction_u = {__sa_handler = 0x0, __sa_sigaction = 0x0}, sa_flags = 0, sa_mask = {
            __bits = {0, 0, 0, 0}}}
#8  0x0000000060051094 in queue_signal (env=0x860eac758, sig=6, info=0x7ffffffe3db8)
19
        cpu = 0x860ea4540
        ts = 0x7ffffffe5490
        k = 0x7ffffffe56d0
        q = 0x0
        pq = 0x0
        handler = 0
#9  0x0000000060051a26 in host_signal_handler (host_signum=6, info=0x7ffffffe45f0,
    puc=0x7ffffffe4280)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/bsd-user/signal.c:482
        env = 0x860eac758
        sig = 6
        tinfo = {si_signo = 6, si_errno = 0, si_code = 65543, si_pid = 39424, si_uid = 1001,
          si_status = 0, si_addr = 0, si_value = {sival_int = 0, sival_ptr = 0, sigval_int = 0,
            sigval_ptr = 0}, _reason = {_fault = {_trapno = 0}, _timer = {_timerid = 0,
              _overrun = 0}, _mesgp = {_mqd = 0}, _poll = {_band = 0}, __spare__ = {__spare1__ = 0,
              __spare2_ = {0, 0, 0, 0, 0, 0, 0}}}}
#10 0x000000006026f774 in handle_signal (actp=0x7ffffffe4208, sig=6, info=0x7ffffffe45f0,
    ucp=0x7ffffffe4280) at /usr/src/lib/libthr/thread/thr_sig.c:246
        in_sigsuspend = 0
        cancel_enable = 1
        cancel_point = 0
        sigfunc = 0x0
        err = <optimized out>
        uc2 = <optimized out>
#11 0x000000006026ec47 in thr_sighandler (sig=6, info=0x7ffffffe45f0, _ucp=0x7ffffffe4280)
    at /usr/src/lib/libthr/thread/thr_sig.c:191
        err = 12
        curthread = 0x860b00000
        act = {__sigaction_u = {__sa_handler = 0x60051950 <host_signal_handler>,
            __sa_sigaction = 0x60051950 <host_signal_handler>}, sa_flags = 64, sa_mask = {__bits = {
              2147483647, 4294967295, 4294967295, 4294967295}}}
#12 <signal handler called>
No symbol table info available.
#13 thr_kill () at thr_kill.S:3
No locals.
#14 0x00000000602d29ff in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:54
        id = 102337
#15 0x00000000602d2979 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
        act = <optimized out>
#16 0x00000000601f880e in mem_error (
    format=0x6038ab81 "failed to allocate %u bytes (alignment: %u): %s\n") at gslice.c:1465
        pname = 0x0
        args = {{gp_offset = 32, fp_offset = 48, overflow_arg_area = 0x7ffffffe4b60,
            reg_save_area = 0x7ffffffe4a70}}
#17 0x00000000601f8cec in allocator_add_slab (allocator=0x62521250 <allocator>, ix=2, chunk_size=48)
    at gslice.c:1284
        syserr = 0x62532f10 <strerror.ebuf> "Cannot allocate memory"
        chunk = 0x868fd4f90
        sinfo = 0x868fd4fd0
        addr = 36121169408
        padding = 32
        n_chunks = 9
        color = 0
        page_size = 512
        aligned_memory = 0x0
        mem = 0x0
        i = 8
#18 0x00000000601f72b6 in slab_allocator_alloc_chunk (chunk_size=48) at gslice.c:1323
        chunk = 0x868fd4f90
        ix = 2
#19 0x00000000601f89b7 in magazine_cache_pop_magazine (ix=2, countp=0x860b0c038) at gslice.c:731
        magazine_threshold = 34
        i = 9
        chunk = 0x868fd4f90
        head = 0x868fd4e10
        chunk_size = 48
#20 0x00000000601f71d8 in thread_memory_magazine1_reload (tmem=0x860b0c000, ix=2) at gslice.c:801
        mag = 0x860b0c030
#21 0x00000000601f6e7e in g_slice_alloc (mem_size=40) at gslice.c:1014
        ix = 2
        tmem = 0x860b0c000
        chunk_size = 48
        mem = 0x800000003e
        acat = 1
#22 0x000000006021299f in g_tree_node_new (key=0x605cfe20 <static_code_gen_buffer+742800>,
    value=0x605cfe00 <static_code_gen_buffer+742768>) at gtree.c:136
        node = 0x605cfca0 <static_code_gen_buffer+742416>
#23 0x000000006021129a in g_tree_insert_internal (tree=0x860b0a800,
    key=0x605cfe20 <static_code_gen_buffer+742800>,
    value=0x605cfe00 <static_code_gen_buffer+742768>, replace=0) at gtree.c:510
        child = 0x605cfef8 <static_code_gen_buffer+743016>
        cmp = 1
        node = 0x868fd4d80
        path = {0x0, 0x868fc4950, 0x868fcbb30, 0x868fd2790, 0x868fd3610, 0x868fd4430, 0x868fd4790,
          0x868fd4b30, 0x868fd4c30, 0x868fd4cf0, 0x868fd4d50,
          0x605cfec8 <static_code_gen_buffer+742968>, 0x7ffffffe4e00, 0x600090ce <patch_reloc+190>,
          0x604f2cf0 <tcg_init_ctx+1776>, 0x4010604f2600, 0x2fffe4e60, 0x860e33d04, 0x7ffffffe4e70,
          0x601d3f3e <qht_insert__locked+478>, 0x605cfe00 <static_code_gen_buffer+742768>,
          0x23754574605cfec8, 0x868f6cd80, 0x868f6cd80, 0x860b1a060, 0x604f25c8 <tb_ctx+8>, 0x0,
          0x0, 0x860e33d00, 0x7ffffffe4e87, 0x2375457460b1a060,
          0x605cfe00 <static_code_gen_buffer+742768>, 0x860e33d00, 0x860b1a060,
          0x604f25c8 <tb_ctx+8>, 0x860e33d00, 0x7ffffffe4eb0, 0x601d3c1f <qht_insert+95>,
          0x17ffffffe4eb0, 0x860b1a060}
        idx = 11
#24 0x0000000060211004 in g_tree_insert (tree=0x860b0a800,
    key=0x605cfe20 <static_code_gen_buffer+742800>,
    value=0x605cfe00 <static_code_gen_buffer+742768>) at gtree.c:391
No locals.
#25 0x000000006003d852 in tb_gen_code (cpu=0x860ea4540, pc=131572, cs_base=0, flags=2147483648,
    cflags=0)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/accel/tcg/translate-all.c:1399
        env = 0x860eac758
        tb = 0x605cfe00 <static_code_gen_buffer+742768>
        phys_pc = 131572
        phys_page2 = 18446744073709551615
        virt_page2 = 131072
        gen_code_buf = 0x605cfec0 <static_code_gen_buffer+742960> "A\213n\354\205\355\017\214\062"
        gen_code_size = 72
        search_size = 14
#26 0x000000006003ab59 in tb_find (cpu=0x860ea4540,
    last_tb=0x605cfc80 <static_code_gen_buffer+742384>, tb_exit=0, cf_mask=0)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/accel/tcg/cpu-exec.c:402
        tb = 0x0
        cs_base = 0
        pc = 131572
        flags = 2147483648
        acquired_tb_lock = true
#27 0x000000006003a518 in cpu_exec (cpu=0x860ea4540)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/accel/tcg/cpu-exec.c:735
        cflags = 0
        tb = 0x605cfc80 <static_code_gen_buffer+742384>
        last_tb = 0x605cfc80 <static_code_gen_buffer+742384>
        tb_exit = 0
        cc = 0x860e9f500
        ret = 340
        sc = {diff_clk = 0, last_cpu_icount = 0, realtime_clock = 0}
#28 0x00000000600442ff in target_cpu_loop (env=0x860eac758)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/bsd-user/aarch64/target_arch_cpu.h:58
        cs = 0x860ea4540
        trapnr = 2
        sig = 1615966250
        info = {si_signo = 1615799808, si_errno = 0, si_code = 1649512448, si_pid = 0,
          si_uid = -110224, si_status = 32767, si_addr = 1610618197, si_value = {sival_int = 4096,
            sival_ptr = 4096, sigval_int = 4096, sigval_ptr = 4096}, _reason = {_fault = {
              _trapno = 1615799808}, _timer = {_timerid = 1615799808, _overrun = 0}, _mesgp = {
              _mqd = 1615799808}, _poll = {_band = 1615799808}, __spare__ = {
              __spare1__ = 1615799808, __spare2_ = {-110128, 32767, 1610618804, 0, 3603561, 0, 1}}}}
        code = 340
        arg1 = 3
        arg2 = 274878237620
        arg3 = 0
        arg4 = 274878037912
        arg5 = 0
        arg6 = 0
        arg7 = 2101248
        arg8 = 4194305
        pstate = 1073741824
        ret = 0
#29 0x00000000600442c5 in cpu_loop (env=0x860eac758)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/bsd-user/main.c:122
No locals.
#30 0x0000000060045b61 in main (argc=2, argv=0x7fffffffec18)
    at /usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-8dcfea1/bsd-user/main.c:516
        filename = 0x7fffffffee4b "./a.out"
        log_file = 0x0
        log_mask = 0x0
        regs1 = {regs = {36120075632, 0 <repeats 30 times>}, sp = 36120075632, pc = 274877972480,
          pstate = 0}
        regs = 0x7ffffffe5358
        info1 = {load_bias = 0, load_addr = 274877906944, start_code = 65536, end_code = 131872,
          start_data = 196608, end_data = 262552, start_brk = 327688, brk = 327688,
          start_mmap = 2147483648, mmap = 0, rss = 0, start_stack = 36120075632,
          entry = 274877972480, code_offset = 0, data_offset = 0, arg_start = 0, arg_end = 0,
          personality = 0}
        info = 0x7ffffffe52c0
        bprm = {
          buf = "\177ELF\002\001\001\t\000\000\000\000\000\000\000\000\003\000\267\000\001\000\000\000\000\000\001\000\000\000\000\000@\000\000\000\000\000\000\000\b\035\004\000\000\000\000\000\000\000\000\000@\000\070\000\a\000@\000\024\000\023\000\006\000\000\000\004\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000\210\001\000\000\000\000\000\000\210\001\000\000\000\000\000\000\b\000\000\000\000\000\000\000\001\000\000\000\004\000\000", page = {
            0x0 <repeats 64 times>}, p = 36120075632, stringp = 36120076008, fd = 3, e_uid = 1001,
          e_gid = 1001, argc = 1, envc = 8, argv = 0x7fffffffec20, envp = 0x860ec6000,
          filename = 0x7fffffffee4b "./a.out", fullpath = 0x860b1e0d0 "/tmp/a.out",
          core_dump = 0x6004b3b0 <elf_core_dump>}
        ts1 = <error reading variable ts1 (value of type `TaskState' requires 103504 bytes, which is more than max-value-size)>
        ts = 0x7ffffffe5490
        env = 0x860eac758
        cpu = 0x860ea4540
        optind = 1
        r = 0x7fffffffee4b "./a.out"
        gdbstub_port = 0
        target_environ = 0x860ec6000
        wrk = 0x860ec6040
        envlist = 0x860b1e0d0
        trace_file = 0x0
Comment 1 Jan Beich freebsd_committer 2017-12-31 02:05:06 UTC
qemu-user-static-2.9.94.g20171023 is not affected. Can someone help bisecting ports r456518?
Comment 2 Jan Beich freebsd_committer 2017-12-31 02:14:10 UTC
- mips64 isn't affected. I guess, only armv6/armv7 and aarch64 are.
- static binaries aren't affected
Comment 3 commit-hook freebsd_committer 2017-12-31 02:19:02 UTC
A commit references this bug:

Author: jbeich
Date: Sun Dec 31 02:18:15 UTC 2017
New revision: 457665
URL: https://svnweb.freebsd.org/changeset/ports/457665

Log:
  devel/libunistring: temporarily skip ENOMEM check for printf

  configure:25883: checking whether printf survives out-of-memory conditions
  configure:26055: /nxb-bin/usr/bin/cc -o conftest -O2 -pipe  -DLIBICONV_PLUG -fno-strict-aliasing -DLIBICONV_PLUG -D_THREAD_SAFE  conftest.c  >&5
  configure:26058: $? = 0

  ***MEMORY-ERROR***: [67280]: GSlice: failed to allocate 496 bytes (alignment: 512): Cannot allocate memory

  PR:		224740
  Reported by:	Mark Millard (via ports@ list, for armv7)
  Approved by:	portmgr blanket

Changes:
  head/devel/libunistring/Makefile
Comment 4 Mark Millard 2017-12-31 02:50:27 UTC
(In reply to commit-hook from comment #3)

The freebsd-arm list also has my follow-ups, including
for aarch64. See in:

https://lists.freebsd.org/pipermail/freebsd-arm/2017-December/thread.html

[ freebsd-ports is rejecting submittals from an intermediate
server now and likely for a half a day or so. One send
did not make it through to freebsd-ports but did show
up on freebsd-arm .]
Comment 5 mikael.urankar 2017-12-31 08:48:21 UTC
I don't have the problem on my machine, is it limited to poudriere?
Comment 6 mikael.urankar 2017-12-31 08:49:01 UTC
root@12armv6: ~ env G_SLICE=always-malloc ./a.out
root@12armv6: ~ echo $?
0
Comment 7 Jan Beich freebsd_committer 2017-12-31 09:15:12 UTC
(In reply to mikael.urankar from comment #5)
> I don't have the problem on my machine, is it limited to poudriere?

Probably. I haven't tried outside of poudriere jail as setting up an environment to load dynamically linked programs via qemu-user-static is tricky.

(In reply to mikael.urankar from comment #6)
> root@12armv6: ~ env G_SLICE=always-malloc ./a.out

G_SLICE=always-malloc disables Glib slice allocator. Try without i.e., simply run ./a.out with default environment variables.
Comment 8 mikael.urankar 2017-12-31 09:22:25 UTC
(In reply to Jan Beich from comment #7)
It's the same:
root@12armv6: ~ env G_SLICE=always-malloc ./a.out
root@12armv6: ~ echo $?
0
root@12armv6: ~ ./a.out
root@12armv6: ~ echo $?
0

I have the problem on aarch64 though.
Comment 9 Mark Millard 2017-12-31 09:26:36 UTC
(In reply to mikael.urankar from comment #8)

Your prompt shows armv6 instead of armv7.
Is that real? (My 32-bit context really
was armv7: cortex-a7 handled as such.)
Comment 10 Mark Millard 2017-12-31 09:37:56 UTC
(In reply to Mark Millard from comment #9)

Also: What are your versions? Mine are:

# qemu-arm-static --version
qemu-arm version 2.11.50
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
usage: qemu-arm [options] program [arguments...]
BSD CPU emulator (compiled for arm emulation)
. . .

# qemu-aarch64-static --version
qemu-aarch64 version 2.11.50
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
usage: qemu-aarch64 [options] program [arguments...]
BSD CPU emulator (compiled for aarch64 emulation)
. . .
Comment 11 mikael.urankar 2017-12-31 09:50:53 UTC
(In reply to Mark Millard from comment #9)
Yes it's an armv6 jail, I don't have an armv7 jail ready right now.

I'm using qemu-user-static-2.11.50.g20171215_1, same version as yours.
Comment 12 commit-hook freebsd_committer 2018-01-14 21:11:39 UTC
A commit references this bug:

Author: antoine
Date: Sun Jan 14 21:10:59 UTC 2018
New revision: 459001
URL: https://svnweb.freebsd.org/changeset/ports/459001

Log:
  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallout
  MFH:		2018Q1
  With hat:	portmgr

Changes:
  head/devel/m4/Makefile
Comment 13 commit-hook freebsd_committer 2018-01-14 22:06:34 UTC
A commit references this bug:

Author: antoine
Date: Sun Jan 14 22:06:20 UTC 2018
New revision: 459006
URL: https://svnweb.freebsd.org/changeset/ports/459006

Log:
  MFH: r459001

  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallout
  With hat:	portmgr

Changes:
_U  branches/2018Q1/
  branches/2018Q1/devel/m4/Makefile
Comment 14 commit-hook freebsd_committer 2018-01-15 07:36:00 UTC
A commit references this bug:

Author: antoine
Date: Mon Jan 15 07:35:04 UTC 2018
New revision: 459020
URL: https://svnweb.freebsd.org/changeset/ports/459020

Log:
  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallout
  MFH:		2018Q1
  With hat:	portmgr

Changes:
  head/devel/bison/Makefile
Comment 15 commit-hook freebsd_committer 2018-01-15 08:19:40 UTC
A commit references this bug:

Author: antoine
Date: Mon Jan 15 08:18:50 UTC 2018
New revision: 459022
URL: https://svnweb.freebsd.org/changeset/ports/459022

Log:
  MFH: r459020

  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallout
  With hat:	portmgr

Changes:
_U  branches/2018Q1/
  branches/2018Q1/devel/bison/Makefile
Comment 17 Sean Bruno freebsd_committer 2018-02-06 20:22:37 UTC
(In reply to Jan Beich from comment #16)
Huh, I thought this was fixed.  I'm building an aarch64 jail and I'll take a look tonight.
Comment 18 commit-hook freebsd_committer 2018-03-17 09:14:35 UTC
A commit references this bug:

Author: antoine
Date: Sat Mar 17 09:14:10 UTC 2018
New revision: 464772
URL: https://svnweb.freebsd.org/changeset/ports/464772

Log:
  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallout
  MFH:		2018Q1

Changes:
  head/databases/recutils/Makefile
  head/misc/gnuls/Makefile
Comment 19 commit-hook freebsd_committer 2018-03-17 09:16:39 UTC
A commit references this bug:

Author: antoine
Date: Sat Mar 17 09:15:46 UTC 2018
New revision: 464773
URL: https://svnweb.freebsd.org/changeset/ports/464773

Log:
  MFH: r464772

  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallout

Changes:
_U  branches/2018Q1/
  branches/2018Q1/databases/recutils/Makefile
  branches/2018Q1/misc/gnuls/Makefile
Comment 20 commit-hook freebsd_committer 2018-03-17 09:25:48 UTC
A commit references this bug:

Author: antoine
Date: Sat Mar 17 09:25:04 UTC 2018
New revision: 464774
URL: https://svnweb.freebsd.org/changeset/ports/464774

Log:
  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallou
  MFH:		2018Q1

Changes:
  head/sysutils/coreutils/Makefile
Comment 21 commit-hook freebsd_committer 2018-03-17 09:26:51 UTC
A commit references this bug:

Author: antoine
Date: Sat Mar 17 09:26:20 UTC 2018
New revision: 464776
URL: https://svnweb.freebsd.org/changeset/ports/464776

Log:
  MFH: r464774

  Skip ENOMEM check for printf when building with qemu, this makes
  configure hang

  PR:		224740
  Reported by:	pkg-fallout

Changes:
_U  branches/2018Q1/
  branches/2018Q1/sysutils/coreutils/Makefile
Comment 22 Mark Millard 2018-05-27 02:35:09 UTC
(In reply to commit-hook from comment #21)

Has the evidence accumulated to the point of this
bugzilla progressing past "In Progress" status?
Comment 23 mikael.urankar 2018-05-28 17:44:23 UTC
If you don't care about the correctness of the emulation of *rlimit* you can use this patch.

--- bsd-user/syscall_defs.h.orig        2018-05-28 19:38:34.012737000 +0200
+++ bsd-user/syscall_defs.h     2018-05-28 19:43:01.994915000 +0200
@@ -295,7 +295,8 @@ struct target_freebsd_kevent {
 /*
  *  sys/resource.h
  */
-#if defined(__FreeBSD__) 
+/* qemu crashes with TARGET_RLIM_INFINITY == RLIM_INFINITY */
+#if false && defined(__FreeBSD__) 
 #define TARGET_RLIM_INFINITY    RLIM_INFINITY
 #else
 #define TARGET_RLIM_INFINITY    ((abi_ulong)-1)


TARGET_RLIM_INFINITY == RLIM_INFINITY was introduced with this commit:
https://github.com/seanbruno/qemu-bsd-user/commit/2c91d727cd1879c382e03b447ca9947aec3bf951

as to why it crashes now and not before: ENOCLUE
Comment 24 mikael.urankar 2018-12-18 10:57:23 UTC
(In reply to mikael.urankar from comment #23)
this hack doesn't work
Comment 25 commit-hook freebsd_committer 2018-12-18 11:20:42 UTC
A commit references this bug:

Author: koobs
Date: Tue Dec 18 11:19:55 UTC 2018
New revision: 487744
URL: https://svnweb.freebsd.org/changeset/ports/487744

Log:
  editors/nano: Fix build (configure) on ARM

  The arm package builder when building this port, fails with the following
  error during configure:

    checking whether printf survives out-of-memory conditions...
    =>> Killing runaway build after 21600 seconds with no output

  The root cause is described in bug 224740, which has not been resolved yet:

    low RLIMIT_VMEM hangs qemu due to GSlice allocation failure

  In the meantime, this change applies a known workaround which has already
  been applied in several ports, which disables the specific (hanging) configure
  check, if the build is run with qemu emulation.

  PR:		231346, 224740
  Reported by:	many
  Approved by:	portmgr (blanket: build fix, jfi)
  MFH:		2018Q4

Changes:
  head/editors/nano/Makefile
Comment 26 commit-hook freebsd_committer 2019-01-29 02:02:26 UTC
A commit references this bug:

Author: jbeich
Date: Tue Jan 29 02:02:19 UTC 2019
New revision: 491535
URL: https://svnweb.freebsd.org/changeset/ports/491535

Log:
  textproc/groff: unhang on qemu-aarch64-static after r488509

  checking whether printf survives out-of-memory conditions...

  PR:		224740

Changes:
  head/textproc/groff/Makefile
Comment 27 commit-hook freebsd_committer 2019-01-29 02:03:29 UTC
A commit references this bug:

Author: jbeich
Date: Tue Jan 29 02:02:49 UTC 2019
New revision: 491536
URL: https://svnweb.freebsd.org/changeset/ports/491536

Log:
  MFH: r491535

  textproc/groff: unhang on qemu-aarch64-static after r488509

  checking whether printf survives out-of-memory conditions...

  PR:		224740
  Approved by:	ports-secteam blanket

Changes:
_U  branches/2019Q1/
  branches/2019Q1/textproc/groff/Makefile
Comment 28 Neko Prog 2019-11-03 04:44:17 UTC
This bug still exist in FreeBSD 12.1:
ports/devel/m4
ports/devel/bison
ports/devel/libunistring
ports/editors/nano

Need to manually kill /usr/local/bin/qemu-arm-static ./conftest so that build continues.
Comment 29 Kyle Evans freebsd_committer 2019-11-12 16:30:29 UTC
(In reply to Neko Prog from comment #28)

Taking this; I'm doing Q/A on an update to qemu-sbruno that should fix this and another couple of signal handling issues. This was the result of trying to terminate the thread while we were still executing guest code, resulting in an immediate deadlock. Latest commits refactor signal handling to push it all out of the signal handler and into process_pending_signals() at the end of individual CPU loops.

I hope to push the update today.
Comment 30 commit-hook freebsd_committer 2019-11-12 21:11:51 UTC
A commit references this bug:

Author: kevans
Date: Tue Nov 12 21:11:40 UTC 2019
New revision: 517350
URL: https://svnweb.freebsd.org/changeset/ports/517350

Log:
  emulators/qemu-user-static: update to head as of 2019/11/12

  With this update, sendmsg/recvmsg (thus, casper'ized) applications now work
  again on mips.  Various signal handling issues have also been addressed,
  most notably qemu-user-static should no longer deadlock when evaluating
  whether printf survives out-of-memory conditions or not.

  PR:		224740
  Approved by:	ler (ports), sbruno (maintainer, implicit)
  MFH:		2019Q4

Changes:
  head/emulators/qemu-sbruno/Makefile
  head/emulators/qemu-sbruno/distinfo
Comment 31 commit-hook freebsd_committer 2019-11-13 14:32:49 UTC
A commit references this bug:

Author: jbeich
Date: Wed Nov 13 14:32:09 UTC 2019
New revision: 517376
URL: https://svnweb.freebsd.org/changeset/ports/517376

Log:
  Drop workaround for qemu-user-static hang after r517350

  GSlice as used by qemu-user still aborts due to low RLIMIT_VMEM in an
  emulated application but no longer hangs. While the behavior differs
  from real hardware it matches the one from before r456518 that was
  hardcoded as gl_cv_func_printf_enomem=no workaround.

  PR:		224740

Changes:
  head/databases/recutils/Makefile
  head/devel/bison/Makefile
  head/devel/libunistring/Makefile
  head/devel/m4/Makefile
  head/editors/nano/Makefile
  head/misc/gnuls/Makefile
  head/sysutils/coreutils/Makefile
  head/textproc/groff/Makefile