Skip to content

Instantly share code, notes, and snippets.

View mqp's full-sized avatar

Marshall Polaris mqp

  • Mountain View, CA
View GitHub Profile
@mqp
mqp / test.c
Created April 1, 2011 23:24
TCO subtleties with C compilers
#include <stdio.h>
long acc_normal_rec(long n, long acc)
{
if (n == 0) return acc;
long localacc = acc + 1;
return acc_normal_rec(n-1, localacc);
}
long acc_normal(long n)
@mqp
mqp / keybase.md
Created December 3, 2015 00:24
Keybase proof of identity

Keybase proof

I hereby claim:

  • I am maugrim on github.
  • I am mquander (https://keybase.io/mquander) on keybase.
  • I have a public key ASAHmK98lT2L5S0Vec_AXgnkWKox7rdoI-7vEMfmbnSw0wo

To claim this, I am signing this object:

@mqp
mqp / ComponentCachedGameObject.cs
Last active September 23, 2016 00:57
ComponentCachedGameObject example
using System;
using System.Collections.Generic;
using UnityEngine;
public static class ComponentCachingDemo
{
public static Dictionary<int, ComponentCachedGameObject> gameObjectsByMeshId;
public static void AddObjects()
{
@mqp
mqp / metric.cs
Created November 5, 2016 00:10
Incremental mystery metric computation
internal void UpdateRoundTripTimeAndVariance(int lastRoundtripTime)
{
if (lastRoundtripTime < 0)
{
return;
}
this.roundTripTimeVariance -= this.roundTripTimeVariance / 4;
if (lastRoundtripTime >= this.roundTripTime)
{
this.roundTripTime += (lastRoundtripTime - this.roundTripTime) / 8;
@mqp
mqp / resource-example.cs
Created February 28, 2017 21:44
Illustrates different ways of loading resources in Unity.
public class ResourceExample : MonoBehavior
{
private GameObject RuntimeLoadedPrefabA;
private GameObject RuntimeLoadedPrefabB;
private GameObject RuntimeLoadedPrefabC;
private GameObject RuntimeLoadedPrefabD;
private GameObject RuntimeLoadedPrefabE;
private GameObject RuntimeLoadedPrefabF;
@mqp
mqp / test.html
Created November 15, 2017 22:09
Test page for Firefox media stream code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tiny test page</title>
</head>
<body>
<form id="form">
<input id="file" type="file" />
<input type="submit" val="Load"/>
@mqp
mqp / janus-refcount-no-sdp-leak
Created November 18, 2017 00:23
janus-refcount-no-sdp-leak
Janus commit: f4fd0084393c1c892b314bb728b7367504df7237
Compiled on: Fri Nov 17 16:22:04 PST 2017
---------------------------------------------------
Starting Meetecho Janus (WebRTC Gateway) v0.2.6
---------------------------------------------------
Checking command line arguments...
[janus.cfg]
[general]
@mqp
mqp / gist:b8d021336b8d9057692e6d70da80a79e
Created November 18, 2017 02:29
janus-refcount-early-destruction
Janus commit: abe0d16b54517c4331002de9e0c7a1b270ef8f80
Compiled on: Fri Nov 17 16:36:45 PST 2017
---------------------------------------------------
Starting Meetecho Janus (WebRTC Gateway) v0.2.6
---------------------------------------------------
Checking command line arguments...
[janus.cfg]
[general]
@mqp
mqp / gist:149f0ba645801913e0cfd55ac6303144
Last active December 6, 2017 22:42
ASan output for Janus ICE destruction shutdown alert race
==24300==ERROR: AddressSanitizer: heap-use-after-free on address 0x612000859908 at pc 0x5639a5226111 bp 0x7fdea5b5e200 sp 0x7fdea5b5e1f0
READ of size 8 at 0x612000859908 thread T1937 (icesend 2661940)
#0 0x5639a5226110 in janus_ice_send_thread /home/mquander/src/janus-gateway/ice.c:3360
#1 0x7fdf95d21644 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72644)
#2 0x7fdf945347fb in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x77fb)
#3 0x7fdf94261b0e in clone (/lib/x86_64-linux-gnu/libc.so.6+0x114b0e)
0x612000859908 is located 200 bytes inside of 280-byte region [0x612000859840,0x612000859958)
freed by thread T1918 (iceloop 2661940) here:
#0 0x7fdf9653c7b8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7b8)
@mqp
mqp / gist:72776ae34824059a4818bc160bd36fc5
Created December 6, 2017 22:43
ASan output for Janus ICE destruction incoming data race
#0 0x5575b8946289 in janus_dtls_notify_data /home/mquander/src/janus-gateway/dtls.c:924
#1 0x5575b8a3b025 in janus_sctp_handle_data_message /home/mquander/src/janus-gateway/sctp.c:939
#2 0x5575b8a3b34c in janus_sctp_handle_message /home/mquander/src/janus-gateway/sctp.c:989
#3 0x5575b8a2ef1c in janus_sctp_incoming_data /home/mquander/src/janus-gateway/sctp.c:343
#4 0x7f010e0f4b4a in sctp_invoke_recv_callback netinet/sctputil.c:4855
#5 0x7f010e0f5236 in sctp_add_to_readq netinet/sctputil.c:4963
#6 0x7f010e079940 in sctp_process_a_data_chunk netinet/sctp_indata.c:2103
#7 0x7f010e07ba31 in sctp_process_data netinet/sctp_indata.c:2760
#8 0x7f010e095b9e in sctp_common_input_processing netinet/sctp_input.c:6162
#9 0x7f010e060d2b in usrsctp_conninput /home/mquander/src/janus-plugin-sfu/build/sctplab/usrsctp/usrsctplib/user_socket.c:3375