unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Raeburn <raeburn@raeburn.org>
To: "Jan Djärv" <jan.h.d@swipnet.se>
Cc: Eli Zaretskii <eliz@gnu.org>, Ryan Yeske <rcyeske@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: problems building trunk in OpenBSD/i386
Date: Thu, 19 Jul 2007 21:18:32 -0400	[thread overview]
Message-ID: <260A0E9D-5A08-4B83-B953-62AF69323093@raeburn.org> (raw)
In-Reply-To: <4697286C.8040605@swipnet.se>

On Jul 13, 2007, at 3:23, Jan Djärv wrote:
> Ken Raeburn skrev:
>> The other parts of the stack trace indicate that the rest of the  
>> loop is in the C library -- pthread_once calls pthread_mutex_lock,  
>> which initializes some thread support code, which is causing some  
>> priority queue code to try to allocate storage, which winds up  
>> calling into gmalloc, which again ensures that initialization has  
>> been done by calling pthread_once.
>
> This sounds like a bug in pthread_once.

Which part?  I think having it allocate storage is perfectly  
acceptable, though if you're explicitly linking against the thread  
library it'd probably be quicker for stuff that'll always be needed  
to be allocated in static storage.  One might argue that internal  
uses of standard C library functions by the system library functions  
should use specially named internal versions of the C library  
functions so as to prevent overriding them, but then you get into  
questions of where you draw the line(s), and what "overriding" is  
really supposed to do.

> I think we safely can call malloc_initialize from main itself  
> without thread protection.  The protection is from threads created  
> by the file dialog, and they get created when the dialog is first  
> used.  So we should be safe.

That sounds like it'll probably work, yes... guess I was looking for  
a too-general solution, suitable for other uses of this gmalloc.c.   
The semantics of some pthread operations and their interactions with  
the language specs are sufficiently vague and subtle[1] that I'd be  
wary of removing any pthread operations, but since malloc_initialize  
and then malloc (with its mutex locking) would be called in the main  
thread before any other threads are created, I think it's probably safe.

Ken

[1] See http://portal.acm.org/citation.cfm?id=1065042 for some examples.

  reply	other threads:[~2007-07-20  1:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-12  9:37 problems building trunk in OpenBSD/i386 Ryan Yeske
2007-07-12 11:07 ` Eli Zaretskii
2007-07-12 17:22   ` Ken Raeburn
2007-07-13  7:23     ` Jan Djärv
2007-07-20  1:18       ` Ken Raeburn [this message]
2007-07-20  6:43         ` Jan Djärv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=260A0E9D-5A08-4B83-B953-62AF69323093@raeburn.org \
    --to=raeburn@raeburn.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jan.h.d@swipnet.se \
    --cc=rcyeske@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).