This website uses cookies to ensure you get the best experience on our website. Learn more

Curiously Recurring C Bugs at Facebook

x

CppCon 2017: Louis Brandy “Curiously Recurring C++ Bugs at Facebook”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

I've spent the last few years watching Facebook's C++ codebase grow by several orders of magnitude. Despite constantly improving abstractions, constantly improving tooling, frequent internal courses, and ongoing internal discussion, there are bug-patterns we simply cannot stop from being reintroduced into our code. My hope is to show some of the most common (and infamous) bugs in our history, and the surprising complexity that arises in some apparently simple situations.

This talk serves the dual purpose of educating the intermediate (and perhaps the occasional advanced) C++ programmer about some really nasty common pitfalls, as well as serves as a plea to experts to help further improve the language, libraries, and best practices to help educate and eradicate some of these problematic patterns.

Louis Brandy: Engineering Director, Facebook

My team is responsible for the overall health of the Facebook C++ codebase, both the tools and the libraries. We work on: compilers, static/dynamic analysis, linters, large scale changes, and the core libraries.

Videos Filmed & Edited by Bash Films:

Curiously Recurring C++ Bugs at Facebook

I've spent the last few years watching Facebook's C++ codebase grow by several orders of magnitude. Despite constantly improving abstractions, constantly improving tooling, frequent internal courses, and ongoing internal discussion, there are bug-patterns we simply cannot stop from being reintroduced into our code. My hope is to show some of the most common (and infamous) bugs in our history, and the surprising complexity that arises in some apparently simple situations.

This talk serves the dual purpose of educating the intermediate (and perhaps the occasional advanced) C++ programmer about some really nasty common pitfalls, as well as serves as a plea to experts to help further improve the language, libraries, and best practices to help educate and eradicate some of these problematic patterns.

EVENT:

CppCon 2017

SPEAKER:

Louis Brandy: Engineering Director, Facebook

PERMISSIONS:

CppCon Organizer provided Coding Tech with the permission to republish this video.

Additional material for C++ learners:
Murach's C++ Programming
C++ in One Hour a Day, Sams Teach Yourself (8th Edition)
A Tour of C++ (2nd Edition) (C++ In-Depth Series)
C# Programming Illustrated Guide For Beginners & Intermediates: The Future Is Here! Learning By Doing Approach
x

CppCon 2017 Curiously Recurring C++ Bugs at Facebook

Curiously Recurring Template Pattern

CRTP is a means to get compile-time polymorphism in C++. Join us as we look at how it works along with a a discussion of complete vs incomplete types
x

CppCon 2016: Nicholas Ormrod “The strange details of std::string at Facebook"



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

Standard strings are slowing you down. Strings are everywhere. Changing the performance of std::string has a measurable impact on the speed of real-world C++ programs. But how can you make strings better? In this talk, we'll explore how Facebook optimizes strings, especially with our open-source std::string replacement, fbstring. We'll dive into implementation tradeoffs, especially the storage of data in the struct; examine which standard rules can and cannot be flouted, such as copy-on-write semantics; and share some of the things we've learned along the way, like how hard it is to abolish the null-terminator. War stories will be provided.

Nicholas Ormrod
Software Engineer, Facebook
Nicholas is a developer efficiency engineer at Facebook. If he talks too much, disable him with a well-placed nerd snipe.

Videos Filmed & Edited by Bash Films:

CppCon 2017: Kenny Yu “End-to-end Deadlock Debugging Tools at Facebook”

Presentation Slides, PDFs, Source Code and other presenter materials are available at:

Facebook has developed tooling to help quickly find and debug several classes of concurrency bugs in Facebook's large C++ codebase. In this talk, we will focus specifically on deadlocks and the tools we use to detect and prevent them. We will explore the various tools we use — some open source tools we have deployed and some we have developed — and how they work by walking through several examples of real-world bugs found by these tools in Facebook's large production systems.

Topics include:
* How we deploy and utilize ThreadSanitizer on Facebook's large codebase
* Linux eBPF tools to detect potential deadlocks on running binaries
* gdb extensions to examine mutex internals to detect deadlocks
* folly::Synchronized and other libraries that make it more difficult to introduce concurrency bugs

