From: Andy Wingo <wingo@pobox.com>
To: bug-guile@gnu.org
Subject: symbol interning and lookup not threadsafe
Date: Wed, 05 Jan 2011 16:24:57 -0500 [thread overview]
Message-ID: <m34o9ndowm.fsf@unquote.localdomain> (raw)
Symbols get interned through scm_i_str2symbol, which looks like this:
/* Intern SYMBOL, an uninterned symbol. */
static void
intern_symbol (SCM symbol)
{
SCM slot, cell;
unsigned long hash;
hash = scm_i_symbol_hash (symbol) % SCM_HASHTABLE_N_BUCKETS (symbols);
slot = SCM_HASHTABLE_BUCKET (symbols, hash);
cell = scm_cons (symbol, SCM_UNDEFINED);
SCM_SET_HASHTABLE_BUCKET (symbols, hash, scm_cons (cell, slot));
SCM_HASHTABLE_INCREMENT (symbols);
if (SCM_HASHTABLE_N_ITEMS (symbols) > SCM_HASHTABLE_UPPER (symbols))
scm_i_rehash (symbols, scm_i_hash_symbol, 0, "intern_symbol");
}
static SCM
scm_i_str2symbol (SCM str)
{
SCM symbol;
size_t raw_hash = scm_i_string_hash (str);
symbol = lookup_interned_symbol (str, raw_hash);
if (scm_is_false (symbol))
{
/* The symbol was not found, create it. */
symbol = scm_i_make_symbol (str, 0, raw_hash,
scm_cons (SCM_BOOL_F, SCM_EOL));
intern_symbol (symbol);
}
return symbol;
}
This is not threadsafe.
Andy
--
http://wingolog.org/
next reply other threads:[~2011-01-05 21:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-05 21:24 Andy Wingo [this message]
2011-01-23 21:23 ` symbol interning and lookup not threadsafe Andy Wingo
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/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m34o9ndowm.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=bug-guile@gnu.org \
/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.
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).