Hi,
# find . -type f | xargs grep -l SV_OFFSET
./apps/demos/SceneViewer/SoSceneMenu.h
# find . -type f | xargs grep -l SoSceneMenu.h
./apps/demos/SceneViewer/SoSceneViewer.c++
SV_OFFSET is used to construct "XtResource intl_light_resources[]" data
structures in SoSceneMenu.h
this data is used by the "X-Window system" when the widget (i think is
was a form-widget) is created.
it is not possible to calculate offsets between different "memory
sections"
e.g.
offset between unitialized and initialized data because uninitialized
data goes into "bss section"
and initialied goes into "data section".
the assembler cant calculate and static remember the delta because "the
link editor" or "runtime linker" later
defines the addresses.
i believe this is only a gcc (possible only gcc 3.2 and 3.x) problem
?!?
the bomb origin is not in "code" its in "data" ... but as i remember the
last "program counter" inside of inventor is
in "SoSceneViewer.c++" in the method "SoSceneViewer::menuDisplay" near
the "case SV_LIGHT:" at function call "strcat"
if you simple comment-out the resource definitions inside "{}" of
"XtResource intl_light_resources[]".
you must be careful because the make-dependencies may now recognize the
changes in the header file ... ?!?
here a greater scope of the fix (SoSceneMenu.h) ... look at the second
usage of SV_OFFSET and the "(char *)NULL" in
"lightData[]" ...:
-----------------8<---------8<---------8<------------------------
static SoSceneViewerButton lightData[] = {
{"Create Dir Light", SV_LIGHT_ADD_DIRECT, SV_PUSH_BUTTON, 0,
0},
{"Create Point Light", SV_LIGHT_ADD_POINT, SV_PUSH_BUTTON, 0,
0},
{"Create Spot Light", SV_LIGHT_ADD_SPOT, SV_PUSH_BUTTON, 0,
0},
{0, 0, SV_SEPARATOR },
{(char *)NULL, SV_LIGHT_AMBIENT_EDIT, SV_PUSH_BUTTON, 0,
0},
{0, 0, SV_SEPARATOR },
{"Turn all ON", SV_LIGHT_TURN_ON, SV_PUSH_BUTTON, 0,
0},
{"Turn all OFF", SV_LIGHT_TURN_OFF, SV_PUSH_BUTTON, 0,
0},
{"Show all Icons", SV_LIGHT_SHOW_ALL, SV_PUSH_BUTTON, 0,
0},
{"Hide all Icons", SV_LIGHT_HIDE_ALL, SV_PUSH_BUTTON, 0,
0},
{0, 0, SV_SEPARATOR },
};
#ifdef NOBBI
static struct {
char *headlight;
char *editlight;
char *directionallight;
char *spotlight;
char *pointlight;
} Light;
#else
/**
** BUG FIX:
** the assembler cant calculate offset between different
sections (data and bss in this case).
** the fix is to change bss to data by initializing the
struct.
** this occurs with gcc-3.2
**/
static struct {
char *headlight;
char *editlight;
char *directionallight;
char *spotlight;
char *pointlight;
} Light = {"XXXhead","XXXedit","XXXdirectional","XXXspot", "XXXpoint"};
#endif
XtResource intl_light_resources[] = {
{ "ambientLighting", NULL, XtRString, sizeof(XtRString),
(Cardinal) SV_OFFSET(&lightData[4].name, &lightData[0]),
XtRString, (XtPointer) "Ambient Lighting...",},
{ "headlight", NULL, XtRString, sizeof(XtRString),
(Cardinal) SV_OFFSET(&Light.headlight, &lightData[0]),
XtRString, (XtPointer) "Headlight ",},
{ "editlight", NULL, XtRString, sizeof(XtRString),
(Cardinal) SV_OFFSET(&Light.editlight, &lightData[0]),
XtRString, (XtPointer) "Edit",},
{ "directionallight", NULL, XtRString, sizeof(XtRString),
(Cardinal) SV_OFFSET(&Light.directionallight, &lightData[0]),
XtRString, (XtPointer) "Directional ",},
-----------------8<---------8<---------8<------------------------
NOTE:
"NOBBI" should be undefined
(
)imon
"J.A. Magallon" wrote:
>
> On 2002.09.06 Simon Ney wrote:
> >Hi,
> >
> >see C-Lang comment ... the macro:
> >
> >#define SV_OFFSET(m,b) ( ((char *) (m)) - ((char *) (b)) )
> >
> >calculates dynamic sub-menu entries in the "Light" menu-entry...
> >
> >if this fix is not applied it results in a core dump on click of "Light"
> >menu.
> >
>
> Can you post the piece of code that uses SV_OFFSET and bombs ?
>
> TIA
>
> --
> J.A. Magallon <jamagallon@xxxxxxx> \ Software is like
> sex:
> werewolf.able.es \ It's better when it's
> free
> Mandrake Linux release 9.0 (Cooker) for i586
> Linux 2.4.20-pre5-jam1 (gcc 3.2 (Mandrake Linux 9.0 3.2-1mdk))
--
---------------------------------------------------------------------
| Simon Ney, Bischofsweg 46 60598 Frankfurt/M Tel: ++49 69 68600055 |
| Email Simon.Ney@xxxxxxxxxxxxxxxxxxxxxxxxxxx Fax: ++49 69 68600052 |
---------------------------------------------------------------------
|