<div dir="ltr">1. __sanitizer_symbolize_pc is present<div>2. Symbolizer support is missing (either llvm-symbolizer is not in your path or in ASAN_OPTIONS=symoblizer_path, the internal symbolizer fails, or something else goes wrong) - verified and re-ran this.</div><div><br></div><div>Do you see any outputs of NEW_FUNC[]? Is just the apifunc() line missing? - I do see other functions and its just the apifunc that is missing along with any subsequent functions called by apifunc. <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 12:15 PM Mitch Phillips <<a href="mailto:mitchp@google.com" target="_blank">mitchp@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">> I am wondering if there is a reason I am not seeing the function in the NEW_FUNC[x/xxx]: log lines. <br><div><br></div><div>I can think of a couple of reasons why this might be happening.</div><div><ol><li>The function __sanitizer_symbolize_pc is missing in your binary (you can check easily with `nm <binary> | grep sanitizer_symbolize_pc`)<br></li><li>Symbolizer support is missing (either llvm-symbolizer is not in your path or in ASAN_OPTIONS=symoblizer_path, the internal symbolizer fails, or something else goes wrong).</li></ol><div>Do you see any outputs of NEW_FUNC[]? Is just the apifunc() line missing?</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 10:02 AM Shikhar Singh <<a href="mailto:shikhar.singh8990@gmail.com" target="_blank">shikhar.singh8990@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Mitch,<div><br></div><div>Thank you for the response. </div><div><br></div><div>1. You don't need to build the library with `-fsanitize-coverage=...`, using `-fsanitize=fuzzer-no-link,address` should be sufficient. - Acknowledged<br></div><div>2. (although you can actually build object files/shared libraries with -fsanitize=fuzzer, and the libFuzzer main won't be linked, if this makes your build process easier). - with just the <b>fuzzer </b>flag, it looks for the LLVMFuzzerTestOneInput.<br></div><div>3. I've run a quick grep and can't find anything that would match "apifunc() resp=0x7ff38f83ac20 uninitialized, fixing it." in libFuzzer (or compiler-rt). What version of compiler-rt/llvm/clang are you trying this with? - This was an oversight on my part, it was a log dump from the library and somehow I mistook it be from libfuzzer. (I am using Clang 9 btw).<br></div><div>4. Have you tried <a href="https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md#visualizing-coverage" target="_blank">visualising the coverage</a> that the fuzz target is generating? It may give you an insight as to why your desired function under test isn't being hit. - Yes, I am using lcov for coverage and do see the relevant methods being exercised. </div><div><br></div><div>I am wondering if there is a reason I am not seeing the function in the NEW_FUNC[x/xxx]: log lines. </div><div>To iterate my steps - </div><div><br></div><div>First I build the library with fuzzer-no-link,address flags. I <b>don't</b> compile the fuzz_target (the file containing the LLVMFuzzerTestOneInput function) with the library.</div><div>Then I build the fuzz target and link it with the library.</div><div><br></div><div><b>clang++ -g -O1 -fsanitize=fuzzer,address -Iinclude -Ibuild/include ..... fuzztarget.c -Lbuild/lib -llib1 -llib2</b></div><div>and then finally <b>./a.out -detect_leaks=0 corpus/</b></div><div><br></div><div>I appreciate your help with this.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 11:38 AM Mitch Phillips <<a href="mailto:mitchp@google.com" target="_blank">mitchp@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Shikhar,<div><br></div><div>You don't need to build the library with `-fsanitize-coverage=...`, using `-fsanitize=fuzzer-no-link,address` should be sufficient. Without being able to inspect, it seems like you're building the library/fuzz target in a sane manner (although you can actually build object files/shared libraries with -fsanitize=fuzzer, and the libFuzzer main won't be linked, if this makes your build process easier).</div><div><br></div><div>I've run a quick grep and can't find anything that would match "apifunc() resp=0x7ff38f83ac20 uninitialized, fixing it." in libFuzzer (or compiler-rt). What version of compiler-rt/llvm/clang are you trying this with?</div><div><br></div><div>Have you tried <a href="https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md#visualizing-coverage" target="_blank">visualising the coverage</a> that the fuzz target is generating? It may give you an insight as to why your desired function under test isn't being hit.</div><div><br></div><div>- Mitch</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 9:16 AM Shikhar Singh via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="margin:0px;padding:0px 0px 20px;width:1644.25px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><div><div id="gmail-m_-3372765021518797641gmail-m_176991245015927004gmail-m_2936464071635911864gmail-m_-7485298340128879504gmail-m_5872114806333856756gmail-:1hb" style="font-size:0.875rem;direction:ltr;margin:8px 0px 0px;padding:0px"><div id="gmail-m_-3372765021518797641gmail-m_176991245015927004gmail-m_2936464071635911864gmail-m_-7485298340128879504gmail-m_5872114806333856756gmail-:ni" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif"><div dir="ltr"><div style="padding:20px 0px 0px;font-size:0.875rem"><span style="font-size:small">I am working of using libfuzzer and asan to test out a third-party library.</span><br><span style="font-size:small">As demonstrated in the tutorial, I wrote a fuzz target to fuzz a specific function in the library. The fuzz target is then linked to the library and compiles clean and I do see some tests generated by the fuzzer. However, I have some questions regarding the "right" way to go about doing this. I have doubts that the fuzzer taking coverage feedback from the fuzztarget and not the library functions (not sure though). Suppose the function in the library being tested is called -</span><span style="font-size:small"> </span><b style="font-size:small">apifunc()</b><span style="font-size:small">. The libfuzzer log has a line which says - </span><b style="font-size:small">apifunc() resp=0x7ff38f83ac20 uninitialized, fixing it</b><span style="font-size:small">. I am not sure what this means. Also, I can see that the apifunc is called and it runs but it does not show up in the </span><span style="font-size:small"> </span><b style="font-size:small">NEW_FUNC[x/xxx]: </b><span style="font-size:small">log lines in the libfuzzer output. </span><table cellpadding="0" style="border-collapse:collapse;margin-top:0px;width:auto;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:0.875rem;letter-spacing:0.2px;display:block"></table></div><div><div id="gmail-m_-3372765021518797641gmail-m_176991245015927004gmail-m_2936464071635911864gmail-m_-7485298340128879504gmail-m_5872114806333856756gmail-m_-4875253864227967866gmail-:14q" style="font-size:0.875rem;direction:ltr;margin:8px 0px 0px;padding:0px"><div id="gmail-m_-3372765021518797641gmail-m_176991245015927004gmail-m_2936464071635911864gmail-m_-7485298340128879504gmail-m_5872114806333856756gmail-m_-4875253864227967866gmail-:13i" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5"><div dir="ltr"><div><br></div><div>To enable fuzzing. First I build the library with the following libfuzzer flags.</div><div><b>-fsanitize=fuzzer-no-link,address -fsanitize-coverage=edge,indirect-calls</b><br></div><div>I also had to make a blacklist to avoid some buffer overflow and use after free error during this build.<br></div><div><br></div><div>After this, I link the fuzz target with the library and use the following libfuzzer options.</div><div><b>-fsanitize=fuzzer,address</b><br></div><div><b><br></b></div><div>I am looking for some guidance and feedback if this is the right way to go about fuzzing the library and the meaning of <b>uninitialized fixing it </b>line in the log.</div></div></div></div></div></div></div></div></div></div>-- <br><div dir="ltr"><div dir="ltr"><div>Live long and Prosper,</div><div><br></div><div>Shikhar Singh</div></div></div></div>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Live long and Prosper,</div><div><br></div><div>Shikhar Singh</div></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Live long and Prosper,</div><div><br></div><div>Shikhar Singh</div></div></div>