g_warning throws core dump with a <<trap>> while g_info does not Why?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

g_warning throws core dump with a <<trap>> while g_info does not Why?

Gonzalo Aguilar Delgado

Hello,


I have a multithread program and I use to log over glib. Using g_warning, g_info, etc convenience macros. I investigated and the only difference between them is the log level used. Something is what I want.


The problem is that if I use g_warning to highlight connection problems in my program it coredumps, but it I use g_info it works flawlesly.


And a trap message is shown when using g_warning. The output is just that:

 G_MESSAGES_DEBUG=all ./testgpsd
/Gpsd/Test60Seconds: ** (/home/gaguilar/workspace-c/sg64-thrift-c_glib-server/src/test/.libs/testgpsd:21759): DEBUG: We must create a thread to process incomming messages on client
** INFO: Thread created for the client

** (/home/gaguilar/workspace-c/sg64-thrift-c_glib-server/src/test/.libs/testgpsd:21759): WARNING **: sg64_gpsd_handler: Error while waiting on thread for GPSD
«trap» para punto de parada/seguimiento (`core' generado)


For the main loop on the thread:



  while (!self->request_exit) {
      if(!gps_waiting(&self->gpsdata, 50000)){

        g_warning ("sg64_gpsd_handler: Error while waiting on thread for GPSD");

//      g_info ("sg64_gpsd_handler: Error while waiting on thread for GPSD");   <---- If I put this it works!
//      self->request_exit=TRUE;
      }else{
      if (gps_read(&self->gpsdata) == -1) {
          g_warning ("sg64_gpsd_handler: %s",
             "Error while reading on thread GPSD");
          g_mutex_lock (&self->mutex_settings);
          self->request_exit=TRUE;
          g_mutex_unlock (&self->mutex_settings);

      }else{
          // Get the time if possible
          if (isnan(self->gpsdata.fix.time) == 0) {
          (void)unix_to_iso8601(self->gpsdata.fix.time, scr, sizeof(scr));
          printf("Current time %s\n", scr);
          }

          /* Fill in the latitude. */
          if (self->gpsdata.fix.mode >= MODE_2D) {
          if(isnan(self->gpsdata.fix.latitude) == 0){
              (void)snprintf(scr, sizeof(scr), "%s %c",
                     deg_to_str(deg_dd, fabs(self->gpsdata.fix.latitude)),
                     (self->gpsdata.fix.latitude < 0) ? 'S' : 'N');
              printf("Current lat %s\n", scr);
          }
          /* Fill in the longitude. */
          if (isnan(self->gpsdata.fix.longitude) == 0) {
              (void)snprintf(scr, sizeof(scr), "%s %c",
                     deg_to_str(deg_dd, fabs(self->gpsdata.fix.longitude)),
                     (self->gpsdata.fix.longitude < 0) ? 'W' : 'E');
              printf("Current lon %s\n", scr);
          }

          /* Fill in the speed. */
          if (isnan(self->gpsdata.fix.track) == 0){
              (void)snprintf(scr, sizeof(scr), "%.1f %s",
                     self->gpsdata.fix.speed, "m/s");

              printf("Current speed %s\n", scr);
          }
          /* Fill in the heading. */
          if (isnan(self->gpsdata.fix.track) == 0) {
              double magheading = true2magnetic(self->gpsdata.fix.latitude,
                            self->gpsdata.fix.longitude,
                            self->gpsdata.fix.track);
              if (!magnetic_flag || isnan(magheading) != 0) {
              (void)snprintf(scr, sizeof(scr), "%.1f deg (true)",
                     self->gpsdata.fix.track);
              } else {
              (void)snprintf(scr, sizeof(scr), "%.1f deg (mag) ",
                     magheading);
              }
              printf("Current heading %s\n", scr);

          }

          }

          /* Fill in the altitude. */
          if (self->gpsdata.fix.mode >= MODE_3D){
          if(isnan(self->gpsdata.fix.altitude) == 0){
              (void)snprintf(scr, sizeof(scr), "%.1f %s",
                     self->gpsdata.fix.altitude, "m");
          }
          }



      }
      }
  }


When working with g_info the output is this one:


/Gpsd/Test60Seconds: ** (/home/gaguilar/workspace-c/sg64-thrift-c_glib-server/src/test/.libs/testgpsd:22552): DEBUG: We must create a thread to process incomming messages on client
** INFO: Thread created for the client
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: Thread finished before the wait
** INFO: Stopping thread

** INFO: sg64_gpsd_handler: Error while waiting on thread for GPSD
** INFO: sg64_gpsd_worker_thread: Finished

done.

OK


Just perfect. The question is why? Where is the problem?


Thank you in advance


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list