[Sorry for copying -patches in my last email, I actually meant to send it to pgsql-bugs]
Alvaro Herrera wrote: > I've been playing with the MIPS machine a little and still haven't found > any _obvious_ cause for the problem. However I suspect that it may be > related to unaligned memory access, which _I think_ results in a SIGBUS > on MIPS. However, this may turn out to be a red herring, because the variables are allocated in the data segment and not by malloc, so I think it's pretty hard to believe there's any unaligned acccess. A small program that simulates what Postgres is doing here is attached, and it doesn't fail with SIGBUS, which is rather what I'd expect. There may be something different in the way Postgres does things, but I haven't been able to find what. Suggestions welcome. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.
#include <stdio.h> #include <stdlib.h> struct config_generic { const char *name; }; struct config_real { struct config_generic gen; double *var; double reset_val; }; static double dbl_val = 4.0; static struct config_real test = { { "generic name" }, &dbl_val, 2.0 }; static struct config_generic **guc_variables; int main(int argc, char **argv) { struct config_generic *generic_var; struct config_real *double_var; guc_variables = (struct config_generic **) malloc(sizeof(struct config_generic *)); guc_variables[0] = &test.gen; generic_var = guc_variables[0]; double_var = (struct config_real *) generic_var; printf("sizeof(double) = %d, sizeof(double *) = %d\n", sizeof(double), sizeof(double *)); printf("var is %f\n", *double_var->var); printf("storing reset_val into var\n"); *double_var->var = double_var->reset_val; printf("var is %f\n", *double_var->var); return 0; }
---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster