After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 304790 - gthread shouldn't abort when stacksize cannot be set
gthread shouldn't abort when stacksize cannot be set
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gthread
2.4.x
Other GNU Hurd
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2005-05-19 18:25 UTC by Michael Banck
Modified: 2005-06-09 15:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.7/2.8


Attachments
Proposed patch removing error check (585 bytes, patch)
2005-05-19 18:43 UTC, Michael Banck
none Details | Review

Description Michael Banck 2005-05-19 18:25:03 UTC
Distribution/Version: Debian unstable

Although GNU/Hurd's libpthread includes a pthread_attr_setstacksize() function,
it is mostly a stub and returns EINVAL except if the caller specifies a stack
size of 2MB.

However, gthread just bails out if pthread_attr_setstacksize() fails,
resulting in e.g. gnome-display-properties and nautilus to abort upon
startup:

GThread-ERROR **: file gthread-posix.c: line 310 (): error 'Invalid argument'
during 'pthread_attr_setstacksize (&attr, stack_size)'
aborting...

Instead, we believe it should not fail if this optional feature cannot be met
and simply continue.

Neal Walfield has written some more on this at
http://lists.debian.org/debian-hurd/2005/05/msg00117.html:

-begin quote--
Our current libpthread doesn't support floating stacks.  To get at the
thread specific data (TSD), we look at the base of the stack.  To find
the base of the stack, we take the current stack point and bitwise and
it with ~(2MB - 1).  This mode of operation makes supporting user
stacks very difficult as we have no mechanism to express these
constraints to the user.

Currently, pthread_attr_setstacksize is essentially a stub (if the
caller specifies 2MB it succeeds all other values return EINVAL).
glib thinks that since it is present (it checks for it using autoconf,
apparently), it must work.  Arguably, we are not not POSIX compliant:

  The pthread_attr_setstacksize() function shall fail if:

  [EINVAL]
      The value of stacksize is less than {PTHREAD_STACK_MIN} or
      exceeds a system-imposed limit.

Thus for our implementation PTHREAD_STACK_MIN would be 2MB and the
system imposed limit would be 2MB. [...]

Since glib just ignores the stack size parameter if
pthread_attr_setstacksize is not found, it should just ignore any
failure.
--end quote--
Comment 1 Michael Banck 2005-05-19 18:43:35 UTC
Created attachment 46650 [details] [review]
Proposed patch removing error check

Just a proposal, as I am not sure what else posix_check_cmd does.
Comment 2 Matthias Clasen 2005-05-20 13:48:54 UTC
posix_check_cmd does nothing beyond reporting the error (it is defined earlier
in the same file).
Comment 3 Matthias Clasen 2005-06-09 15:27:24 UTC
2005-06-09  Matthias Clasen  <mclasen@redhat.com>

	* gthread-posix.c (g_thread_create_posix_impl): Allow
	setstacksize to fail.  (#304790, Michael Banck)