Q: From MDB post: Some op benefit from mmap at the expense of others: Any more insight here? Q: How do you deal with I/O errors? They cause SIGSEGV, right? Q: Did you have any problems with network drives: May give SIGBUS instead of SIGSEGV Q: Does WiredTiger support Windows? Any problems using MapViewOfFile instead of mmap. I've heard MapViewOfFile puts in a lock?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unfinished example of clobber and doNotOptimize functions. | |
// https://godbolt.org/z/CkZ9Bh | |
void f() { | |
int val; | |
//asm volatile("" : : "r,m"(val) : "memory"); | |
//asm volatile("" : : "rm"(val) : "memory"); | |
asm volatile("" : "+m"(val) : : "memory"); | |
val = 1; | |
asm volatile("" : : : "memory"); | |
val = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://godbolt.org/z/pbULFF | |
#include <atomic> | |
int read(std::atomic<int>& a) { | |
return a.load(std::memory_order_seq_cst); | |
} | |
void write(std::atomic<int>& a, int value) { | |
return a.store(value, std::memory_order_seq_cst); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define RUN_ME /* | |
gcc -O2 -Wall $0 -o "$(basename $0 .c)" && ./"$(basename $0 .c)" ; exit | |
*/ | |
#include <inttypes.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <malloc.h> |
- side-channel attacks have been around since 90's
- speculative execution can execute the program in a possible incorrect way, but state is rolled back before visible (atleast that's the idea)
- There has been micro-architectural vuln before: cache timings, rowhammer, branch target buffers
- Trick the cpu into exec instr that should not have been executed
- Attacks both using native code, javascript and eBPF
- An attack
- Locate or introduce instr which act as covert channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Experiment with expressions for reading from structs and union fields. | |
// https://godbolt.org/z/G_fsbD | |
typedef union { | |
struct { | |
long u; | |
short v; | |
char w; | |
} t1; | |
struct { |
My background: Not an expert on debuggers nor embedded systems.
Scope: GNU toolchain. What code does gcc generate? How does gdb interpret it?
END GOAL: An embedded developer should have an intuition for how call flow, control flow and data flow is presented by the debugger.
Many people have described DWARF and how to debug optimized code, but I haven't found an article that gives practical examples of debugging sessions with optimized code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stddef.h> | |
// TODO(dannas): Find examples of loop hoisting. WIP | |
// https://godbolt.org/z/YWf5c7 | |
// baseline | |
void f1(int a[], size_t N) { | |
for (size_t i = 0; i < N; i++) { | |
a[i] = i; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <math.h> | |
// https://godbolt.org/z/sb5cof | |
int add2(int x) { | |
x = x + 1; | |
int y = x + 1; | |
//int y = x; | |
return x + y; | |
} |