Hi/2.

Paul Eggert wrote:
> KO Myung-Hun wrote:
>> getrlimit() was implemented in kLIBC and works well. Strangely,
>> however, it crashes due to 'stack overflow' or 'SIGSEGV' when used in
>> GNU M4.
> 
> This needs explanation in the form of a brief comment in the source code.
> 

Fixed.

> Also, I don't see how it can be said to work "well" if it crashes.  

Simple test cases work well. Anyway, fixed. ^^

> Most
> likely, kLIBC getrlimit is buggy, or is being compiled with the wrong
> options, or something like that.  The implementation of kLIBC getrlimit
> is incorrectly attempting to stuff a 32-bit unsigned value into a 32-bit
> signed variable, and it could be something as simple as that.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

From a9db09d5360c9a60ef55cf0444b5310291f11f25 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <k...@chollian.net>
Date: Wed, 16 Jul 2014 18:38:00 +0900
Subject: [PATCH] getdtablesize: do not use getrlimit() on OS/2 kLIBC

getrlimit() implementation of kLIBC is buggy. For examples, it crashes
due to 'stack overflow' or 'SIGSEGV' when used in GNU M4. So just use
getdtablesize() on kLIBC.

* lib/getdtablesize.c (rpl_getdtablesize): Do not use getrlimit() on
OS/2 kLIBC.
---
 lib/getdtablesize.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index f0c6271..07e9d57 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -92,6 +92,10 @@ getdtablesize (void)
 int
 rpl_getdtablesize(void)
 {
+/* getrlimit() implementation of kLIBC is buggy. For examples, it crashes
+   due to 'stack overflow' or 'SIGSEGV' when used in GNU M4. So just use
+   getdtablesize() on kLIBC.  */
+# ifndef __KLIBC__
   /* To date, this replacement is only compiled for Cygwin 1.7.25,
      which auto-increased the RLIMIT_NOFILE soft limit until it
      hits the compile-time constant hard limit of 3200.  Although
@@ -101,6 +105,7 @@ rpl_getdtablesize(void)
   struct rlimit lim;
   if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_max != RLIM_INFINITY)
     return lim.rlim_max;
+# endif
   return getdtablesize ();
 }
 
-- 
1.8.5.2

Reply via email to