Kenny Yu: Facebook, Software Engineer

Kenny Yu is a software engineer at Facebook. In his time there, he has focused on improving testing and developer experience for engineers at Facebook, working on things such as debugging tools and concurrency bug-finders. He currently works on Facebook's cluster manager and container deployment platform.

Videos Filmed & Edited by Bash Films:
x

The Curiously Recurring Pattern of Coupled Types - Adi Shavit and Björn Fahller

Why can pointers be subtracted but not added?

What do raw C pointers, STL iterators, std::chrono types, and 2D/3D geometric primitives have in common?

In this talk we will present some curiously coupled data types that frequently occur in your programs, together forming notions that you are already intuitively familiar with. We will shine a light on the mathematical notion of Affine Spaces, and how they guide stronger design. We will review the properties of affine spaces and show how they improve program semantics, stronger type safety and compile time enforcement of these semantics.

By showing motivational examples, we will introduce you to the mathematical notion of affine spaces. The main focus will then be on how affine space types and their well defined semantics shape expressive APIs.

We will give examples and guidelines for creating your own affine types. Although the examples in the talk will use C++, the general concepts are applicable to other strongly typed programming languages.



Don't forget to check out Adi Shavit's and Björn Fahller's next talks at this year's NDC Techtown:



Check out more of our talks in the following links!

NDC Conferences

Pacific++ 2017: Jason Turner "Rethinking Exceptions"

Website:
Resources:
Twitter:

Abstract:
Rethinking Exceptions

About the speaker:
Jason is an independent C++ developer, trainer and speaker; host of C++Weekly, a weekly video tutorial on C++ ; co-host of CppCast, the only podcast for C++ developers by C++ developers; co-creator and maintainer of the embedded scripting language for C++ ChaiScript, an easy to use embedded scripting language for C++; and author and curator of the forkable coding standards document cppbestpractices.com. He has also published two C++ video series with O'Reilly Media. While in New Zealand he's hoping for some suggestions for which local micro-brewery beers to try and wondering if his four-legged coworker will be getting enough running time without him.

C++Now 2018: Daniel Dilts “Avoiding Virtual Call in CRTP”



Lightning Talk

Presentation Slides, PDFs, Source Code and other presenter materials are available at:

Videos Filmed & Edited by Bash Films:

Adi Shavit & Björn Fahller: The Curiously Recurring Pattern of Coupled Types

The C++ Distributed Meetup 0x03: Malmö C++ (Malmö) & Core C++ (Mevasseret Ziyyon) & SwedenCpp (Stockholm)
StockholmCpp, 0x10 October 2018

Slides:

See the whole C++ Distributed Meetup 0x03 here:
x

CppCon 2018: Adi Shavit “What Bug Hunting Taught Me About Hunting Bugs”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

Lightning Talk

Videos Filmed & Edited by Bash Films:

How to Adopt Modern C++17 into Your C++ Code : Build 2018

Just how different is Modern C++ from legacy C++? Is my codebase ready for C++17? Do I need a full rewrite of my app to modernize my code? If you're looking for answers to some of these questions, join us for a session on how to effectively leverage modern C++17 features in your existing C++ projects; and no, you don't need to rewrite your app.
x

How to Fix Segmentation Faults

This tutorial uses an example to demonstrate how to fix and avoid segmentation faults in a C/C++ application.

► Website:
► Facebook:

CppCon 2017: Scott Schurr “Type Punning in C++17: Avoiding Pun-defined Behavior”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

Type punning, treating a type as though it is a different type, has a long and sordid history in C and C++. But, as much as we'd like to deny its existence, it plays an important role in efficient low-level code. If you've ever written a program that examines the individual bits of a pointer or of a floating point number, then you've done type punning.

Given its long legacy, some of the techniques for type punning that were appropriate, even encouraged, earlier in history now live in the realm of undefined behavior. We'll identify which techniques are now proscribed and postulate why. We'll also explore ways to do type punning in C++17 that sidestep undefined behavior and are hopefully as efficient as the older techniques.

