Skip to content

Instantly share code, notes, and snippets.

@scottt
scottt / TWKLH-description.txt.patch
Last active August 20, 2018 14:14
Proposed change to TWLKH FB group description
--- TWLKH-description.txt 2018-08-20 21:49:59.361145866 +0800
+++ TWLKH-description.txt.hacked 2018-08-20 22:12:40.319784822 +0800
@@ -17,23 +17,6 @@
社團另有 slack 聊天室位於
https://twlinuxkernelhackers.slack.com/
-欲加入社團FB messenger群組請洽管理員。
-
-Kernel 內容繁雜,目前依據貼文的內容用tag在 Facebook 上面分類(字母排序)
-
@scottt
scottt / stack-and-sp.c
Created June 11, 2018 23:12
stack-and-sp: test whether stack access without setting the stack pointer register would cause SEGFAULTs on x86-64
/* x86-64 program to test wether stack access without setting the stack poitner register would cause SEGFAULTs
* $ ./stack-and-sp # just access stack adjacent memory until SEGFAULT.
* $ ./stack-and-sp --set-sp # set stack pointer register before accessing memory.
*
* Output:
* stack-and-sp: do_set_sp: 1
* RLIMIT_STACK: 8192/unlimited (cur/max)
* sp0: 0x7ffd5fdd3000
* sp: 0x7ffd5f5d7000, size: 8176K
*/
@scottt
scottt / TRANSCRIPT
Created May 31, 2018 14:21
Interruption and auto restart of syscall after signal handler execution
$ gdb -q -x syscall-restart-after-handler.gdb
Breakpoint 1 at 0x400920: file syscall-restart-after-handler.c, line 13.
pre blocking read on pipe
Breakpoint 1, sig_handler (sig=14, info=0x7fffffffc230, ctx=0x7fffffffc100) at syscall-restart-after-handler.c:13
warning: Source file is more recent than executable.
13 fprintf(stderr, "%s: caught signal %d (%s) \n", program_name, sig, strsignal(sig));
#0 sig_handler (sig=14, info=0x7fffffffc230, ctx=0x7fffffffc100) at syscall-restart-after-handler.c:13
#1 <signal handler called>
#2 0x00007ffff7b02fc1 in __GI___libc_read (fd=3, buf=buf@entry=0x7fffffffc6b7, nbytes=nbytes@entry=1) at ../sysdeps/unix/sysv/linux/read.c:27
@scottt
scottt / burn-cpu-and-segfault.c
Last active July 10, 2022 08:33
signalfd SIGCHLD handling
/* Burn some CPU time then segfault */
int main()
{
volatile int i;
for (i=0; i>=0; i++)
;
*(volatile char*)0;
return 0;
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@scottt
scottt / Numpy-1D-Vectors.ipynb
Created November 3, 2017 12:27
Numpy 一維陣列沒區分 row 與 column vector
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@scottt
scottt / Matplotlib-Set-Font-for-zh-TW.ipynb
Created October 26, 2017 05:18
Matplotlib set suitable font for zh_TW text
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.