<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 23, 2017 at 6:40 PM, Andrew Kelley <span dir="ltr"><<a href="mailto:superjoe30@gmail.com" target="_blank">superjoe30@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Mon, Oct 23, 2017 at 9:30 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Oct 23, 2017 at 5:28 PM, Andrew Kelley <span dir="ltr"><<a href="mailto:superjoe30@gmail.com" target="_blank">superjoe30@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">For Zig we use LLD as a library. So for us it would be better to avoid global state such as SIGBUS (or any other signal handlers), instead returning an error from the link function when linking fails. If lld can encapsulate this signal handling and prevent the application using lld from getting the signal directly, instead carefully handling the signal in LLD itself and translating it into a proper error code or message, this would be reasonable.</div></blockquote><div><br></div></span><div>Signal handlers and signal masks are inherently process-wide, so there's no way to encapsulate them to lld functions. So my plan is to change the name of lld::{coff,elf}::link's `ExitEarly` parameter to `IsStandalone`, and we (not only call exit(2) but also) set a signal handler only when the argument is true. Since library users pass false to the parameter, it shouldn't change the behavior of lld for the library use case.</div></div></div></div></blockquote><div><br></div></span><div>This sounds good to me.</div><div><br></div><div>And then if an application wants to handle the SIGBUS correctly, it would have to register this signal handler to report the error?</div></div></div></div></blockquote><div><br></div><div>I could export a function that sets a signal handler as part of the library interface, but I'm reluctant to do that because you can do the same thing in a few lines of C code.</div><div><br></div><div>Can I ask you a question? I wonder if there's a reason to not call fork before calling lld's main function.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="m_1517697046084156886m_6367262219279998m_7150981526900970998m_3826056377170752387m_6493432152284616398m_8467861714384009563h5">On Mon, Oct 23, 2017 at 6:21 PM, Rui Ueyama 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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_1517697046084156886m_6367262219279998m_7150981526900970998m_3826056377170752387m_6493432152284616398m_8467861714384009563h5"><div dir="ltr">If your system does not support fallocate(2), we use ftruncate(2) to create an output file. fallocate(2) succeeds even if your disk have less space than the requested size, because it creates a sparse file. If you mmap such sparse file, you'll receive a SIGBUS when the disk actually becomes full.<div><br></div><div>So, lld can die suddenly with SIGBUS when your disk becomes full, and currently we are not doing anything about it. It's sometimes hard to notice that that was caused by the lack of disk space.</div><div><br></div><div>I wonder if we should print out a hint (e.g. "Bus error -- disk full?") when we receive a SIGBUS. Any opinions?</div></div>
<br></div></div><span>______________________________<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>
<br></span></blockquote></div><br></div></div>
</blockquote></span></div><br></div></div>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div></div>