In this session we will look at:
o Common (and some uncommon) motivations for type punning.
o Techniques for type punning, both good and bad, all ugly.
o Related topics (like type conversions and std::launder()) with an eye toward unspecified and undefined behavior.

Scott Schurr: Ripple, Senior Software Engineer

If you ask his children, they will tell you that Scott has been writing software since dinosaurs roamed the earth. In 1996 Scott learned C++ by working through the exercises in Stroustrup's TC++PL 2nd edition and he has never looked back. Scott is currently working at Ripple Labs developing open source crypto-financial software. When he's not writing code Scott plays the Chapman Stick, sings rock and roll, and spends time with his lovely wife.

Videos Filmed & Edited by Bash Films:

CppCon 2017: Ben Deane & Jason Turner “constexpr ALL the Things!”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

constexpr: in C++11, a curiosity; in C++14, viable for more uses; now with added power, in C++17 will it become an important tool in the programmer's toolkit?

In this talk we will examine the possibilities and power of constexpr and explore what can (and what should) be done at compile-time with C++17. We'll present techniques for building constexpr data structures and algorithms, and look at what the standard provides and where it can improve. We'll also explore constexpr use of user defined literals for expressive compile-time abstractions.

Compile-time computation offers perhaps the ultimate zero-cost abstraction, and this talk attempts to gauge the power available with C++17 constexpr.

Ben Deane: Principal Software Engineer, Blizzard Entertainment

Ben has been writing games for almost 20 years, and in C++ for most of that. He is currently a Principal Engineer at Blizzard Entertainment where he works on the Battle.net team. He's always looking for useful new techniques in C++, and he likes functional programming.

Jason Turner: Developer, Trainer, Speaker

Host of C++Weekly Co-host of CppCast Co-creator and maintainer of the embedded scripting language for C++, ChaiScript and author and curator of the forkable coding standards document

I'm available for contracting and onsite training.

Videos Filmed & Edited by Bash Films:
x

CppCon 2018: Louis Dionne “Compile-time programming and reflection in C++20 and beyond”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

Compile-time programming and reflection have been getting a lot of attention recently. Indeed, from Herb Sutter's well-known Metaclasses proposal to the newly created Reflection TS, a lot of effort is being put into solving the general problem of programmatic code generation and program introspection. More recently, the C++ Standards Committee has also been evaluating and adopting proposals that vastly expand the realm of constructs available at compile-time, in constexpr functions: new-expressions, try-catch blocks, virtual functions, some standard containers, and more.

For most people, it is unclear how all these features, whether exploratory or voted into the Draft International Standard, relate together. Without being active in the Committee, it can be difficult to see the big picture, the unifying vision driving all these changes. Fortunately, there is one, and this is what this talk is about.

We will go over these features and explain how they might interact with each other by boiling them down to their essential parts. We will present how different use cases for compile-time programming will be solved in C++20, and how even more use cases can be unlocked in the future. Attendees will leave this talk with an understanding of the improvements to constexpr planned for C++20, of what's needed to unlock more advanced use cases and an unifying vision for how to get there.

Louis Dionne, Apple, C++ Standard Library Engineer
Louis is a math and computer science enthusiast who got swallowed by the C++ monster when he was a naive, unsuspecting student. He now works for Apple, where he is responsible for libc++, the Standard Library shipped with LLVM/Clang. He is a member of the C++ Standards Committee and of the Boost community, where he authored the Boost.Hana metaprogramming library.

Videos Filmed & Edited by Bash Films:

CppCon 2017: Hartmut Kaiser “The Asynchronous C++ Parallel Programming Model”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

With the advent of modern computer architectures characterized by — amongst other things —many-core nodes, deep and complex memory hierarchies, heterogeneous subsystems, and power-aware components, it is becoming increasingly difficult to achieve best possible application scalability and satisfactory parallel efficiency. The community is experimenting with new programming models which are based on finer-grain parallelism, and flexible and lightweight synchronization, combined with work-queue-based, message-driven computation. Implementations of such a model are often based on a framework managing lightweight tasks which allows to flexibly coordinate highly hierarchical parallel execution flows.

