//mymodule.c #include struct emacs_runtime *gert = NULL; emacs_env *genv = NULL; void my_test(void) { genv->intern(genv, "nil"); // sig seg fault -_-! } int emacs_module_init(struct emacs_runtime *ert) { emacs_env *env = ert->get_environment(ert); gert = ert; genv = env; return 0; } // until here, the gert and genv content still correct. //EOF I want to use "env" in my_test(void) but don't want to pass it as a parameter, so I set a global genv to save the pointer. but the *genv content was changed: Breakpoint 4, emacs_module_init (ert=0xbfb904f0) at mymodule.c:411 411 return 0; (gdb) p *gert $4 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } 412 } ########### out of emacs_module_init() ####################### (gdb) s 0x081680b1 in Fmodule_load () (gdb) p *gert $5 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function Fmodule_load, which has no line number information. 0x08164610 in Fload () (gdb) p *gert $6 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function Fload, which has no line number information. 0x0814ee38 in Frequire () (gdb) p *gert $7 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function Frequire, which has no line number information. 0x08141530 in unbind_to () (gdb) p *gert $8 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function unbind_to, which has no line number information. 0x08141d8b in eval_sub () (gdb) p *gert $9 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function eval_sub, which has no line number information. 0x08143fa8 in Feval () (gdb) p *gert $10 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function Feval, which has no line number information. 0x08141530 in unbind_to () (gdb) p *gert $11 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function unbind_to, which has no line number information. 0x081427fd in Ffuncall () (gdb) p *gert $12 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function Ffuncall, which has no line number information. 0x081770bf in exec_byte_code () (gdb) p *gert $13 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910 } (gdb) s Single stepping until exit from function exec_byte_code, which has no line number information. 0x08142355 in funcall_lambda () (gdb) p *gert $14 = {size = 138896016, private_members = 0x0, get_environment = 0x4c38} (gdb) q A debugging session is active. what's happened after calling funcall_lambda () ? is it possible to keep a copy of the *env in module ? thanks!