signal SEGV (no mapping at the fault address)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers signal SEGV (no mapping at the fault address)
# 1  
Old 04-13-2010
signal SEGV (no mapping at the fault address)

Hello

i ve got the following error on a C servor.
Code:
signal SEGV (no mapping at the fault address)

when running in dbx
Code:
program terminated by signal SEGV (no mapping at the fault address)
0xff1d5cb4: srch_dir+0x0154:    cmp     %o1, %o0
Current function is _log
  533                   fprintf ( fp,"%s", "test" )

a where in dbx give me this
Code:
(dbx) where                                                                  
  [1] srch_dir(0x2008, 0xa0550, 0xa0550, 0xa0550, 0x0, 0x0), at 0xff1d5cb4
  [2] ispts(0x2008, 0x1, 0x98904, 0x0, 0xff26e32c, 0xff2776f0), at 0xff1d5a6c
  [3] 0xff2265ac(0x543e0, 0x6, 0x40, 0xffffffff, 0x4, 0x2000), at 0xff2265ab
  [4] _rmutex_lock(0x3b754, 0xffbfece4, 0xff26e32c, 0x0, 0x40, 0x40), at 0xff219550
  [5] mknod(0x543e0, 0x3b754, 0x503a8, 0x513b8, 0x2296c, 0xff26e32c), at 0xff21d040
=>[6] _log(msg = 0xffbff694, param = UNION), line 533 in "transf.c"
  [7] Processus_serveur(0x5, 0x543b0, 0x0, 0x0, 0x65e10, 0x9), at 0x1a7a4
  [8] demare(0x0, 0x1, 0x0, 0x0, 0x5, 0x4), at 0x199b4
  [9] main(0x4, 0xffbff894, 0x0, 0x0, 0x1, 0x0), at 0x192ec

pstack core
{code}
Code:
core 'core' of 1202:    /export/home/support_sofi/bin/support_sofi -detach -debug -nolog
 ff1d5cb4 srch_dir (2008, a0550, a0550, a0550, 0, 0) + 154
 ff1d5a6c ispts    (2008, 1, 98904, 0, ff26e32c, ff2776f0) + 64
 ff2265ac _sys_errs (543e0, 6, 40, ffffffff, 4, 2000) + 258
 ff219550 _rmutex_lock (3b754, ffbfece4, ff26e32c, 0, 40, 40) + 68
 ff21d040 mknod    (543e0, 3b754, 503a8, 513b8, 2296c, ff26e32c) + 24
 0001f624 ???????? (ffbff694, ffbff674, 200, 0, 0, 65e10)
 0001a7a4 ???????? (5, 543b0, 0, 0, 65e10, 9)
 000199b4 ???????? (0, 1, 0, 0, 5, 4)
 000192ec ???????? (4, ffbff894, 0, 0, 1, 0)
 00014d78 ???????? (0, 0, 0, 0, 0, 0)

{code}

