<p dir="ltr">Such a patch would be very welcome. Just open up a diff on Phabricator and it should be reviewed and merged pretty quick.</p>
<div class="gmail_quote">On 15 Nov 2015 06:39, "Eugene Kosov via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello.<br>
<br>
I use these packages <a href="http://llvm.org/apt/" rel="noreferrer" target="_blank">http://llvm.org/apt/</a><br>
<br>
llldb doesn't work. It crashes on start with the following backtrace.<br>
<br>
#0 0x00007ffff475f8f9 in llvm::cl::Option::addArgument() () from /usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1<br>
#1 0x00007fffee3787af in global constructors keyed to a () from /usr/local/lib/python2.7/dist-packages/lldb/_lldb.so<br>
#2 0x00007fffefc6e020 in __frame_dummy_init_array_entry () from /usr/local/lib/python2.7/dist-packages/lldb/_lldb.so<br>
#3 0x00007fffffffdec8 in ?? ()<br>
#4 0x00007fffffffded8 in ?? ()<br>
#5 0x00007fffefc6e258 in __frame_dummy_init_array_entry ()<br>
#6 0x0000000000000000 in ?? ()<br>
<br>
Dump of assembler code for function _ZN4llvm2cl6Option11addArgumentEv:<br>
0x00007ffff475f8b0 <+0>: push %r15<br>
0x00007ffff475f8b2 <+2>: push %r14<br>
0x00007ffff475f8b4 <+4>: push %r13<br>
0x00007ffff475f8b6 <+6>: push %r12<br>
0x00007ffff475f8b8 <+8>: push %rbp<br>
0x00007ffff475f8b9 <+9>: push %rbx<br>
0x00007ffff475f8ba <+10>: mov %rdi,%rbx<br>
0x00007ffff475f8bd <+13>: sub $0x58,%rsp<br>
0x00007ffff475f8c1 <+17>: mov 0xe64818(%rip),%rbp # 0x7ffff55c40e0<br>
0x00007ffff475f8c8 <+24>: mov %fs:0x28,%rax<br>
0x00007ffff475f8d1 <+33>: mov %rax,0x48(%rsp)<br>
0x00007ffff475f8d6 <+38>: xor %eax,%eax<br>
0x00007ffff475f8d8 <+40>: callq 0x7ffff47a1740 <_ZN4llvm21llvm_is_multithreadedEv><br>
0x00007ffff475f8dd <+45>: test %al,%al<br>
0x00007ffff475f8df <+47>: jne 0x7ffff475fac0 <_ZN4llvm2cl6Option11addArgumentEv+528><br>
0x00007ffff475f8e5 <+53>: test %rbp,%rbp<br>
0x00007ffff475f8e8 <+56>: je 0x7ffff475face <_ZN4llvm2cl6Option11addArgumentEv+542><br>
0x00007ffff475f8ee <+62>: mov 0x18(%rbx),%r12<br>
0x00007ffff475f8f2 <+66>: mov 0xe647e7(%rip),%rbp # 0x7ffff55c40e0<br>
=> 0x00007ffff475f8f9 <+73>: cmpb $0x0,(%r12)<br>
0x00007ffff475f8fe <+78>: jne 0x7ffff475f968 <_ZN4llvm2cl6Option11addArgumentEv+184><br>
0x00007ffff475f900 <+80>: xor %r12d,%r12d<br>
0x00007ffff475f903 <+83>: movzwl 0xc(%rbx),%eax<br>
0x00007ffff475f907 <+87>: shr $0x7,%ax<br>
0x00007ffff475f90b <+91>: and $0x3,%eax<br>
0x00007ffff475f90e <+94>: cmp $0x1,%eax<br>
0x00007ffff475f911 <+97>: je 0x7ffff475fc10 <_ZN4llvm2cl6Option11addArgumentEv+864><br>
0x00007ffff475f917 <+103>: testb $0x8,0xd(%rbx)<br>
0x00007ffff475f91b <+107>: jne 0x7ffff475faf0 <_ZN4llvm2cl6Option11addArgumentEv+576><br>
0x00007ffff475f921 <+113>: movzbl 0xc(%rbx),%eax<br>
0x00007ffff475f925 <+117>: and $0x7,%eax<br>
0x00007ffff475f928 <+120>: cmp $0x4,%eax<br>
0x00007ffff475f92b <+123>: je 0x7ffff475fba0 <_ZN4llvm2cl6Option11addArgumentEv+752><br>
0x00007ffff475f931 <+129>: test %r12b,%r12b<br>
0x00007ffff475f934 <+132>: jne 0x7ffff475fcdb <_ZN4llvm2cl6Option11addArgumentEv+1067><br>
0x00007ffff475f93a <+138>: mov 0x48(%rsp),%rax<br>
0x00007ffff475f93f <+143>: xor %fs:0x28,%rax<br>
0x00007ffff475f948 <+152>: movb $0x1,0x38(%rbx)<br>
0x00007ffff475f94c <+156>: jne 0x7ffff475fcd6 <_ZN4llvm2cl6Option11addArgumentEv+1062><br>
0x00007ffff475f952 <+162>: add $0x58,%rsp<br>
0x00007ffff475f956 <+166>: pop %rbx<br>
0x00007ffff475f957 <+167>: pop %rbp<br>
0x00007ffff475f958 <+168>: pop %r12<br>
0x00007ffff475f95a <+170>: pop %r13<br>
0x00007ffff475f95c <+172>: pop %r14<br>
0x00007ffff475f95e <+174>: pop %r15<br>
<br>
We have a null pointer dereference here.<br>
<br>
(gdb) p $r12<br>
$1 = 0<br>
<br>
Here is that line of code <a href="https://github.com/llvm-mirror/llvm/blob/master/lib/Support/CommandLine.cpp#L123" rel="noreferrer" target="_blank">https://github.com/llvm-mirror/llvm/blob/master/lib/Support/CommandLine.cpp#L123</a><br>
<br>
Somehow ArgStr is a nullptr.<br>
<br>
I suggest to change ArgStr type to StringRef to fix my crash. Also, that will modernize code. I can provide a patch. Additionally, I can also change some other const char * types to StringRef where appropriate. Will such patch be accepted? Do I need to fill a ticket in bug tracker?<br>
<br>
--<br>
Eugene<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>