Closed
Bug 110263
Opened 24 years ago
Closed 21 years ago
static const NS_NAMED_LITERAL_STRING is not thread safe
Categories
(Core :: XPConnect, defect)
Tracking
()
RESOLVED
FIXED
Future
People
(Reporter: dbradley, Assigned: dbradley)
Details
Attachments
(1 file)
|
1.64 KB,
patch
|
darin.moz
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
There are two instances of static const declarations of this that are not thread
safe, at least under Windows. VC++ generates code that tests a flag for creation
that is subject to a race condition. The window of vulnerability is quite small,
but does exist.
http://lxr.mozilla.org/seamonkey/source/js/src/xpconnect/src/xpcconvert.cpp#554
Simple solution is to remove static, but that would incure two allocations for
the strings. This occurs in conversions of DOM Strings which occurs fairly
often. Using a lock seems rather heavy handed as well.
| Assignee | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.8
Comment 1•24 years ago
|
||
I really doubt you can even construct a test that will trigger any problem here.
I'd let it ride.
| Assignee | ||
Comment 2•24 years ago
|
||
You'd have to have two threads converting undefined/null to a DOM string all for
the first time. Given I generally don't buy lottery tickets and there's not a
simple inexpensive fix, futuring.
Target Milestone: mozilla0.9.8 → Future
Comment 3•21 years ago
|
||
Maybe the code has changed, but the trivial fix now is to just use string
literals, no?
const PRUnichar sEmptyString[] = {'\0'};
const PRUnichar sVoidString[] = {'u','n','d','e','f','i','n','e','d'.'\0'};
| Assignee | ||
Comment 4•21 years ago
|
||
Good point. This patch uses the formentioned array initalization which
eliminates the very slight threading issue.
Comment 5•21 years ago
|
||
Comment on attachment 157013 [details] [diff] [review]
Use array initialization
r=darin
Attachment #157013 -
Flags: review+
| Assignee | ||
Comment 6•21 years ago
|
||
Comment on attachment 157013 [details] [diff] [review]
Use array initialization
JST want to SR this? Also will have some tiny code size reduction.
Attachment #157013 -
Flags: superreview?(jst)
Comment 7•21 years ago
|
||
Comment on attachment 157013 [details] [diff] [review]
Use array initialization
+ static const PRUnichar EMPTY_STRING[] = { 0 };
+ static const PRUnichar VOID_STRING[] = { 'u', 'n', 'd', 'e', 'f',
'i', 'n', 'e', 'd', 0 };
I'd do s/0/'\0'/ to make it clearer that we're dealing with null terminators
here.
sr=jst either way.
Attachment #157013 -
Flags: superreview?(jst) → superreview+
Comment 8•21 years ago
|
||
David: will you check this in or should I?
| Assignee | ||
Comment 9•21 years ago
|
||
I was going to, I was hoping to have my cvs ssh key thingy working, but I
haven't heard back after sending in the key. So if you have some time, feel
free.
Comment 10•21 years ago
|
||
I checked this in with one small change, I changed
length = sizeof(VOID_STRING) / sizeof(PRUnichar);
to
length = NS_ARRAY_LENGTH(VOID_STRING) - 1;
(we don't want to count the terminating null-character in the length).
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•