The recently growing interest in the C++ programming language in industry and in the wider community increases the demand for libraries implementing those programming models for the language. Developers of applications targeting high-performance computing resources would like to see libraries which provide higher-level programming interfaces shielding them from the lower-level details and complexities of modern computer architectures. At the same time, those APIs have to expose all necessary customization points such that power users can still fine-tune their applications enabling them to control data placement and execution, if necessary.

In this talk we present a new asynchronous C++ parallel programming model which is built around lightweight tasks and mechanisms to orchestrate massively parallel (and distributed) execution. This model uses the concept of (std) futures to make data dependencies explicit, employs explicit and implicit asynchrony to hide latencies and to improve utilization, and manages finer-grain parallelism with a work-stealing scheduling system enabling automatic load-balancing of tasks. As a result of combining those capabilities the programming model exposes auto-parallelization capabilities as emergent properties.

We have implemented the this model as a C++ library exposing a higher-level parallelism API which is fully conforming to the existing C++11/14/17 standards and is aligned with the ongoing standardization work. This API and programming model has shown to enable writing parallel and distributed applications for heterogeneous resources with excellent performance and scaling characteristics.

Hartmut Kaiser: Center for Computation and Technology, STE||AR Group

Hartmut is a member of the faculty at the CS department at Louisiana State University (LSU) and a senior research scientist at LSU's Center for Computation and Technology (CCT). He received his doctorate from the Technical University of Chemnitz (Germany) in 1988. He is probably best known through his involvement in open source software projects, mainly as the author of several C++ libraries he has contributed to Boost, which are in use by thousands of developers worldwide. His current research is focused on leading the STE||AR group at CCT working on the practical design and implementation of future execution models and programming methods. His research interests are focused on the complex interaction of compiler technologies, runtime systems, active libraries, and modern system's architectures. His goal is to enable the creation of a new generation of scientific applications in powerful, though complex environments, such as high performance computing, distributed and grid computing, spatial information systems, and compiler technologies.

Videos Filmed & Edited by Bash Films:

CppCon 2017: Piotr Padlewski “Undefined Behaviour is awesome!”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

Undefined behavior (UB) is one of the features of C++ that is both loved and hated. Every C++ developer cares about performance, which is why it is very important to understand what the compiler can optimize and what are the language guarantees. Many times programmers are too optimistic about what the compiler can optimize, or they waste time optimizing code by hand.

In this talk you will learn:
- what is the “as-if” rule
- why compilers know less than the programmer — the main problem with Translation Units
- why compilers optimize based on UB, but don't warn about it
- why Undefined Behavior can transcend time, removing your whole code without running 88mph
- why having a more constrained language is better — optimizations that you can’t do in C

Piotr Padlewski: masters student, University of Warsaw

Videos Filmed & Edited by Bash Films:

2014.10.29 - Security@Scale - Louis Brandy, Facebook

CppCon 2018: Matt Godbolt “The Bits Between the Bits: How We Get to main()”



Presentation Slides, PDFs, Source Code and other presenter materials are available at:

When you run your C++ code, have you ever considered how the linker, loader, operating system, C and C++ runtime all work so hard to get everything set up for you to start running your code in main()?

In this Linux-focused talk, Matt will talk about how the linker stitches together your code and how that fits in with dynamic linking. He'll touch on debugging issues with the loader, and how ODR violations can manifest themselves. Then he'll take a look at what's going on behind the scenes to get the C runtime up, and then the C++ runtime, along with all the global object constructors - showing more reasons why you shouldn't be using them!

By the end of the talk you should have an understanding of how a bundle of object files are brought together by the linker, along with the relevant runtimes, and then loaded and executed by the operating system.

Matt Godbolt, Coinbase
Senior Software Engineer

Matt Godbolt is the creator of the Compiler Explorer website. He is passionate about writing efficient code. He has previously worked at a trading firm, on mobile apps at Google, run his own C++ tools company and spent more than a decade making console games. When he's not hacking on Compiler Explorer, Matt enjoys writing emulators for old 8-bit computer hardware.

Videos Filmed & Edited by Bash Films:

Shares

x

Check Also

x

Menu