<div dir="ltr"><div><div><div>Hello.</div><div>This might be a trivial question, but is it correct if the signal handler aborts the program?</div><div>For example:</div><div><br></div><div>  int *normal = ADDRESS1;</div><div>  volatile int* ptr = ADDRESS2;</div><div>  int k = *ptr; // segfaults, and the signal handler calls abort()</div><div>  int value = *normal; // this may be UB(undefined behavior).</div><div><br></div><div>Let's assume that normal is dereferenceable if ptr1 does not raise SEGSEGV, but accessing normal raises UB if ptr1 raises SEGSEGV.</div><div>Before reordering is done, there's no UB because the program will always abort if UB could happen, but UB may happen after they are reordered.</div><div><br></div></div></div><div>Best Regards,</div><div>Juneyoung Lee</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 21, 2017 at 4:50 AM, Krzysztof Parzyszek via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 12/20/2017 1:37 PM, Sanjoy Das wrote:><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Fwiw, I was under the impression that regular loads could *not* be<br>
reordered with volatile loads since we could have e.g.:<br>
<br>
   int *normal = &global_variable;<br>
   volatile int* ptr = 0;<br>
   int k = *ptr; // segfaults, and the signal handler writes to *normal<br>
   int value = *normal;<br>
<br>
and that we'd have to treat volatile loads and stores essentially as<br>
calls to unknown functions.<br>
</blockquote>
<br></span>
For this to work, "normal" should be volatile as well.<br>
<br>
-Krzysztof<span class="im HOEnZb"><br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation<br></span><div class="HOEnZb"><div class="h5">
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><br></div><font size="1">Juneyoung Lee</font><div><font size="1">Software Foundation Lab, Seoul National University</font></div></div></div>
</div>