strange blowup...sequence correct

22 views
Skip to first unread message

Greg Brill

unread,
Aug 27, 2014, 10:37:39 PM8/27/14
to lo...@googlegroups.com
I am getting a consistent seg fault on windows. 

Sequence should be correct per code below: initialization, creation of cerr then call logging macros.  But it explodes:

void initialize()
{
LOGOG_INITIALIZE();
g_errOutput = new logog::Cerr();
//
INFO("this is the first test from inside logog %d", GetCurrentThreadId()); //THIS works find.
//WARN("a warning from here");
}

void print(void* handle, ::ros::console::Level level, const char* str, const char* file, const char* function, int line)
{
INFO("sdf");  //This will blow up the application if present. 


Initialization is called before "print" so I really don't know what is happening.   It is all one thread, but it is as though Initialization isn't happening by the time "print" is called.  Just for fun, I put the initialization code for logog into print, and it stopped blowing up.   

Could really use some direction. 

John Byrd

unread,
Aug 28, 2014, 12:59:44 PM8/28/14
to lo...@googlegroups.com
"Blowing up" is not a term of art and it doesn't help me solve your
problem. If you are getting a segfault on Windows then, since you
have the source code, you should be able to step through the sources
and see on which line in the source the segfault occurs; if you can do
this, since you have a working test case, you should be able to see
the difference in the program state between the working and the
non-working versions. Given your lack of adequate description of the
problem, I can only guess that you're probably calling print() from a
different process.
> --
> You received this message because you are subscribed to the Google Groups
> "Logog" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to logog+un...@googlegroups.com.
> To post to this group, send email to lo...@googlegroups.com.
> Visit this group at http://groups.google.com/group/logog.
> For more options, visit https://groups.google.com/d/optout.



--
---

John Byrd
Gigantic Software
2102 Business Center Drive
Suite 210-D
Irvine, CA 92612-1001
http://www.giganticsoftware.com
T: (949) 892-3526 F: (206) 309-0850

Guillaume Seguin

unread,
Aug 28, 2014, 4:23:24 PM8/28/14
to lo...@googlegroups.com
Just a shot in the dark : I beleive that LOGOG_INITIALIZE creates some objects that are destroyed when it goes out of scope. 

Make shure the LOGOG_INITIALIZE() and LOGOG_SHUTDOWN() pair scope outlives any other logging statements. Maybe like this 

int main() {
int result;
/* The LOGOG_INITIALIZE() function must be called before we call
* any other logog functions.
*/
{
result = real_main_which_include_logging_code();
}
/* Call LOGOG_SHUTDOWN() at the termination of your program to free
* all memory allocated by logog. Make sure no logog objects exist
* when you call LOGOG_SHUTDOWN().
*/

return result;

John Byrd

unread,
Aug 28, 2014, 5:15:28 PM8/28/14
to lo...@googlegroups.com
Guillaume's right. Correct use of LOGOG_INITIALIZE() and
LOGOG_SHUTDOWN() is critical for avoiding memory leaks.
Reply all
Reply to author
Forward
0 new messages