Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#38999 closed defect (fixed)

base/src/pextlib1.0/tracelib.c setrlimit failure

Reported by: ajdudman Owned by: neverpanic (Clemens Lang)
Priority: Normal Milestone:
Component: base Version: 2.1.3
Keywords: Cc:
Port:

Description (last modified by mf2k (Frank Schima))

Say OSX is 10.8.3 and open files are:

ulimit -Sn
10240
ulimit -Hn
12288

Then the current code will have rl.rlim_max as 12288, which is greater than OPEN_MAX. This produces an error in setrlimit() at line 438. See the attached log. OSX's setrlimit(2) is tricky and recently its behavior has changed. The manual page gives highlights. This problem is analogous to closed, fixed ticket:35612 for bsdmake and the solution is similar.

Attachments (4)

portsuvt (375 bytes) - added by ajdudman 12 years ago.
log showing setrlimit warning
p (529 bytes) - added by ajdudman 12 years ago.
setrlimit patch for tracelib.c
patch_to_100071.diff (978 bytes) - added by ajdudman 12 years ago.
getrlimit setrlimit patch
patch_to_105748.diff (593 bytes) - added by ajdudman 12 years ago.
getrlimit setrlimit patch

Download all attachments as: .zip

Change History (12)

Changed 12 years ago by ajdudman

Attachment: portsuvt added

log showing setrlimit warning

Changed 12 years ago by ajdudman

Attachment: p added

setrlimit patch for tracelib.c

comment:1 Changed 12 years ago by ajdudman

Say OSX is 10.8.3 and open files are:

ulimit -Sn
10240
ulimit -Hn
12288

The current code uses RLIM_INFINITY. This produces an error in setrlimit() at line 438. See the attached log. OSX's setrlimit(2) is tricky and recently its behavior has changed. The manual page gives highlights. This problem is like closed, fixed Ticket 35612 for bsdmake and the solution is similar.

Last edited 12 years ago by ajdudman (previous) (diff)

comment:2 Changed 12 years ago by ajdudman

Sorry for the ugly ticket. I am having trouble editing the description. Please strike out the first sentence of the second paragraph. That applied to the old code for bsdmake port and is not valid here.

comment:3 Changed 12 years ago by neverpanic (Clemens Lang)

Cc: cal@… removed
Owner: changed from macports-tickets@… to cal@…
Status: newassigned

Thanks, r105748.

comment:4 Changed 12 years ago by neverpanic (Clemens Lang)

Resolution: fixed
Status: assignedclosed

I wonder why I never saw this message, though.

comment:5 Changed 12 years ago by mf2k (Frank Schima)

Description: modified (diff)

comment:6 Changed 12 years ago by ajdudman

Cal, Did you set rlim_max to something less than default unlimited in your shell, before running "port -t" command? That is when I see it.

comment:7 Changed 12 years ago by ajdudman

I do not like my patch from yesterday nor r105748 as they are incomplete. The rl structure must be initialized first by calling getrlimit().

Changed 12 years ago by ajdudman

Attachment: patch_to_100071.diff added

getrlimit setrlimit patch

Changed 12 years ago by ajdudman

Attachment: patch_to_105748.diff added

getrlimit setrlimit patch

comment:8 Changed 12 years ago by neverpanic (Clemens Lang)

You're right, the struct might not be initialized; I should have seen that before commiting.

My shell seems to have a default soft limit on the number of open files (I never changed any limit settings). It currently is 2560, but I recall it being 256 when I checked last time. Maybe the OS (or my shell) is doing some magic… The hard limit is unlimited, though.

Your patch looks good, but if getrlimit failed, setrlimit would work on unitialized data structures, so I thought it might be better to only run setrlimit when getrlimit succeeds. See r105765.

Note: See TracTickets for help on using tickets.