Skip to content

Instantly share code, notes, and snippets.

@vtjnash
vtjnash / mach-sigchld-bug.c
Created Aug 17, 2021
SIGCHLD bug with macOS mach xnu posix_spawn
View mach-sigchld-bug.c
/* Copyright libuv contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
View jameson-pgp2021.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGDlNbwBEACcP4bRV2VZjt0gjTl5g9Eild/e9MAemDGd63U2570f+3bJJo3I
ysbIUeIikWtYvmnZPXCQz2rn7skXX2v1bHRpaP8eEyeCxtuzIJ8IFk6cS253abZw
dWuy3fEYFlW0qez9BkLuYF25nbEBi964GBpsivmnGmzlN3hctJT1n+eJgukt/NQw
twp/5aiEfZ6ACW9hrzegOefVjd5ahs+rNViME5COk+a1fkRV8FDcSz6i5nEFxKEs
wDgziOoWhK9jzVCq+5p45uNKcZnp80zdyjerFF9oVpvqwwF6lM2H+FvYx+yT/x7C
zd7iwWB4ERDtOiyqbl+MEu2ES0I/inwYve14/mEiq2CBCvEh6b3kijcahU+ND9/N
1XCMJYUp0tORGEWKAi2xPWB5u8toL2qg/Y9wG2QJ+W81qxyXw1IHAO2N35jUI+Hr
GmyFRuCxdj/T1nBTJT8CfeXEPGbAud2JU2Lb3jLoy86F+BQhLVttJiDvV/y6gJOk
View jameson-pgp.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQINBFcQfaEBEACsFVOK9z9DQTbBAh0fWIilqgeT6B1MM5fKSJOjT/UreHEicdQG
yAws+C7/1HqotqAStLbpO2bLHBWhtMZyiINPkRJ8Wa4Pl/57TgJoN6B1peGnyH2a
QBtyje+Ikp+9ZcdSBSXM5ozOXjuW9bEn65esg6uBXossN6cblkWBCWGvWFD5SoHf
e0EyHGS2Lnj2mPM+eBttxcK8q2RTFTPp4JbKGmv7B3z8ML2VrtDZRP5KwTq3Kf9N
rKU7tK0tJOqMHPltcBmIm+pvbJGFlAWSkF+opcufoRNRy+V/dSlREywh+ywhrQnB
k7nsAN49qt84wz3zyLez+0B+nvzVJPGx40ZsIxLUhuSMxNFmo4kOOGhfy0m7tn0V
S0Evyei1YV7wg8pvkyvszaT7kCBs3GzaoWbndNG2DZebObcUg2dmMeo8rjdEZyQ9
View JuliaAtomics.md

Introduction

This proposal aims to define the memory model of Julia and to provide certain guarantees in the presence of data races, both by default and through providing intrinsics to allow the user to specify the level of guarantees required. This should allow native implementation in Julia of simple system primitives (like mutexes), interoperate with native system code, and aim to give generally explainable behaviors without incurring significant performance cost. Additionally, it strives to be general-purpose and yet clear about the user's intent—particularly with respect to ensuring that an atomic-type field is accessed with proper care for synchronization.

The last two points deserve particular attention, as Julia has always provided strong reflection and generic programming capabilities that has not been seen—in this synergy combination—in any other language. Therefore, we want to be careful to observe a distinction between the asymmetries of reading vs. writing that we have felt is often not given

@vtjnash
vtjnash / alloc32035.jl
Created Apr 13, 2021
memory allocation policy comparison
View alloc32035.jl
let a = 2; global y2 = Int[]
while a < 2^42
a += a < .1*2^34 ? a : round(Int, .1*2^34)
push!(y2, a)
end
y2
end;
let a = 2; global y3 = Int[]
while a < 2^46
@vtjnash
vtjnash / MHO-C303.txt
Last active Feb 7, 2021
Updating time on MHO-C303 manually (example)
View MHO-C303.txt
Getting current time:
julia> string(bswap(round(UInt32, datetime2unix(Dates.now()))), base=16) * "00"
"5f3f1f60"
The "00" is the timezone offset (in hours). Here we just use localtime (with offset zero).
With Bluetility.app (from Github) or any other similar tool for bt gatt, look for:
Service: EBE0CCB0-7A0A-4B0C-8A1A-6FF2997DA3A6
Characteristic: EBE0CCB7-7A0A-4B0C-8A1A-6FF2997DA3A6
Read: Hex: 973F1F60_00
@vtjnash
vtjnash / ambig.jl
Created May 19, 2020
method-ambiguities on f12cde0e8c7f4268838d3201dd9e13b90ea44633 (Version 1.6.0-DEV.29)
View ambig.jl
julia> Test.detect_ambiguities(Base)
35-element Array{Tuple{Method,Method},1}:
(\(F::LinearAlgebra.Factorization{T}, B::Union{Array{Complex{T},1}, Array{Complex{T},2}}) where T<:Union{Float32, Float64} in LinearAlgebra at /data/vtjnash/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/factorization.jl:84, \(A::LinearAlgebra.LQ{TA,S} where S<:AbstractArray{TA,2}, B::StridedVecOrMat{TB}) where {TA, TB} in LinearAlgebra at /data/vtjnash/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/lq.jl:310)
(convert(::Type{T}, x::T) where T in Base at essentials.jl:171, convert(::Type{T}, x) where T>:Missing in Base at missing.jl:69)
(convert(::Type{T}, x) where T>:Missing in Base at missing.jl:69, convert(::Type{T}, x::T) where T>:Nothing in Base at some.jl:33)
View japi1_vcat_52196.ll
define internal nonnull %jl_value_t addrspace(10)* @japi1_vcat_52196(%jl_value_t addrspace(10)*, %jl_value_t addrspace(10)**, i32) #8 !dbg !60493 {
top:
%3 = alloca %jl_value_t addrspace(10)*, i32 2
%gcframe = alloca %jl_value_t addrspace(10)*, i32 4, align 16
%4 = bitcast %jl_value_t addrspace(10)** %gcframe to i8*
call void @llvm.memset.p0i8.i32(i8* align 16 %4, i8 0, i32 32, i1 false), !tbaa !11893
%5 = alloca %jl_value_t addrspace(10)**, align 8
store volatile %jl_value_t addrspace(10)** %1, %jl_value_t addrspace(10)*** %5, align 8
%6 = load i64, i64* @jl_tls_offset.real, !tbaa !11895, !invariant.load !4
@vtjnash
vtjnash / prettyprint.asm
Created Dec 2, 2019
dwarf linetable pretty printer
View prettyprint.asm
julia> @code_native write(devnull, 'x')
.text
; ┌ @ io.jl:644 within `write'
; │┌ @ io.jl:644 within `bswap'
bswapl %edi
xorl %eax, %eax
nopw %cs:(%rax,%rax)
nop
; │└
; │ @ io.jl:648 within `write'
@vtjnash
vtjnash / after.ll
Last active Apr 28, 2019
bad TBAA/LICM
View after.ll
; *** IR Dump After Loop Invariant Code Motion *** (loop: %L140)
; ModuleID = 'reverse1'
source_filename = "reverse1"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12:13"
target triple = "x86_64--linux-gnu"
%jl_value_t = type opaque
@llvm.compiler.used = appending global [2 x i8*] [i8* bitcast (%jl_value_t addrspace(10)* (i8*, i32, i32)* @jl_gc_pool_alloc to i8*), i8* bitcast (%jl_value_t addrspace(10)* (i8*, i64)* @jl_gc_big_alloc to i8*)], section "llvm.metadata"