From: Luis Lavena Date: 2007-11-15T15:42:23+09:00 Subject: [PATCH] mswin32-vc6 segmentation fault due ruby_in_eval wrong definition ------=_Part_5167_33220260.1195108946207 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Summary: Working in collaboration with Aman Gupta, we were trying to make ParseTree on Windows a fully working gem+extension. During the process of testing the changes, we found a segmentation fault raised by the C extension in ruby_in_eval increment: ruby_in_eval++; ... some code ... ruby_in_eval--; The synthetic code was reduced to this: #include "ruby.h" #include "env.h" void Init_test_in_eval() { printf("&ruby_safe_level: %d\r\n", &ruby_safe_level); printf("ruby_safe_level = %d\r\n", ruby_safe_level); printf("&ruby_in_eval: %d\r\n", &ruby_in_eval); printf("ruby_in_eval = %d\r\n", ruby_in_eval); ruby_in_eval++; ruby_in_eval--; } Trying to find why this was happening, found that env.h defined: extern int ruby_in_eval; in contrast with ruby_safe_level (ruby.h): RUBY_EXTERN int ruby_safe_level; I took ruby_safe_level for comparison only and isn't used directly by ParseTree code. This problem block us continue checking the ParseTree windows compatibility. ruby_in_eval was referenced but pointed to garbage memory... Solution: Attached is a patch for ruby_1_8 branch that correct this. Done a build test of the checkout with the modification in case this was used internally by ruby. Everything work without problems, now the test_in_eval extension and ParseTree compiles and run without crashes. Since 1.9 moved away from ruby_in_eval to rb_parse_in_eval() there is no need to back port the change to trunk. We are looking forward this patch gets committed. Regards and have a nice week everybody. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi ------=_Part_5167_33220260.1195108946207 Content-Type: application/octet-stream; name=fix-ruby_in_eval-export-1.patch Content-Transfer-Encoding: base64 X-Attachment-Id: f_f90wnyty0 Content-Disposition: attachment; filename=fix-ruby_in_eval-export-1.patch SW5kZXg6IGVudi5oDQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09DQotLS0gZW52LmgJKHJldmlzaW9uIDEzOTMwKQ0KKysr IGVudi5oCSh3b3JraW5nIGNvcHkpDQpAQCAtNDUsNyArNDUsNyBAQA0KICNkZWZpbmUgU0NPUEVf RE9OVF9SRUNZQ0xFIDQNCiAjZGVmaW5lIFNDT1BFX0NMT05FICAgOA0KIA0KLWV4dGVybiBpbnQg cnVieV9pbl9ldmFsOw0KK1JVQllfRVhURVJOIGludCBydWJ5X2luX2V2YWw7DQogDQogZXh0ZXJu IFZBTFVFIHJ1YnlfY2xhc3M7DQogDQo= ------=_Part_5167_33220260.1195108946207--