Skip to content

Instantly share code, notes, and snippets.

@hackcasual
Created October 17, 2017 22:56
Show Gist options
  • Save hackcasual/7de2f357714505061506df01923f99cd to your computer and use it in GitHub Desktop.
Save hackcasual/7de2f357714505061506df01923f99cd to your computer and use it in GitHub Desktop.
#include <cstdint>
#include <stdio.h>
#include <emscripten.h>
using namespace std;
struct source_location {
const char *file_name;
union {
unsigned long reported;
struct {
uint32_t line;
uint32_t column;
};
};
};
struct type_descriptor {
uint16_t type_kind;
uint16_t type_info;
char type_name[1];
};
struct overflow_data {
struct source_location location;
struct type_descriptor *type;
};
extern "C" {
void EMSCRIPTEN_KEEPALIVE __ubsan_handle_add_overflow(struct overflow_data *data,
unsigned long lhs,
unsigned long rhs)
{
printf("Overflow happened %lu + %lu @%s\n", lhs, rhs, data->location.file_name);
}
}
int main(int argc, char **argv) {
int k = 0x7fffffff;
k += argc;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment