Around line 199 in function "search_pattern" /* *_unlocked are a GNU extension: makes function fread thread safe */ which is the opposite of the truth. As their name implies the _unlocked functions are thread-unsafe! They are safe to use, and faster, if you can be sure only one thread is using the FILE*