Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a83ee105
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a83ee105
编写于
10月 17, 2015
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8133249: Occasional SIGSEGV: non thread-safe use of strerr in get LastErrorString
Reviewed-by: coffeys, igerasim
上级
72d6d0ac
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
67 addition
and
41 deletion
+67
-41
make/lib/CoreLibraries.gmk
make/lib/CoreLibraries.gmk
+1
-0
make/mapfiles/libjava/mapfile-vers
make/mapfiles/libjava/mapfile-vers
+2
-0
src/share/native/common/jni_util.h
src/share/native/common/jni_util.h
+1
-0
src/share/native/java/util/zip/zip_util.c
src/share/native/java/util/zip/zip_util.c
+11
-4
src/solaris/native/common/jni_util_md.c
src/solaris/native/common/jni_util_md.c
+13
-0
src/solaris/native/java/io/io_util_md.c
src/solaris/native/java/io/io_util_md.c
+2
-9
src/solaris/native/java/lang/UNIXProcess_md.c
src/solaris/native/java/lang/UNIXProcess_md.c
+4
-3
src/solaris/native/java/net/PlainDatagramSocketImpl.c
src/solaris/native/java/net/PlainDatagramSocketImpl.c
+15
-13
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
+4
-10
src/windows/native/common/jni_util_md.c
src/windows/native/common/jni_util_md.c
+9
-0
src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
...indows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
+5
-2
未找到文件。
make/lib/CoreLibraries.gmk
浏览文件 @
a83ee105
...
...
@@ -205,6 +205,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
-framework Foundation \
-framework Security -framework SystemConfiguration, \
LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \
-export:getErrorString \
jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \
advapi32.lib version.lib, \
...
...
make/mapfiles/libjava/mapfile-vers
浏览文件 @
a83ee105
...
...
@@ -284,6 +284,8 @@ SUNWprivate_1.1 {
# ZipFile.c needs this one
throwFileNotFoundException;
# zip_util.c needs this
getErrorString;
# Java_sun_misc_VM_getState; threads.c
# Java_sun_misc_VM_threadsSuspended; threads.c
...
...
src/share/native/common/jni_util.h
浏览文件 @
a83ee105
...
...
@@ -391,6 +391,7 @@ void* getProcessHandle();
void
buildJniFunctionName
(
const
char
*
sym
,
const
char
*
cname
,
char
*
jniEntryName
);
extern
int
getErrorString
(
int
err
,
char
*
buf
,
size_t
len
);
#ifdef __cplusplus
}
/* extern "C" */
#endif
/* __cplusplus */
...
...
src/share/native/java/util/zip/zip_util.c
浏览文件 @
a83ee105
...
...
@@ -1449,6 +1449,7 @@ jboolean JNICALL
ZIP_ReadEntry
(
jzfile
*
zip
,
jzentry
*
entry
,
unsigned
char
*
buf
,
char
*
entryname
)
{
char
*
msg
;
char
tmpbuf
[
1024
];
strcpy
(
entryname
,
entry
->
name
);
if
(
entry
->
csize
==
0
)
{
...
...
@@ -1467,8 +1468,11 @@ ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname)
msg
=
zip
->
msg
;
ZIP_Unlock
(
zip
);
if
(
n
==
-
1
)
{
jio_fprintf
(
stderr
,
"%s: %s
\n
"
,
zip
->
name
,
msg
!=
0
?
msg
:
strerror
(
errno
));
if
(
msg
==
0
)
{
getErrorString
(
errno
,
tmpbuf
,
sizeof
(
tmpbuf
));
msg
=
tmpbuf
;
}
jio_fprintf
(
stderr
,
"%s: %s
\n
"
,
zip
->
name
,
msg
);
return
JNI_FALSE
;
}
buf
+=
n
;
...
...
@@ -1481,8 +1485,11 @@ ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname)
if
((
msg
==
NULL
)
||
(
*
msg
==
0
))
{
msg
=
zip
->
msg
;
}
jio_fprintf
(
stderr
,
"%s: %s
\n
"
,
zip
->
name
,
msg
!=
0
?
msg
:
strerror
(
errno
));
if
(
msg
==
0
)
{
getErrorString
(
errno
,
tmpbuf
,
sizeof
(
tmpbuf
));
msg
=
tmpbuf
;
}
jio_fprintf
(
stderr
,
"%s: %s
\n
"
,
zip
->
name
,
msg
);
return
JNI_FALSE
;
}
}
...
...
src/solaris/native/common/jni_util_md.c
浏览文件 @
a83ee105
...
...
@@ -37,6 +37,13 @@ char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy)
return
NULL
;
}
#if defined(LINUX) && (defined(_GNU_SOURCE) || \
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 200112L \
&& defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 600))
extern
int
__xpg_strerror_r
(
int
,
char
*
,
size_t
);
#define strerror_r(a, b, c) __xpg_strerror_r((a), (b), (c))
#endif
void
*
getProcessHandle
()
{
static
void
*
procHandle
=
NULL
;
if
(
procHandle
!=
NULL
)
{
...
...
@@ -59,3 +66,9 @@ void buildJniFunctionName(const char *sym, const char *cname,
}
}
int
getErrorString
(
int
err
,
char
*
buf
,
size_t
len
)
{
if
(
err
==
0
||
len
<
1
)
return
0
;
return
strerror_r
(
err
,
buf
,
len
);
}
src/solaris/native/java/io/io_util_md.c
浏览文件 @
a83ee105
...
...
@@ -216,13 +216,6 @@ size_t
getLastErrorString
(
char
*
buf
,
size_t
len
)
{
if
(
errno
==
0
||
len
<
1
)
return
0
;
const
char
*
err
=
strerror
(
errno
);
size_t
n
=
strlen
(
err
);
if
(
n
>=
len
)
n
=
len
-
1
;
strncpy
(
buf
,
err
,
n
);
buf
[
n
]
=
'\0'
;
return
n
;
getErrorString
(
errno
,
buf
,
len
);
return
strlen
(
buf
);
}
src/solaris/native/java/lang/UNIXProcess_md.c
浏览文件 @
a83ee105
...
...
@@ -292,12 +292,13 @@ throwIOException(JNIEnv *env, int errnum, const char *defaultDetail)
static
const
char
*
const
format
=
"error=%d, %s"
;
const
char
*
detail
=
defaultDetail
;
char
*
errmsg
;
char
tmpbuf
[
1024
];
jstring
s
;
if
(
errnum
!=
0
)
{
const
char
*
s
=
strerror
(
errnum
);
if
(
strcmp
(
s
,
"Unknown error"
)
!=
0
)
detail
=
s
;
int
ret
=
getErrorString
(
errnum
,
tmpbuf
,
sizeof
(
tmpbuf
)
);
if
(
ret
!=
EINVAL
)
detail
=
tmpbuf
;
}
/* ASCII Decimal representation uses 2.4 times as many bits as binary. */
errmsg
=
NEW
(
char
,
strlen
(
format
)
+
strlen
(
detail
)
+
3
*
sizeof
(
errnum
));
...
...
src/solaris/native/java/net/PlainDatagramSocketImpl.c
浏览文件 @
a83ee105
...
...
@@ -954,6 +954,7 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
jobject
this
)
{
jobject
fdObj
=
(
*
env
)
->
GetObjectField
(
env
,
this
,
pdsi_fdID
);
int
arg
,
fd
,
t
=
1
;
char
tmpbuf
[
1024
];
#ifdef AF_INET6
int
domain
=
ipv6_available
()
?
AF_INET6
:
AF_INET
;
#else
...
...
@@ -989,14 +990,14 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
arg
=
65507
;
if
(
JVM_SetSockOpt
(
fd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
char
*
)
&
arg
,
sizeof
(
arg
))
<
0
)
{
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
strerror
(
errno
)
);
getErrorString
(
errno
,
tmpbuf
,
sizeof
(
tmpbuf
));
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
tmpbuf
);
return
;
}
if
(
JVM_SetSockOpt
(
fd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
char
*
)
&
arg
,
sizeof
(
arg
))
<
0
)
{
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
strerror
(
errno
)
);
getErrorString
(
errno
,
tmpbuf
,
sizeof
(
tmpbuf
));
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
tmpbuf
);
return
;
}
#endif
/* __APPLE__ */
...
...
@@ -1007,9 +1008,10 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
arg
=
0
;
int
level
=
(
domain
==
AF_INET6
)
?
IPPROTO_IPV6
:
IPPROTO_IP
;
if
((
setsockopt
(
fd
,
level
,
IP_MULTICAST_ALL
,
(
char
*
)
&
arg
,
sizeof
(
arg
))
<
0
)
&&
(
errno
!=
ENOPROTOOPT
))
{
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
strerror
(
errno
));
(
errno
!=
ENOPROTOOPT
))
{
getErrorString
(
errno
,
tmpbuf
,
sizeof
(
tmpbuf
));
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
tmpbuf
);
close
(
fd
);
return
;
}
...
...
src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
浏览文件 @
a83ee105
...
...
@@ -308,21 +308,15 @@ Java_sun_nio_fs_UnixNativeDispatcher_getcwd(JNIEnv* env, jclass this) {
JNIEXPORT
jbyteArray
Java_sun_nio_fs_UnixNativeDispatcher_strerror
(
JNIEnv
*
env
,
jclass
this
,
jint
error
)
{
char
*
msg
;
char
tmpbuf
[
1024
]
;
jsize
len
;
jbyteArray
bytes
;
#ifdef _AIX
/* strerror() is not thread-safe on AIX so we have to use strerror_r() */
char
buffer
[
256
];
msg
=
(
strerror_r
((
int
)
error
,
buffer
,
256
)
==
0
)
?
buffer
:
"Error while calling strerror_r"
;
#else
msg
=
strerror
((
int
)
error
);
#endif
len
=
strlen
(
msg
);
getErrorString
((
int
)
errno
,
tmpbuf
,
sizeof
(
tmpbuf
));
len
=
strlen
(
tmpbuf
);
bytes
=
(
*
env
)
->
NewByteArray
(
env
,
len
);
if
(
bytes
!=
NULL
)
{
(
*
env
)
->
SetByteArrayRegion
(
env
,
bytes
,
0
,
len
,
(
jbyte
*
)
msg
);
(
*
env
)
->
SetByteArrayRegion
(
env
,
bytes
,
0
,
len
,
(
jbyte
*
)
tmpbuf
);
}
return
bytes
;
}
...
...
src/windows/native/common/jni_util_md.c
浏览文件 @
a83ee105
...
...
@@ -142,6 +142,15 @@ void* getProcessHandle() {
return
(
void
*
)
GetModuleHandle
(
NULL
);
}
int
getErrorString
(
int
err
,
char
*
buf
,
size_t
len
)
{
int
ret
=
0
;
if
(
err
==
0
||
len
<
1
)
return
0
;
ret
=
strerror_s
(
buf
,
len
,
err
);
return
ret
;
}
/*
* Windows symbols can be simple like JNI_OnLoad or __stdcall format
* like _JNI_OnLoad@8. We need to handle both.
...
...
src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
浏览文件 @
a83ee105
...
...
@@ -2239,8 +2239,11 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobj
optlen
=
sizeof
(
optval
.
i
);
if
(
NET_GetSockOpt
(
fd
,
level
,
optname
,
(
void
*
)
&
optval
,
&
optlen
)
<
0
)
{
char
errmsg
[
255
];
sprintf
(
errmsg
,
"error getting socket option: %s
\n
"
,
strerror
(
errno
));
char
tmpbuf
[
255
];
int
size
=
0
;
char
errmsg
[
255
+
31
];
getErrorString
(
errno
,
tmpbuf
,
sizeof
(
tmpbuf
));
sprintf
(
errmsg
,
"error getting socket option: %s"
,
tmpbuf
);
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
errmsg
);
return
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录