New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"getcontext failed" in a 32-bit Docker container #133

Closed
andyli opened this Issue Aug 9, 2016 · 9 comments

Comments

Projects
None yet
3 participants
@andyli
Contributor

andyli commented Aug 9, 2016

With a Dockerfile as follows:

# FROM ubuntu:trusty # for reference, the 64-bit "ubuntu:trusty" works correctly

FROM osrf/ubuntu_32bit:trusty

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
        git \
        build-essential \
        libtool \
        pkg-config \
        autoconf \
        automake \
    && rm -r /var/lib/apt/lists/*

RUN git clone git://github.com/ivmai/bdwgc.git /bdwgc

WORKDIR /bdwgc

RUN git clone git://github.com/ivmai/libatomic_ops.git

RUN autoreconf -vif

RUN automake --add-missing

RUN ./configure

RUN make

CMD make check

Build it:

$ docker build . -t gc_docker

Run it:

$ docker run -it gc_docker bash
root@21a11fe7e22e:/bdwgc# make check
...
============================================================================
Testsuite summary for gc 7.5.0
============================================================================
# TOTAL: 14
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  14
# XPASS: 0
# ERROR: 0
============================================================================
See ./test-suite.log
Please report to bdwgc@lists.opendylan.org
============================================================================
make[3]: *** [test-suite.log] Error 1
make[3]: Leaving directory `/bdwgc'
make[2]: *** [check-TESTS] Error 2
make[2]: Leaving directory `/bdwgc'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/bdwgc'
make: *** [check-recursive] Error 1
root@21a11fe7e22e:/bdwgc# cat test-suite.log
================================
   gc 7.5.0: ./test-suite.log
================================

# TOTAL: 14
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  14
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: cordtest
==============

getcontext failed: Use another register retrieval method?

FAIL: gctest
============

getcontext failed: Use another register retrieval method?

FAIL: leaktest
==============

getcontext failed: Use another register retrieval method?

FAIL: middletest
================

getcontext failed: Use another register retrieval method?

FAIL: smashtest
===============

getcontext failed: Use another register retrieval method?

FAIL: hugetest
==============

getcontext failed: Use another register retrieval method?

FAIL: realloc_test
==================

getcontext failed: Use another register retrieval method?

FAIL: staticrootstest
=====================

getcontext failed: Use another register retrieval method?

FAIL: threadleaktest
====================

getcontext failed: Use another register retrieval method?

FAIL: threadkey_test
====================

getcontext failed: Use another register retrieval method?

FAIL: subthreadcreate_test
==========================

getcontext failed: Use another register retrieval method?

FAIL: initsecondarythread_test
==============================

getcontext failed: Use another register retrieval method?

FAIL: disclaim_test
===================

getcontext failed: Use another register retrieval method?

FAIL: disclaim_bench
====================

getcontext failed: Use another register retrieval method?
@andyli

This comment has been minimized.

Contributor

andyli commented Aug 9, 2016

It works correctly if it is built with NO_GETCONTEXT. Is it possible for the config script to add that define automatically by checking getcontext?

@ivmai

This comment has been minimized.

Owner

ivmai commented Aug 9, 2016

I think it should be possible. Could you please send the patch? (There is a difficulty that some clients do not use make, so, some config params should be determined during compilation.)

@ivmai

This comment has been minimized.

Owner

ivmai commented Aug 9, 2016

I wonder what is errno value after getcontext failure?

@ivmai

This comment has been minimized.

Owner

ivmai commented Aug 9, 2016

Maybe it is better to fix the Docker itself? Right now I don't think checking getcontext is implemented in configure is a good choice because it won't help if you compile bdwgc outside docker and run inside it.
Another opportunity is try other methods of saving regs in case of getcontext failed during bdwgc execution.

@andyli

This comment has been minimized.

Contributor

andyli commented Aug 9, 2016

Thanks for the quick reply!

what is errno value after getcontext failure?

getcontext(&ctxt) returns -1. errno is 1.

Maybe it is better to fix the Docker itself?

I have no idea who is responsible for the bug, Docker, the base container image, or bdwgc. But I think it is relatively easy to workaround in the bdwgc code base.

I agree having a fallback mechanism in run-time is better then checking getcontext during config.

@okuoku

This comment has been minimized.

Contributor

okuoku commented Aug 9, 2016

I have no idea who is responsible for the bug, Docker, the base container image, or bdwgc

... or the Kernel; it seems the problem only occur on i686 binary on amd64 kernel -- I haven't tried yet without Docker for amd64 kernel though.
IIRC, Fedora23 was OK(with Ubuntu trusty image) and Fedora24 has this problem.

@okuoku

This comment has been minimized.

Contributor

okuoku commented Aug 9, 2016

Uh, it seems the problem belongs to Docker.. running the same binary which was built inside Docker(osrf/ubuntu_32bit:trusty) on the host directly, it runs successfully.

I can reproduce the problem with official ubuntu:trusty image and the binary built on osrf/ubuntu_32bit:trusty on Ubuntu 16.04 host.

Dockerfile:

FROM ubuntu:trusty
RUN apt-get update && apt-get install -y lib32z1
COPY libgc.so.1 /
COPY gctest /

Transcript:

# docker run -it --rm  gc_test bash
root@f0a1905f64b7:/# LD_LIBRARY_PATH=. ./gctest
getcontext failed: Use another register retrieval method?
Aborted (core dumped)
@ivmai

This comment has been minimized.

Owner

ivmai commented Aug 11, 2016

Please test a62e6fc

@andyli

This comment has been minimized.

Contributor

andyli commented Aug 12, 2016

I confirm it works now. Thanks a lot!

@andyli andyli closed this Aug 12, 2016

vbraun added a commit to vbraun/sage that referenced this issue Sep 14, 2016

Trac #21474: Patch Boehm-Weiser gc so that ecl builds on 32-bit Linux…
… Docker images

I am building Sage on a 32-bit Linux Docker (https://github.com/mkoeppe
/docker-images/tree/master/sagemath-buildenv-32bit).

Building ecl fails with this error: `getcontext failed: Use another
register retrieval method?`

This is solved with a patch that is a backport from the patch mentioned
here
ivmai/bdwgc#133
(branch here: https://github.com/mkoeppe/bdwgc/tree/gc7_2f_sage)

URL: https://trac.sagemath.org/21474
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): François Bissey

vbraun added a commit to vbraun/sage that referenced this issue Sep 15, 2016

Trac #21474: Patch Boehm-Weiser gc so that ecl builds on 32-bit Linux…
… Docker images

I am building Sage on a 32-bit Linux Docker (https://github.com/mkoeppe
/docker-images/tree/master/sagemath-buildenv-32bit).

Building ecl fails with this error: `getcontext failed: Use another
register retrieval method?`

This is solved with a patch that is a backport from the patch mentioned
here
ivmai/bdwgc#133
(branch here: https://github.com/mkoeppe/bdwgc/tree/gc7_2f_sage)

URL: https://trac.sagemath.org/21474
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): François Bissey

vbraun added a commit to vbraun/sage that referenced this issue Sep 15, 2016

Trac #21474: Patch Boehm-Weiser gc so that ecl builds on 32-bit Linux…
… Docker images

I am building Sage on a 32-bit Linux Docker (https://github.com/mkoeppe
/docker-images/tree/master/sagemath-buildenv-32bit).

Building ecl fails with this error: `getcontext failed: Use another
register retrieval method?`

This is solved with a patch that is a backport from the patch mentioned
here
ivmai/bdwgc#133
(branch here: https://github.com/mkoeppe/bdwgc/tree/gc7_2f_sage)

URL: https://trac.sagemath.org/21474
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): François Bissey

ivmai added a commit that referenced this issue Apr 26, 2018

Avoid multiple 'getcontext failed' warnings if getcontext is broken
Issue #133 (bdwgc).

* mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT]
(GC_with_callee_saves_pushed): Define getcontext_works static variable;
do not call getcontext() if getcontext_works < 0; add comment; set
getcontext_works to 1 or -1 (depending whether getcontext is working)
if getcontext_works is zero.
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT]
(callee_saves_pushed_dummy_fn): New static function (empty).
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (GC_init): Call
GC_with_callee_saves_pushed(callee_saves_pushed_dummy_fn) if GC_dont_gc
or GC_dont_precollect (otherwise it is called by GC_gcollect_inner);
add comment.

ivmai added a commit that referenced this issue Apr 26, 2018

Fix syntax of conditional operator in with_callee_saves_pushed
(fix of commit b594132)

Issue #133 (bdwgc).

* mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT]
(GC_with_callee_saves_pushed): Fix syntax of ?: operator (add missing
'?' symbol).

ivmai added a commit that referenced this issue Apr 26, 2018

Avoid multiple 'getcontext failed' warnings if getcontext is broken
(back-port of commits b594132, 2bfaff7 from 'master')

Issue #133 (bdwgc).

* mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT]
(GC_with_callee_saves_pushed): Define getcontext_works static variable;
do not call getcontext() if getcontext_works < 0; add comment; set
getcontext_works to 1 or -1 (depending whether getcontext is working)
if getcontext_works is zero.
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT]
(callee_saves_pushed_dummy_fn): New static function (empty).
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (GC_init): Call
GC_with_callee_saves_pushed(callee_saves_pushed_dummy_fn) if GC_dont_gc
or GC_dont_precollect (otherwise it is called by GC_gcollect_inner);
add comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment