x86 - Can static storage (mostly data segment) cause segmentation fault? -
x86 - Can static storage (mostly data segment) cause segmentation fault? -
static
storage decided @ compilation time. however, consider scenario have lot of lazy initialization in functions:
void foo () { static int a[1000]; }
i not discussing coding practice here, technical aspect. many such other functions like foo()
executed, many static
variables introduced on info segment.
will compiler take lazy initialization in business relationship while allocating space info segment. if 'no' then, cause segmentation fault @ runtime while code executing ? (more happen when lot of static
info within template
methods).
just because initialization lazy, allocation isn't. standard requires static variables (including local variables) 0 initialized before start of program. , in fact, static means (in case): space variable nowadays entire lifetime of program.
x86 segmentation-fault lazy-initialization data-segment
Comments
Post a Comment