<div dir="ltr">In x86 asm, cmpl is both signed and unsigned, it's the following jump that decides to work signed or not. In this case it's jl "jump if less" so it's signed (vs jb "jump if before" that is unsigned). But I digress.<div><br></div><div>I've recompiled ksh93 with debug, no stripped symbols and no optimizations (the binary is here: <a href="https://www.dropbox.com/s/brys628g40akruv/ksh93.gz?dl=0">https://www.dropbox.com/s/brys628g40akruv/ksh93.gz?dl=0</a>) and managed to figure out where that infinite loop is happening:</div><div><br></div><div><div>> ::stack</div><div>job_byjid+5()</div><div>job_alloc+0x62()</div><div>job_post+0x1a2()</div><div>_sh_fork+0x265()</div><div>sh_ntfork+0xa99()</div><div>sh_exec+0x2be8()</div><div>sh_subshell+0x982()</div><div>comsubst+0xbf0()</div><div>varsub+0x3f4()</div><div>copyto+0xa2a()</div><div>sh_mactrim+0x196()</div><div>nv_setlist+0x220()</div><div>sh_exec+0xdb7()</div><div>sh_eval+0x2b9()</div><div>sh_trap+0x29b()</div><div>ed_setup+0x7ac()</div><div>ed_viread+0xf6()</div><div>slowread+0x181()</div><div>sfrd+0x4da()</div><div>_sffilbuf+0x433()</div><div>sfreserve+0x566()</div><div>exfile+0x808()</div><div>sh_main+0xb38()</div><div>main+0x25()</div></div><div>> </div><div><br></div><div>Looking at ksh' sources, my understanding is that job_post is stuck in that else clause:</div><div><div>       else</div><div>       {</div><div>              /* create a new job */</div><div>              while((pw->p_job = job_alloc()) < 0)</div><div>                     job_wait((pid_t)1);</div><div>              pw->p_nxtjob = job.pwlist;</div><div>              pw->p_nxtproc = 0;</div><div>       }</div></div><div><br></div><div>Digging into the sources and stepping though the instructions of job_alloc and job_byjid it looks like ksh cannot allocate a job id as it believes they're all reserved. But so far, all this code is purely working on internal structures of ksh so a LX bug would have no impact.</div><div><br></div><div>I'll continue looking into this as time permits and I'll post an update if I find anything worth mentioning.</div><div><br></div><div>--</div><div>Ludovic</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 9, 2017 at 5:15 PM, Dan McDonald <span dir="ltr"><<a href="mailto:danmcd@omniti.com" target="_blank">danmcd@omniti.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On May 9, 2017, at 11:05 AM, Dan McDonald <<a href="mailto:danmcd@omniti.com">danmcd@omniti.com</a>> wrote:<br>
><br>
> And I've no good way to know what it's doing, as the illumos-native tools aren't giving me enough data.<br>
<br>
</span>ksh93 appears to be looping in something:<br>
<br>
mdb: target stopped at:<br>
0x42adf0:       movq   +0x350129(%rip),%rax     <0x77af20><br>
> ::step<br>
mdb: target stopped at:<br>
0x42adf7:       testq  %rax,%rax<br>
> ::step<br>
mdb: target stopped at:<br>
0x42adfa:       jne    +0xc     <0x42ae08><br>
> ::step<br>
mdb: target stopped at:<br>
0x42adfc:       jmp    +0x28    <0x42ae26><br>
> ::step<br>
mdb: target stopped at:<br>
0x42ae26:       addl   $0x1,%r14d<br>
> ::step<br>
mdb: target stopped at:<br>
0x42ae2a:       cmpl   0x10(%rsi),%r14d<br>
> ::step<br>
mdb: target stopped at:<br>
0x42ae2e:       jl     -0x40    <0x42adf0><br>
> ::step<br>
mdb: target stopped at:<br>
0x42adf0:       movq   +0x350129(%rip),%rax     <0x77af20><br>
> <rsi+0x10<br>
Usage: step [ over | out ] [SIG]<br>
> <rsi+0x10=P<br>
                0x7fffff0470f0<br>
> 0x7fffff0470f0/D<br>
0x7fffff0470f0: 2147483647<br>
> 0x7fffff0470f0/X<br>
0x7fffff0470f0: 7fffffff<br>
> <r14d/P<br>
mdb: failed to read data from target: no mapping for address<br>
0x761133e5:<br>
> <r14d=P<br>
                0x761133e5<br>
><br>
<br>
Something that never seems to exit.  Hmmm... I'm guessing r14d will never be less than 0x7ffffff with a signed compare (cmpl is signed,right?).<br>
<br>
NO idea how this happened.  :-/<br>
<div class="HOEnZb"><div class="h5"><br>
Dan<br>
<br>
______________________________<wbr>_________________<br>
OmniOS-discuss mailing list<br>
<a href="mailto:OmniOS-discuss@lists.omniti.com">OmniOS-discuss@lists.omniti.<wbr>com</a><br>
<a href="http://lists.omniti.com/mailman/listinfo/omnios-discuss" rel="noreferrer" target="_blank">http://lists.omniti.com/<wbr>mailman/listinfo/omnios-<wbr>discuss</a><br>
</div></div></blockquote></div><br></div>