Hack

Dataflow Analysis to Semi-Automatically Find Chainer Bugs

published on
Preface As a system software researcher working for an (you know, one of many) “artificial intelligence research center”, I use Chainer to explore what kind of system characteristics/supports the real AI applications need. Chainer is really good for this purpose because the framework itself is really simple so it is easy to hack as you wish. Although the framework is intensively maintained, I sometimes happen to find bugs, especially when I use it in a bit different usage than normally done. Read More...

Psuedo Type Checking in C using Struct

published on
Requirement Let the C compiler recognize two types different, even when the two are actually equivalent in terms of the size and contents. Idea Wrap each type in a struct to add type information, as a compiler recognizes two structs (even with the same size) as different. Do not actually define dummy structs, but use pointers to them to: avoid meaningless coding expect that the types are stored in registers for speedup Example typedef struct A1* a1; typedef struct A2* a2; void f(a1 p){ } void g(a2 p){ } a1 make_a1(int n){ return (a1)(unsigned long)n; } a2 make_a2(int n){ return (a2)(unsigned long)n; } main(){ a1 p1 = make_a1(0); a2 p2 = make_a2(1); f(p1); g(p2); } The code above compiles with no relevant warnings. Read More...

Let Intel Pin follow child processes

published on
Intel Pin is a very successful tool for dynamic bynary instrumentation and is used widely for program analysis (especially for analysing malicious behaviours when the source code is not available). One feature of it is FOLLOW_CHILD_PROCESS_CALLBACK, which allows a user to choose whether the instrumentation is enabled or not for each child prosess of the target program. What the documentation says is that the callback is called everytime the target program does exec (in Linux) and the callback may return true/false in accordance to whether the exec’ed child process has to be instrumented. Read More...

LaTeX and PDF Tips

published on
LaTeX and PDF Tips From the access logs it’s obvious that the latex and pdf tips page (in Japanese) is one of the most popular contents besides my profile and seems like it’s somewhat highly page-ranked by google, so I put here an English translation. Equalize the Column Heights of the Last Page flushend.sty is the most convienient way to equalize the heights of the last page of a 2-column pdf. Read More...

Linking external libraries to an apache module

published on
This is a straight translation from my qiita post in Japanese You may want to link external libraries (like libmysqlclient) when you create an Apache module. The Problem So the Makefile generated by apxs includes some stub, which is like this: # additional defines, includes and libraries #DEFS=-Dmy_define=my_value #INCLUDES=-Imy/include/dir #LIBS=-Lmy/lib/dir -lmylib Cool, so I can add -lmysqlclient to LIBS, right? But the building command executed by make does not include -lmysqlclient, event after I add it. Read More...