Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Issue 757333003: Win64: Fix a pointer truncation bug in nspr. (Closed)

Created:
6 years ago by Nico
Modified:
6 years ago
Reviewers:
wtc, scottmg
CC:
chromium-reviews
Visibility:
Public.

Description

Win64: Fix a pointer truncation bug in nspr. Found by this clang warning: ..\..\third_party\nss\nspr\pr\src\threads\combined\pruthr.c(82,23) : warning(clang): cast to 'char *' from smaller integer type 'long' [-Wint-to-pointer-cast] stack->stackTop = (char*) ((((long)&type + _pr_pageSize - 1) ^ ..\..\third_party\nss\nspr\pr\src\threads\combined\pruthr.c(182,25) : warning(clang): cast to 'char *' from smaller integer type 'long' [-Wint-to-pointer-cast] ts->allocBase = (char*) ((((long)&ts + _pr_pageSize - 1) ^ 2 warnings generated. I don't know if this code path is hit in practice. BUG=82385 R=scottmg@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=293130

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -4 lines) Patch
M README.chromium View 1 chunk +3 lines, -0 lines 0 comments Download
M nspr/pr/src/threads/combined/pruthr.c View 2 chunks +4 lines, -4 lines 1 comment Download
A patches/nspr-no-pointers-in-longs.patch View 1 chunk +35 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (1 generated)
Nico
6 years ago (2014-11-26 18:26:33 UTC) #2
scottmg
lgtm
6 years ago (2014-11-26 18:41:51 UTC) #3
Nico
Committed patchset #1 (id:1) manually as r293130 (presubmit successful).
6 years ago (2014-11-26 19:09:28 UTC) #4
wtc
6 years ago (2014-12-01 18:34:02 UTC) #5
Message was sent while issue was closed.
Patch set 1 LGTM.

This will be fixed in NSPR 4.10.8. Thanks.

https://codereview.chromium.org/757333003/diff/1/nspr/pr/src/threads/combined...
File nspr/pr/src/threads/combined/pruthr.c (right):

https://codereview.chromium.org/757333003/diff/1/nspr/pr/src/threads/combined...
nspr/pr/src/threads/combined/pruthr.c:76: stack->stackTop = (char*)
((((intptr_t)&type) >> _pr_pageShift)
In the NSPR upstream, I changed intptr_t to PRWord, which is a (poorly named)
NSPR type commonly used for this purpose. In Chromium it is fine to just use
intptr_t.

PRWord and intptr_t are both defined as __int64 in WIN64. Here is Visual C++
2010's definition of intptr_t:

#ifndef _INTPTR_T_DEFINED
 #define _INTPTR_T_DEFINED
 #ifdef _WIN64
typedef __int64 intptr_t;
 #else /* _WIN64 */
typedef _W64 int intptr_t;
 #endif /* _WIN64 */
#endif /* _INTPTR_T_DEFINED */

Powered by Google App Engine
This is Rietveld 408576698