<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hello, </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">In my organization, we've been using ASAN and most of UBSAN checks in the default developers mode with a big success. I'd like to enable a few remaining UBSAN checks too but noticed that they cause significant (up to
 2x in some cases) binary size overhead (mostly .rodata and .data). These checks are: null, function, vptr, object-size.  </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Inspecting .rodata, it looks like there are a lot of strings with file and type names. <span style="font-size: 12pt;">I tried to use `<span>-fsanitize-undefined-strip-path-components=-1` from [1]. It appeared to have
 no effect when `-fsanitize=function` and `-fsanitize=address` are used at the same time (filed bug [2]). Disabling `-fsanitize=function` and using  <span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">`</span><span style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">-fsanitize-undefined-strip-path-components=-1`
 reduces the size overhead to 1.4x. </span></span></span>This is quite already significant.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I've considered -fsanitize=trap, it causes very little size overhead but it in some cases is hard to work with. </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I noticed that [3] added minimal runtime for UBSAN. It works similar to `<span>-fsanitize-trap`, but prints a bit more informative message, which would suffice. Out of the box, I didn't notice a measurable binary size
 reduction as mentioned on that change, but if used with `<span>-fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--print-gc-sections`, the size bloat of .rodata and .data is almost eliminated. Note, in this case, those flags don't help without `-<span>fsanitize-minimal-runtime`.</span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span><br>
</span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span>Unfortunately, there is a restriction in the driver preventing this minimal UBSAN runtime to be used when ASAN is also enabled. I don't completely understand the reasons for having this restriction.
 When I removed that restriction, both ASAN and UBSAN still seem functioning in my tests. </span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span><br>
</span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span>I'd like to allow using minimal UBSAN runtime with ASAN. Are there reasons against it? I'd volunteer to do the work here.</span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span><br>
</span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span>Also, v<span>ptr UBSAN check is disallowed when minimal UBSAN runtime is used. Would someone clarify why?</span></span></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span><span><br>
</span></span></span></span></p>
<p style="margin-top:0;margin-bottom:0">-- Igor</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<ol style="margin-bottom: 0px; margin-top: 0px;">
<li><a href="https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#additional-configuration" class="OWAAutoLink" id="LPlnk224361" previewremoved="true">https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#additional-configuration</a></li><li><span style="font-size: 12pt;"></span><a href="https://bugs.llvm.org/show_bug.cgi?id=39347" class="OWAAutoLink" id="LPlnk663307" previewremoved="true">https://bugs.llvm.org/show_bug.cgi?id=39347</a></li><li><a href="https://reviews.llvm.org/D36810" class="OWAAutoLink" id="LPlnk471537" previewremoved="true">https://reviews.llvm.org/D36810</a>
<div id="LPBorder_GT_15399093196730.2558932204692528" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15399093196720.2638047386862139" role="presentation" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_15399093196720.6118055161042004" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_15399093196720.4167337012904666"></div>
<div id="LPTitle_15399093196720.6843494300108914" style="top: 0px; color: rgb(93, 178, 255); font-weight: 400; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_15399093196720.8406941018844281" href="https://reviews.llvm.org/D36810" target="_blank" style="text-decoration: none;">D36810 Minimal runtime for UBSan. - LLVM</a></div>
<div id="LPMetadata_15399093196720.14031362546793513" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: 400; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
reviews.llvm.org</div>
<div id="LPDescription_15399093196730.44365991749594613" style="display: block; color: rgb(102, 102, 102); font-weight: 400; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
Not worried about that. If it allocates or prints too much, we can add in a custom allocator or printing strategy. If it requires too much metadata to be inserted into user programs, we can devise a new, smaller encoding for the metadata.</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
<br>
</li></ol>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><a href="https://reviews.llvm.org/D36810" class="OWAAutoLink" id="LPlnk510871" previewremoved="true">https://reviews.llvm.org/D36810</a></p>
<div id="LPBorder_GT_15399077390180.4556167263663371" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15399077390150.3628391387566361" role="presentation" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_15399077390170.9356204513907331" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_15399077390170.15590685974231056"><a id="LPlnk536017" class="ms-Icon--x ms-icon-font-size-14 OWAAutoLink" style="font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-weight: normal; position: relative; cursor: pointer; padding: 8px; float: right; color: rgb(102, 102, 102); background-color: rgb(238, 247, 255); user-select: none; margin-left: 10px;" previewremoved="true"></a></div>
<div id="LPTitle_15399077390170.8512445827367043" style="top: 0px; color: rgb(93, 178, 255); font-weight: 400; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_15399077390170.8827673418982735" href="https://reviews.llvm.org/D36810" target="_blank" style="text-decoration: none;">D36810 Minimal runtime for UBSan. - LLVM</a></div>
<div id="LPMetadata_15399077390170.34360392979186627" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: 400; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
reviews.llvm.org</div>
<div id="LPDescription_15399077390180.6919949750220125" style="display: block; color: rgb(102, 102, 102); font-weight: 400; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
Not worried about that. If it allocates or prints too much, we can add in a custom allocator or printing strategy. If it requires too much metadata to be inserted into user programs, we can devise a new, smaller encoding for the metadata.</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
<p></p>
</div>
</body>
</html>