From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Status: No, score=-0.4 required=3.0 tests=AWL,BAYES_00 shortcircuit=no autolearn=ham version=3.3.2 X-Original-To: kgio-public@bogomips.org Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 2D4F21FA6C for ; Tue, 30 Dec 2014 07:00:25 +0000 (UTC) Received: by mail-la0-f52.google.com with SMTP id hs14so12391444lab.11 for ; Mon, 29 Dec 2014 23:00:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-type; bh=YRYAkmpu8hxx6XILpHjGaeJdB+LL41uKfdPMgTtv86s=; b=kZknsR299EM3yDbuLR4iJrf6vhQ9U3X1Xn7dtuhYY+yl131GSZESu2xcVDdc1486WH oxoRaI+iAO7tM2/DLOZmOeJZbSS5ci8vg7RbX/MfrVtvn5gnGh/d8EmbQSrtgRKpHtVQ XuVj52zP9RUpcSvdJRxV5zVemdIJMymcjB4BA4/a0vUu7iSNFgfrAiTnpXSZJQE1H+Z3 Cxob6ST1lja6YCaTv5Aqi8EENtnn0TkFpXUEvJZv/DQFQrEcNU2m/rRV2igUX226p6TU 6nt148ISp2FPGki6zGBJ6xlz/U4YU+9v6ROLu/gUj6rI+r4mIhQn7Rc4WTZPowLeNqzv WtOQ== X-Gm-Message-State: ALoCoQl+KvQNkjy0JlzMUyLmsXu1bmbg1DgqEXn4g0WsoMJvnIwEkUcITM5llrt6detrPGiJL8/Q X-Received: by 10.152.19.71 with SMTP id c7mr60581831lae.79.1419922823492; Mon, 29 Dec 2014 23:00:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.150.233 with HTTP; Mon, 29 Dec 2014 23:00:01 -0800 (PST) From: Petr Novodvorskiy Date: Tue, 30 Dec 2014 02:00:01 -0500 Message-ID: Subject: programs using kgio crash under memory pressure during init To: kgio-public@bogomips.org Cc: Lara Martin , Nick Astete Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: PublicInbox::Filter 0.0.1 List-Id: In rare cases when we run our unit tests we get following error: /var/lib/gems/1.8/gems/kgio-2.7.4/lib/kgio_ext.so: [BUG] constant not a symbol or string ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] Aborted (core dumped) rake aborted! I was able to run out unit tests in memory constrained environment and get to reproduce it 4 out of 5 runs. I was able to reproduce it even after I upgraded our kgio version. After looking in the code, I think I was able to identify the problem. In init_kgio_tryopen(), when rb_funcall is called to get list of errno constants, it doesn't protect returned list from garbage collecting. I made modification (below) that seemed to fix the problem (I wasn't able to reproduce it anymore). Thanks, Petr. diff --git a/ext/kgio/tryopen.c b/ext/kgio/tryopen.c index 20f3f6d..d97a5fa 100644 --- a/ext/kgio/tryopen.c +++ b/ext/kgio/tryopen.c @@ -162,7 +162,13 @@ void init_kgio_tryopen(void) rb_define_alias(cFile, "to_path", "path"); errno2sym = st_init_numtable(); - tmp = rb_funcall(rb_mErrno, rb_intern("constants"), 0); + + VALUE *get_err_constants(VALUE blah) { + return rb_funcall(rb_mErrno, rb_intern("constants"), 0); + } + int exception; + tmp = rb_protect(get_err_constants, (VALUE)NULL, &exception); + len = RARRAY_LEN(tmp); for (i = 0; i < len; i++) { VALUE error;