← Back to team overview

kicad-developers team mailing list archive

Re: Be careful with static const members

 

On Sun, May 18, 2014 at 10:34:00PM +0200, Nick Østergaard wrote:
> Can this be the reason for the behaviour described in this bug thread?
> 
> https://bugs.launchpad.net/kicad/+bug/1315885/comments/19

In my experience no. Usually is simply gives a link error.

However when the standard says 'it's an error' consequences are
undefined.

I doubt that's the cause... unless it somehow triggers a compiler bug
(which wouldn't be strictly a bug in that case :P)

To troubleshoot the issue I'd put some good old tracing
printf("%d\n",__LINE__); (or wx equivalent) to pinpoint the location
(faster than singlestepping)

In particular I'd check the return value of Kiface() (well... kind of,
since it's a reference), since at first look the
Kiface().KifaceSettings() seem the most probable call to segfault. Well,
it's the only (uncheck) pointer used, it seems...


By the way, the order of the global constructor is non specified. Quite
a common error to incur into. That could be if the DRAW_FRAME in
question is on BSS and not allocated on the heap. Too bad it isn't :D
It's clearly allocated as the OnRunPcbNew.

Another thing: I'm not sure how the initialization of stuff in loaded
DSO is handled in different OS. Dick should know better than me about
that. I'm quite sure BSS get initialized but no idea about constructors.

Based on how the whole kiface thing works it's possible that for some
reason the KIFACE object constructor is not run on loading, so the
KifaceSetting function bombs... just speculating of course.

-- 
Lorenzo Marcantonio
Logos Srl


References