This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
void* xmalloc(size_t s) __attribute__ ((alloc_size(1))); | |
int main(void) | |
{ | |
char *str = "12345"; | |
char *buf = xmalloc(5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
void* xmalloc(size_t s); | |
int main(void) | |
{ | |
char *str = "12345"; | |
char *buf = xmalloc(5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__fortify_function wchar_t * | |
__NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) | |
{ | |
if (__bos (__dest) != (size_t) -1) | |
return __wcpcpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); | |
return __wcpcpy_alias (__dest, __src); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
char *str = "12345"; | |
char *buf = malloc(5); | |
strcpy(buf, str); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
char *str = "12345"; | |
char buf[5]; | |
strcpy(buf, str); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configure.in b/configure.in | |
index 599775b..84f10af 100644 | |
--- a/configure.in | |
+++ b/configure.in | |
@@ -980,7 +980,7 @@ AC_CHECK_HEADERS(limits.h sys/file.h sys/ioctl.h sys/sysca | |
syscall.h pwd.h grp.h a.out.h utime.h direct.h sys/resource.h | |
sys/mkdev.h sys/utime.h float.h ieeefp.h \ | |
ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h ti | |
- net/socket.h sys/socket.h process.h sys/prctl.h) | |
+ net/socket.h sys/socket.h process.h sys/prctl.h atomic.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glibcでrealloc(ptr, 0)とわたしたときに、mtraceのログがおかしいというバグがあってその議論が面白かったのでご紹介。 | |
<a href="http://sourceware.org/bugzilla/show_bug.cgi?id=14981" target="_blank" title="http://sourceware.org/bugzilla/show_bug.cgi?id=14981">http://sourceware.org/bugzilla/show_bug.cgi?id=14981</a> | |
reallocという関数がある。まあ、みなさんよくご存知のように realloc(ptr, size)とわたしたときにptrをsizeの大きさに拡張(縮小)してくれる関数である。 | |
malloc(0)がNULLを返しても非NULLを返してもいいように、realloc(ptr, 0)も挙動に実装の自由度がある | |
1.realloc(ptr, 1) と同等(mallocが非NULLを返すケースではこれが普通) | |
2.ptrは解放され、NULLが返る(mallocがNULLを返すケースでは常識的な挙動) | |
3.ptrは解放されず、NULLが返る(mallocがNULLを返すケースでは同じくらい常識的な挙動、malloc(0)をエラーとみなす哲学だと関数の最初に引数チェックをするのは理解できる) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
この記事は Ruby の Advent Calendar に参加しようとして用意しましたが、間に合わなかったものです。 | |
Ruby 2.0でdtrace対応が入りました。この機能はLinuxのsystemtapからもアクセス出来ます。でも、どこにもドキュメントがないのでいっちょ使い方を解説しようという、そういう趣旨の記事です。 | |
まず、基本の使い方ですが、以下の様に | |
process(プロセス名).provider("ruby").mark(Rubyで定義されてるprobe名) で引っ掛けるイベント名を | |
記述して、tapscriptを記述します | |
ruby.stp | |
<blockquote><pre>probe process("./ruby").provider("ruby").mark("find__require__entry") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/thread_pthread.c b/thread_pthread.c | |
index d60cb41..4d055da 100644 | |
--- a/thread_pthread.c | |
+++ b/thread_pthread.c | |
@@ -959,11 +959,13 @@ native_sleep(rb_thread_t *th, struct timeval *timeout_tv) | |
GVL_UNLOCK_BEGIN(); | |
{ | |
+ rb_thread_t *th = ruby_thread_from_native(); | |
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50.times{|e| | |
(1..2).map{ | |
Thread.new{ | |
} | |
}.each{|e| | |
e.join() | |
} | |
} |