-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
697 lines (333 loc) · 19.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Confessions of a Wall Street Programmer</title>
<meta name="author" content="Bill Torpey">
<meta name="description" content="I’ve recently been dipping my toes in the very deep water that is “undefined behavior” in C and C++, and the more I learn about it, the scarier it …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://btorpey.github.io">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<link href="/atom.xml" rel="alternate" title="Confessions of a Wall Street Programmer" type="application/atom+xml">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="./javascripts/libs/jquery.min.js"%3E%3C/script%3E'))</script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-61420123-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css">
</head>
<body >
<header role="banner"><hgroup>
<h1><a href="/">Confessions of a Wall Street Programmer</a></h1>
<h2>practical ideas (and perhaps some uncommon knowledge) on software architecture, design, construction and testing</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="http://google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:btorpey.github.io" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<header>
<h1 class="entry-title"><a href="/blog/2023/02/09/danger/">Danger, Will Robinson!</a></h1>
<p class="meta">
<time datetime="2023-02-09T00:00:00-05:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="right" src="/images/robot1.jpg" width="183" height="200" /></p>
<p>I’ve recently been dipping my toes in the very deep water that is “undefined behavior” in C and C++, and the more I learn about it, the scarier it is. </p>
<p>This was inspired by a rather tricky crash that I needed to track down as part of moving the code-base at my day job to more modern compilers and language standards.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2023/02/09/danger/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2021/02/13/moving-from-centos-to-ubuntu/">Moving from CentOS to Ubuntu</a></h1>
<p class="meta">
<time datetime="2021-02-13T00:00:00-05:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="left" src="/images/twins.jpg" width="234" height="288" /></p>
<p>I recently needed to build a Linux development system from scratch, and while I was at it I decided to provide dual-boot capability between CentOS and Ubuntu. </p>
<p>Having used RH/CentOS pretty much exclusively since moving from Unix (Solaris) to Linux many years back, I learned that even though CentOS and Ubuntu are both Linux, they are very different in ways both large and small. I shaved a few yaks along the way, and made lots of notes – hopefully they’ll help if you’re thinking about making a similar transition.</p>
<p>With <a href="https://blog.centos.org/2020/12/future-is-centos-stream/">recent events</a> in CentOS-land this has become even more relevant — read on to see how you can easily move back and forth between CentOS and Ubuntu.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2021/02/13/moving-from-centos-to-ubuntu/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2019/07/14/memory-checking/">Memory Checking</a></h1>
<p class="meta">
<time datetime="2019-07-14T00:00:00-04:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="right" src="/images/memory-testing.jpg" /></p>
<p>At my day job, I spend a fair amount of time working on software reliability. One way to make software more reliable is to use memory-checking tools like valgrind’s <a href="http://www.valgrind.org/info/tools.html#memcheck">memcheck</a> and clang’s <a href="https://github.com/google/sanitizers/wiki/AddressSanitizer">AddressSanitizer</a> to detect memory errors at runtime. </p>
<p>But these tools are typically not appropriate to use all the time – valgrind causes programs to run much more slowly than normal, and AddressSanitizer needs a special instrumented build of the code to work properly. So neither tool is typically well-suited for production code.</p>
<p>But there’s another memory-checking tool that is “always on”. That tool is plain old <code>malloc</code>, and it is the subject of this article.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2019/07/14/memory-checking/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2017/09/17/lotso-static/">Lots o’ static</a></h1>
<p class="meta">
<time datetime="2017-09-17T00:00:00-04:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="left" src="/images/static-cat.jpg" width="250" height="188" /></p>
<ul id="markdown-toc">
<li><a href="#openmama">OpenMAMA</a></li>
<li><a href="#following-along">Following along</a></li>
<li><a href="#false-positives">False Positives</a></li>
<li><a href="#style-vs-substance">Style vs. Substance</a></li>
<li><a href="#dead-code">Dead Code</a></li>
<li><a href="#buffer-overflow">Buffer Overflow</a></li>
<li><a href="#null-pointer-dereference">NULL pointer dereference</a></li>
<li><a href="#leaks">Leaks</a></li>
<li><a href="#pointer-errors">Pointer Errors</a></li>
<li><a href="#but-wait-theres-more">But Wait, There’s More!</a></li>
<li><a href="#conclusion">Conclusion</a></li>
<li><a href="#footnotes">Footnotes</a></li>
</ul>
<p>I’ve written before about <a href="/blog/categories/static-analysis/">static analysis</a>, but in those earlier posts I wasn’t able to give specific examples of real-world code where static analysis is able to discover latent errors.</p>
<p>In the earlier articles I used a synthetic code-base <a href="https://github.com/regehr/itc-benchmarks">from ITC Research</a> to test clang, cppcheck and PVS-Studio. I also ran all three tools on the code-bases that I’m responsible for maintaining at my “day job”, but I wasn’t able to share detailed results from that analysis, given that the code is not public.</p>
<p>In this article, I want to expand the discussion of static analysis by diving into a real-world, open-source code base that I’ve been working with lately, with specific examples of the kinds of problems static analysis can expose.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2017/09/17/lotso-static/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2017/05/10/join/">We Don’t Need No Stinkin’ Databases</a></h1>
<p class="meta">
<time datetime="2017-05-10T00:00:00-04:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="right" src="/images/Gold_Hat_portrayed_by_Alfonso_Bedoya.jpg" width="220" height="162" /></p>
<p>I’ve been working on performance analysis recently, and a large part of that is scraping log files to capture interesting events and chart them.</p>
<p>I’m continually surprised by the things that you can do using plain old bash and his friends, but this latest one took the cake for me.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2017/05/10/join/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2016/11/12/even-mo-static/">Even Mo’ Static</a></h1>
<p class="meta">
<time datetime="2016-11-12T00:00:00-05:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="left" src="/images/vandergraaf.jpg" width="139" height="122" /></p>
<ul id="markdown-toc">
<li><a href="#tldr">TL;DR</a></li>
<li><a href="#methodology">Methodology</a> <ul>
<li><a href="#itc-test-suite">ITC test suite</a> <ul>
<li><a href="#caveats">Caveats</a> <ul>
<li><a href="#specific-issues">Specific issues</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="#real-world-test-results">Real-world test results</a></li>
<li><a href="#false-positives">False positives</a></li>
<li><a href="#conclusion">Conclusion</a></li>
<li><a href="#appendix-helper-scripts-and-sample-results">Appendix: Helper scripts and sample results</a></li>
<li><a href="#appendix-detailed-test-results">Appendix: Detailed test results</a></li>
</ul>
<p>A while back I wrote <a href="/blog/2016/04/07/mo-static/">an article</a> that compared cppcheck and clang’s static analyzers (clang-check and clang-tidy). The folks who make <a href="http://www.viva64.com/en/pvs-studio/">PVS-Studio</a> (the guys with the unicorn mascot that you’ve probably been seeing a lot of lately) saw the article, and suggested that I take a look at their Linux port, which was then in beta test, and write about it.</p>
<p>So I did. Read on for an overview of PVS-Studio, and how it compared to <a href="http://cppcheck.sourceforge.net/">cppcheck</a>.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2016/11/12/even-mo-static/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2016/10/13/custom-tailor/">Custom-Tailored Configuration</a></h1>
<p class="meta">
<time datetime="2016-10-13T00:00:00-04:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="right" src="/images/customtailor.jpg" /></p>
<p>As developers, we seem to take a special delight in personalizing the virtual worlds in which we work – from color palettes to keyboards, fonts, macros, you name it. “Off-the-rack” is never good enough, we want Saville Row tailoring for our environments.</p>
<p>And a lot of the tools we use support and encourage that customization, giving us control over every little option.</p>
<p>But not every tool we use does so – read on to learn a very simple trick to how to take control even when your tool doesn’t make that easy.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2016/10/13/custom-tailor/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2016/04/07/mo-static/">Mo’ Static</a></h1>
<p class="meta">
<time datetime="2016-04-07T00:00:00-04:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="left" src="/images/nye-static.jpg" width="240" height="180" /></p>
<ul id="markdown-toc">
<li><a href="#testing-static-analysis-tools">Testing Static Analysis Tools</a></li>
<li><a href="#can-i-haz-teh-codez">Can I haz teh codez?</a></li>
<li><a href="#creating-a-compilation-database">Creating a compilation database</a></li>
<li><a href="#establishing-a-baseline">Establishing a baseline</a></li>
<li><a href="#using-clangs-analysis-tools">Using clang’s analysis tools</a> <ul>
<li><a href="#analyzing-the-results">Analyzing the results</a></li>
</ul>
</li>
<li><a href="#running-clang-analysis-again">Running clang analysis (again)</a></li>
<li><a href="#using-cppcheck">Using cppcheck</a> <ul>
<li><a href="#installing-cppchceck">Installing cppchceck</a> <ul>
<li><a href="#verifying-the-installation">Verifying the installation</a></li>
</ul>
</li>
<li><a href="#running-cppcheck">Running cppcheck</a></li>
<li><a href="#analyzing-the-results-1">Analyzing the results</a></li>
</ul>
</li>
<li><a href="#comparing-clang-and-cppcheck">Comparing clang and cppcheck</a></li>
<li><a href="#conclusions">Conclusions</a></li>
<li><a href="#acknowledgements">Acknowledgements</a></li>
<li><a href="#references">References</a></li>
</ul>
<p>In my day job, one of my main focuses is software reliability and correctness, so it makes sense that I would be a big fan of static analysis.</p>
<p>I’ve written previously about the <a href="/blog/2015/04/27/static-analysis-with-clang/">static analysis provided by clang</a>. Today, I want to take a bit of a “deep-dive” into the whole subject by putting both clang and <a href="http://cppcheck.sourceforge.net/">cppcheck</a> through their paces, using them to analyze a benchmark suite designed to exercise static analysis tools. In the course of doing that, I’ll also provide some helper scripts that make working with the tools easier. </p>
</div>
<footer>
<a rel="full-article" href="/blog/2016/04/07/mo-static/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2015/10/13/remote-scripting-with-bash-and-ssh/">Remote Scripting with bash and ssh</a></h1>
<p class="meta">
<time datetime="2015-10-13T00:00:00-04:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="right" src="/images/multimonitors.jpg" width="370" height="245" /></p>
<p>Nowadays it’s pretty common for applications to be distributed across multiple
machines, which can be good for scalability and resilience.</p>
<p>But it does mean that we have more machines to monitor – sometimes a LOT more!</p>
<p>Read on for a handy tip that will let you do a lot of those tasks from any old
session (and maybe lose some of those screens)!</p>
</div>
<footer>
<a rel="full-article" href="/blog/2015/10/13/remote-scripting-with-bash-and-ssh/">…</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2015/04/27/static-analysis-with-clang/">Static Analysis with clang</a></h1>
<p class="meta">
<time datetime="2015-04-27T00:00:00-04:00" pubdate data-updated="true"></time>
</p>
</header>
<div class="entry-content"><p><img class="left" src="/images/coil3.jpg" width="195" height="281" /></p>
<p>I keep singing the praises of clang, and with good reason – the <a href="http://clang.llvm.org/">clang project</a> has been advancing the state of C/C++ compiler technology on Linux and OS X for quite a while now. </p>
<p>The modular design of the compiler has also enabled the creation of a set of ancillary tools, including run-time “sanitizers” (which I <a href="http://btorpey.github.io/blog/2014/03/27/using-clangs-address-sanitizer/">wrote about earlier</a>), as well as pretty-printers, and a tool to automatically upgrade code to C++11. </p>
<p>Today I want to talk about clang’s static analysis engine, which can do a deep-dive on your code and find problems that are hard for a human to detect, but that are amenable to a brute-force approach that models the run-time behavior of a piece of code, but at compile-time.</p>
</div>
<footer>
<a rel="full-article" href="/blog/2015/04/27/static-analysis-with-clang/">…</a>
</footer>
</article>
<div class="pagination">
<a class="prev" href="/blog/page/2/">← Older</a>
<a href="/blog/archives">Blog Archives</a>
</div>
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/blog/2023/02/09/danger/">Danger, Will Robinson!</a>
</li>
<li class="post">
<a href="/blog/2021/02/13/moving-from-centos-to-ubuntu/">Moving from CentOS to Ubuntu</a>
</li>
<li class="post">
<a href="/blog/2019/07/14/memory-checking/">Memory Checking</a>
</li>
<li class="post">
<a href="/blog/2017/09/17/lotso-static/">Lots o’ static</a>
</li>
<li class="post">
<a href="/blog/2017/05/10/join/">We Don’t Need No Stinkin’ Databases</a>
</li>
</ul>
</section>
<section>
<a href="/about/index.html"><h1>About…</h1></a>
</section>
</aside>
</div>
</div>
<footer role="contentinfo"><p>
Copyright © 2023 - Bill Torpey. All Rights Reserved.
<br>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/4.0/80x15.png" /></a> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/deed.en_US">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
<br>
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>
</p>
</footer>
<script type="text/javascript">
var disqus_shortname = 'wallstprog';
var disqus_script = 'count.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = '//platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
</body>
</html>