[
https://issues.apache.org/jira/browse/HADOOP-12955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15209299#comment-15209299
]
Colin Patrick McCabe commented on HADOOP-12955:
-----------------------------------------------
Thanks, [~drankye]. I agree that building using {{\-Drequire.isal}} is
important, and I hope we can get YETUS-222 in soon.
{code}
124 void get_library_name(char* buf, size_t buf_len) {
125 #ifdef UNIX
126 Dl_info dl_info;
127
128 if (isaLoader == NULL || isaLoader->ec_encode_data == NULL) {
129 strncpy(buf, HADOOP_ISAL_LIBRARY, buf_len);
130 }
131
132 if(dladdr(isaLoader->ec_encode_data, &dl_info)) {
133 strncpy(buf, dl_info.dli_fname, buf_len);
134 }
135 #else
136 LPTSTR filename = NULL;
137
138 if (isaLoader == NULL || isaLoader->libec == NULL) {
139 strncpy(buf, HADOOP_ISAL_LIBRARY, buf_len);
140 }
141
142 if (GetModuleFileName(isaLoader->libec, filename, 256) > 0) {
143 strncpy(buf, filename, buf_len);
144 }
145 #endif
{code}
Right now, {{buf}} is left uninitialized if neither if statement is taken in
the non-UNIX code path. This case should be an error instead.
Please do not use {{strncpy}}. It zeroes the entire end of the buffer, which
is unnecessary in this case. It also can produce a buffer which is not
null-terminated if {{src}} is longer than {{dst}}. Instead, use
{{snprintf(buf, buf_len, "%s", source);}}.
You need to check if the string you're trying to copy is too long, and return
an error if that is so. Please do not silently truncate the name string.
Why is there no return statement on line 140? Is there ever a case where we
would want to overwrite the string we wrote on line 139 later in the function?
The potential error coming from {{loadLib}} is not handled.
> checknative failed when checking ISA-L library
> ----------------------------------------------
>
> Key: HADOOP-12955
> URL: https://issues.apache.org/jira/browse/HADOOP-12955
> Project: Hadoop Common
> Issue Type: Bug
> Components: native
> Reporter: Kai Zheng
> Assignee: Kai Zheng
> Attachments: HADOOP-12955-v1.patch
>
>
> Ref. the comment
> [here|https://issues.apache.org/jira/browse/HADOOP-11540?focusedCommentId=15207619&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15207619].
>
> When run hadoop checknative, it also failed. Got something like below from
> log:
> {noformat}
> Stack: [0x00007f2b9d405000,0x00007f2b9d506000], sp=0x00007f2b9d504748, free
> space=1021k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native
> code)
> V [libjvm.so+0xa90c90] UTF8::unicode_length(char const*)+0x0
> V [libjvm.so+0x6ddfc3] jni_NewStringUTF+0xc3
> j
> org.apache.hadoop.io.erasurecode.ErasureCodeNative.getLibraryName()Ljava/lang/String;+0
> j org.apache.hadoop.util.NativeLibraryChecker.main([Ljava/lang/String;)V+212
> v ~StubRoutines::call_stub
> V [libjvm.so+0x68c616] JavaCalls::call_helper(JavaValue*, methodHandle*,
> JavaCallArguments*, Thread*)+0x1056
> V [libjvm.so+0x6cdc32] jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*,
> JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x362
> V [libjvm.so+0x6ea63a] jni_CallStaticVoidMethod+0x17a
> C [libjli.so+0x7bcc] JavaMain+0x80c
> C [libpthread.so.0+0x8182] start_thread+0xc2
> Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
> j
> org.apache.hadoop.io.erasurecode.ErasureCodeNative.getLibraryName()Ljava/lang/String;+0
> j org.apache.hadoop.util.NativeLibraryChecker.main([Ljava/lang/String;)V+212
> v ~StubRoutines::call_stub
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)