Code:
(dbx) print *fp
*fp = {
    _cnt          = 0
    _ptr          = (nil)
    _base         = (nil)
    _flag         = '\002'
    _file         = '\004'
    __orientation = 1U
    __ionolock    = 0
    __filler      = 0

here is the function which have the problem

Code:
{code}void _log (struct msg_info * msg, union msg_param param)
{
    struct msgin_log * pin;
    struct msgout_log * pout;
    char * c;
    char Buffer[2048];
    char fname[255];
    
    time_t ti;
  struct tm * tm = NULL;

    FILE * fp = NULL;

    trace ("_log begin");

    pin = (struct msgin_log *)msg->data_in;
    pout = (struct msgout_log *)msg->data_out;
    msg->len_out = sizeof (struct msgout_log);
    memset (pout, 0, sizeof (struct msgout_log));
    trace ("_fin allocation");

    // reconstitution du nom du fichier de log support_sofi.client.yyyy-mm-dd.log
    time (&ti);
    tm = localtime (&ti);
    trace ("_fin time");

    strncpy ( Buffer, pin->InMsg, 2048 );
    sprintf ( fname, "support_sofi.client.%04d-%02d-%02d.log", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday );

    trace ("_fin sprintf");
    trace(fname);
    fp = fopen (fname, "a");
    trace ("_fin fopen");
    if ( fp != NULL )
    {
        trace ("_start fprintf");
        trace(Buffer);
        fprintf ( fp,"%s", "test" );
      //fwrite (Buffer , 1 , sizeof(Buffer) , fp );
        //fputs(Buffer,fp);
        trace ("_fin fprintf");
        if (fclose (fp)!=0){
            trace ("fclose failed");
        }else{
            trace("fclose success");
        } 
        trace ("_fin fclose");
     
    }

    //strcpy ( pout->OutMsg, "" );
    trace ("_log end");
}{code}

this code work on a server but not on an other one, i would like to see why it doesn't work on the second servor.
Note that the core dump is created after the second call to the _log function

any help would be appreciated

thanks in advanced

---------- Post updated at 10:06 AM ---------- Previous update was at 10:03 AM ----------

the _log function is called in the server.c file

Code:
/********************************************************************
 *                      SERVER.C
 *                     ----------
 *
 * Objet :
 *      Moniteur serveur pour les échanges papiers SUPPORT
 *      Application client-serveur
 *      Client : Application sur poste de travail PTMF2 sous NT4
 *      Serveur: Application sur serveur UNIX NCR ou SUN
 *      Communication : socket TCP/IP
 *
 *--------------------------------------------------------------------
 * V 1.3 02/07/2001
 *   Ajout edition des attestations
 *
 * V 2.1 08/10/2001
 *   Ajout gestion des variables
 *
 * V 2.5 02/07/2002
 *   Modification des lignes cmc7 des vignettes
 *   Fonctions d'affichage des statistiques
 *
 * V 2.5 07/11/2002
 *   Portage sur sun
 *
 * V 2.9 01/07/2004
 *   Portage sur sun, compilation laxf01
 *
 *********************************************************************/

#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <netdb.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <netinet/in.h>

#define SUPPORT_SERVER_C
#include "main.h"
#include "server.h"
#include "fonction.h"
#include "transf.h"

static char ident[] = "@(#)"__FILE__","__DATE__","__TIME__"\0";

/*
 * Fonction appelee lors de l'initialisation du pocessus
 * maitre. Permet d'initialiser les variables dupliquees
 * lors de la creation des processus de dialogue.
 */

#define DEBUG

int Processus_initialiser()
{
	printf("\n%s\n%s\n%s\n\n",
	"----------------------------------------------",
	"  (c) 2001-2002 DISF La Poste                 ",
	"----------------------------------------------");
	printf (" Module traitement serveur : %s %s\n\n", __DATE__, __TIME__);

	gs_Pid = 0;
	gs_SocketId = 0;
	gs_SocketNum = 0;
	memset (gs_Utilisateur, 0, SIZE_UTIL);
	gs_Accept = FALSE;

	return TRUE;
}

#define NETBUFF_TMP	1024
#define NETBUFF_MAX	65536

static char * _netbuff;
static char * _databuffin;
static char * _databuffout;

/*----------------------------------------------------------------
 * Table de definition des messages
 *  - Nom de la requette
 *  - Version mini, Version maxi
 *  - Autorisee hors signature
 *  - Ouverture automatique des ports
 *  - Fonction, et parametre
 *----------------------------------------------------------------*/

static struct msg_table _msg_table[] =
{
//
// Traitements directs par le service
//
{{'C', 'L', 'O', 'T'}, 0, 0xffff, TRUE, FALSE, _terminer, {0}},
{{'S', 'I', 'G', 'N'}, 0, 0xffff, TRUE, FALSE, _signature, {0}},
{{'E', 'T', 'A', 'P'}, 0, 0xffff, TRUE, FALSE, _test_etape, {0}},
{{'P', 'A', 'R', 'A'}, 0, 0xffff, TRUE, FALSE, _parametres, {0}},
{{'P', 'U', 'T', 'F'}, 0, 0xffff, FALSE, TRUE, _fichier_ecrit, {0}},
{{'G', 'E', 'T', 'F'}, 0, 0xffff, FALSE, TRUE, _fichier_lit, {0}},
{{'M', 'S', 'G', 'S'}, 0, 0xffff, FALSE, TRUE, _messages, {0}},
{{'V', 'A', 'R', 'S'}, 0, 0xffff, FALSE, TRUE, _variables, {0}},
//
// Traitements externes
//
// Transferts et procédures
{{'S', 'H', 'E', 'L'}, 0, 0xffff, FALSE, FALSE, _lanceprocedure, {0}},
{{'W', 'L', 'O', 'G'}, 0, 0xffff, FALSE, FALSE, _log, {0}},
{{'S', 'H', 'R', 'T'}, 0, 0xffff, FALSE, FALSE, _lanceprocedure_stdout, {0}},
{{'S', 'H', 'S', 'O'}, 0, 0xffff, FALSE, FALSE, _lanceprocedure_systemoutput, {0}},
{{'T', 'R', 'A', 'N'}, 0, 0xffff, FALSE, FALSE, _transfert, {0}},
{{0, 0, 0, 0}, 0, 0, 0, 0, NULL, {0}}
};

static int __fin = FALSE;

static int recvwait(int s, char * buf, int len, int flags)
{
#ifdef sun
	int i = len;
	char * ptr = buf;
	while (i > 0)
	{
		int l;
		if ((l = recv (s, ptr, i, flags)) < 0)
			return -1;
		if (l == 0)
			return 0;
		i -= l;
		ptr += l;
	}
	return len;
#else
	return recv(s, buf, len, flags | MSG_WAITALL);
#endif
}


int Processus_serveur (int sock_communication)
{
	struct msg_header msgh;
	struct msg_info   msgi;
	int m, i;
	char * ptr;

	/*
	 * Initialisation du processus utilisateur
	 */

#ifdef DEBUG
	trace ("Processus_serveur point 1");
#endif

	__fin = FALSE;
	_netbuff = (char *)malloc (NETBUFF_TMP);
	_databuffin = (char *)malloc (NETBUFF_MAX);
	_databuffout = (char *)malloc (NETBUFF_MAX);
	if (_netbuff == NULL || _databuffin == NULL || _databuffout == NULL)
	{
		send (sock_communication, "ERRO", 4, 0);
		send (sock_communication, "\n", 1, 0);
		__fin = TRUE;
	}

#ifdef DEBUG
	trace ("Processus_serveur point 2");
#endif

	if (!Crsf_Charger ())
	{
		send (sock_communication, "ERRO", 4, 0);
		send (sock_communication, "\n", 1, 0);
		__fin = TRUE;
	}

#ifdef DEBUG
	trace ("Processus_serveur point 3");
#endif

	if (!Rejet_Charger ())
	{
		send (sock_communication, "ERRO", 4, 0);
		send (sock_communication, "\n", 1, 0);
		__fin = TRUE;
	}

#ifdef DEBUG
	trace ("Processus_serveur point 4");
#endif

	if (!Parametres_Initialiser ())
	{
		send (sock_communication, "ERRO", 4, 0);
		send (sock_communication, "\n", 1, 0);
		__fin = TRUE;
	}

	/*
	 * Boucle de traitement des requettes
	 */

#ifdef DEBUG
	trace ("Processus_serveur point 5");
#endif

	while (!__fin)
	{
#ifdef DEBUG
		trace ("Processus_serveur attente commande");
#endif
		if (recvwait (sock_communication, (char *)(&msgh), sizeof (msgh), 0) <= 0)
		{
			if (errno == EINTR)	__fin = TRUE;
			else perror ("Erreur lecture des donnees");
			__fin = TRUE;
			break;
		}
		// Mise au format correct des donnees binaires
		msgh.Version = ntohs (msgh.Version);
		msgh.PortAller = ntohs (msgh.PortAller);
		msgh.PortRetour = ntohs (msgh.PortRetour);
		msgh.Longueur = ntohs (msgh.Longueur);

#ifdef DEBUG
		trace ("Processus_serveur commande recue");
#endif

		// Recherche si commande connue dans le tableau

		for (m = 0; _msg_table[m].ReqName[0] != 0; m++)
		{
			if (memcmp (_msg_table[m].ReqName, msgh.ReqName, 4) != 0)
				continue;
			if (msgh.Version < _msg_table[m].MinVer || msgh.Version > _msg_table[m].MaxVer)
				continue;
			//
			// Ok c'est trouve
			// Lecture des donnees du message
			//
			i = msgh.Longueur;
			ptr = _databuffin;
			while (i > 0)
			{
				int l = (i > 512) ? 512 : i;
				if (recvwait (sock_communication, ptr, l, 0) != l)
				{
					if (errno != EINTR)	perror ("Erreur lecture des donnees");
					__fin = TRUE;
					break;
				}
				i -= l;
				ptr += l;
			}
			msgi.header = msgh;
			msgi.size_in = NETBUFF_MAX;
			msgi.len_in = msgh.Longueur;
			msgi.data_in = _databuffin;
			msgi.size_out = NETBUFF_MAX;
			msgi.len_out = 0;
			msgi.data_out = _databuffout;
			msgi.sok_in = 0;
			msgi.sok_out = 0;
			//
			// Si besoin, ouverture des ports de communication additionels
			//
			if (_msg_table[m].Ouverture)
			{
				struct sockaddr_in sokdef;
#ifdef DEBUG
				trace ("Ouverture des ports additionels");
#endif
				if (msgh.PortAller != 0)
				{
					if ((msgi.sok_in = socket(PF_INET, SOCK_STREAM, 0)) == -1 )
					{
						perror("Erreur lors de la creation du socket");
						sortie (-1);
					}
					//initialisation du serveur
					sokdef.sin_family = AF_INET;
					sokdef.sin_port = htons(msgh.PortAller);
					sokdef.sin_addr.s_addr = gs_SaClient.sin_addr.s_addr;
					if (connect (msgi.sok_in, (struct sockaddr *)&sokdef, sizeof (sokdef)) != 0)
					{
						perror("Erreur lors de la connexion du socket");
						__fin = TRUE;
						break;
					}
#ifdef DEBUG
					trace ("Connexion entree realisee");
#endif
				}
				if (msgh.PortRetour != 0)
				{
					if ((msgi.sok_out = socket(PF_INET, SOCK_STREAM, 0)) == -1 )
					{
						perror("Erreur lors de la creation du socket");
						if (msgi.sok_in != 0)
							close (msgi.sok_in);
						sortie (-1);
					}
					//initialisation du serveur
					sokdef.sin_family = AF_INET;
					sokdef.sin_port = htons(msgh.PortRetour);
					sokdef.sin_addr.s_addr = gs_SaClient.sin_addr.s_addr;
					if (connect (msgi.sok_out, (struct sockaddr *)&sokdef, sizeof (sokdef)) != 0)
					{
						perror("Erreur lors de la connexion du socket");
						if (msgi.sok_in != 0)
						{
							close (msgi.sok_in);
							msgi.sok_in = 0;
						}
						__fin = TRUE;
						break;
					}
#ifdef DEBUG
					trace ("Connexion sortie realisee\n");
#endif
				}
			}
			//
			// Si fonction disponible selon l'état de connexion
			//
			if (gs_Accept == 1 || _msg_table[m].Autori != FALSE)
			{ 
				//
				// Appel de la fonction de traitement
				//
				if (_msg_table[m].fn_trait != NULL)
				{
					_msg_table[m].fn_trait (&msgi, _msg_table[m].Param);
				}
			}
			else
			{
				printf ("Reception commande %4.4s(%d) interdite\n", msgh.ReqName, msgh.Version);
				__fin = TRUE;
			}
			//
			// Si besoin, fermeture des ports de communication additionels
			//
			if (_msg_table[m].Ouverture)
			{
				if (msgi.sok_in != 0)
				{
					shutdown (msgi.sok_in, 0);
					close (msgi.sok_in);
					msgi.sok_in = 0;
				}
				if (msgi.sok_out != 0)
				{
					shutdown (msgi.sok_out, 0);
					close (msgi.sok_out);
					msgi.sok_out = 0;
				}
			}
			//
			// Retour des donnees du message
			//
			msgh.PortAller = htons (msgh.PortAller);
			msgh.PortRetour = htons (msgh.PortRetour);
			msgh.Longueur = htons (msgi.len_out);
			msgh.Version = htons (msgh.Version);
			if (send (sock_communication, (char *)(&msgh), sizeof (msgh), 0) <= 0)
			{
				if (errno == EINTR)	__fin = TRUE;
				else perror ("Erreur envoi des donnees");
				__fin = TRUE;
				break;
			}
			i = msgi.len_out;
			ptr = _databuffout;
			while (i > 0)
			{
				int l = (i > 512) ? 512 : i;
				if (send (sock_communication, ptr, l, 0) != l)
				{
					if (errno != EINTR)	perror ("Erreur envoi des donnees");
					__fin = TRUE;
					break;
				}
				i -= l;
				ptr += l;
			}
			break;
		}
		if (_msg_table[m].ReqName[0] == 0)
		{
			printf ("Reception commande %4.4s(%d) inconue\n", msgh.ReqName, msgh.Version);
			send (sock_communication, "Commande inconnue, deconnexion\n", 31, 0);
			__fin = TRUE;
		}
	}
	send (sock_communication, "DISC", 4, 0);
	send (sock_communication, "\n", 1, 0);

	if (_netbuff != NULL)
		free (_netbuff);
	if (_databuffin != NULL)
		free (_databuffin);
	if (_databuffout != NULL)
		free (_databuffout);
	_netbuff = NULL;
	_databuffin = NULL;
	_databuffout = NULL;

#ifdef DEBUG
	trace ("Processus_serveur point 99");
#endif
	return 0;
}

void _terminer (struct msg_info * msg, union msg_param param)
{
	__fin = TRUE;
}

thanks for any help
i m stuck with this problem since two days , and don't know what to do

Last edited by mumuri; 04-14-2010 at 04:16 AM..
# 2  
Old 04-13-2010
Could you please point out which line is line 533 in "transf.c", that is where the crash is happening.
# 3  
Old 04-14-2010
it's this line
Code:
 fprintf ( fp,"%s", "test" )


Last edited by Yogesh Sawant; 04-19-2010 at 04:34 PM.. Reason: added code tags
# 4  
Old 04-19-2010
Check to make sure fp is not NULL before writing to it.
# 5  
Old 04-20-2010
it's already done Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Signal SEGV (no mapping at the fault address) in _memcpy at 0xff0b07c0

Hi, I am unable to copy the cursor value into character variable which is defined in nested structure by pointer. typedef struct aaa { unsigned char device_type; unsigned char encrypt; unsigned short rec_len; } ABC; typedef ABC *Pabc; typedef struct def { ABC... (9 Replies)
Discussion started by: gthangav
9 Replies

2. Shell Programming and Scripting

Creating unique mapping from multiple mapping

Hello, I do not know if this is the right title to use. I have a large dictionary database which has the following structure: where a b c d e are in English and p q r s t are in a target language., the two separated by the delimiter =. What I am looking for is a perl script which will take... (5 Replies)
Discussion started by: gimley
5 Replies

3. Red Hat

Help needed 'Segv'

Red Hat Enterprise 4.5 (32 bit) In strace we see "unexpected reloc type 0x38" What does that code 0x38 mean? mprotect(0x59a000, 42229760, PROT_READ|PROT_WRITE) = 0 writev(2, unexpected reloc type 0x38", 26}, {"", 0}, {"", 0}, {"\n", 1}], 1 0) = 113 exit_group(127) ... (6 Replies)
Discussion started by: Sunusernewbie
6 Replies

4. UNIX for Dummies Questions & Answers

Help with HUP and SEGV.

Hello - I need to know the detail of HUP and SEGV. I know HUP is Hangup and can be use to kill a Unix login session remotely by sending a hangup signal to the process running the login session. Could someone tell me in detail prupose of HUP and SEGV (segmentation violation)? I need to... (1 Reply)
Discussion started by: namasteall2000
1 Replies

5. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

6. Programming

segmantation Fault error SEGV_MAPERR - Address not mapped to object

Program received signal SIGSEGV, Segmentation fault si_code: 1 - SEGV_MAPERR - Address not mapped to object. 0x9fffffffbe7080d0:0 in free+0xb0 () from /usr/lib/hpux64/libc.so.1 Hi , I have developed a class to read config file (flat file with space as a field seperator ) on plattform... (3 Replies)
Discussion started by: pravinbhingare
3 Replies

7. UNIX for Dummies Questions & Answers

signal SEGV (no mapping at the fault address) in _malloc_unlocked at 0xfe1d44ac

When i run a program in sun solaris i got core dumped with an error message as follows... signal SEGV (no mapping at the fault address) in _malloc_unlocked at 0xfe1d44ac 0xfe1d44ac: _malloc_unlocked+0x022c: ld , %o3 Current function is GetEDBInfo 360 EXEC SQL (dbx) where... (1 Reply)
Discussion started by: noufal
1 Replies

8. Programming

Program received signal SIGSEGV, Segmentation fault.

Dear all, I used debugger from C++ and these are the message I got: Program received signal SIGSEGV, Segmentation fault. 0x00323fc0 in free () from /lib/tls/libc.so.6 (gdb) info s #0 0x00323fc0 in free () from /lib/tls/libc.so.6 #1 0x00794fa1 in operator delete () from... (5 Replies)
Discussion started by: napapanbkk
5 Replies
Login or Register to Ask a Question