This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/757: gcc gets a seg. fault after a ~parse error before 'if'~ error.



>Number:         757
>Category:       c++
>Synopsis:       gcc gets a seg. fault after a ~parse error before 'if'~ error.
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 09 07:46:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     overholt@thinkhost.com
>Release:        2.96 20000731
>Organization:
>Environment:
Redhat 7.0
>Description:
When trying to compile this (Seemingly) correct code, my gcc gives me the following error:

module.cpp In function MakeRequest (char *):
module.cpp:96: parse error before ~if~
module.cpp:94: Internal error: Segmentation fault.

I'm not sure why it's doing this, or why it's having any trouble at all.  The code here is nearly identical to another function I use which has no problems.

>How-To-Repeat:
Not too sure, but all you should have to do is
gcc module.cpp -c
That's all I did...
>Fix:
Don't know of one
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="Module.cpp"
Content-Disposition: inline; filename="Module.cpp"

/* Module.cpp
Module support for CreditCart */

#include <dlfcn.h>
#include "main.h"

extern struct tagMain Main;

#if defined(USING_WINDOWS) || defined(USING_WINDOWS_MSVC)

HINSTANCE LoadLib(char * szLibName)
{
	return LoadLibrary(szLibName);
}

int FreeLib(HMODULE lpLib)
{
	return FreeLibrary(lpLib);
}

void * FindFunc(HMODULE lpLib, char * lpszSymbolName)
{
	return (void *)GetProcAddress(lpLib, lpszSymbolName);
}

#elif defined(USING_LINUX)

void * LoadLib(char * szLibName)
{
	return dlopen(szLibName, RTLD_NOW | RTLD_GLOBAL);
}

int FreeLib(void * lpLib)
{
	dlclose(lpLib);
	return true;
}

void * FindFunc(void * lpLib, char * lpszSymbolName)
{
	return dlsym(lpLib, lpszSymbolName);
}

#endif

int MakeRequest(char * lpszRequest)
{
	ModuleReqFunc ReqHandler;
	char szHandler[128];
	char szSymbol[128];
	memset(szHandler, 0, 128);
	memset(szSymbol, 0, 128);
	
	// Load config file and lookup request
	
	FILE * Conf = fopen("./mod.conf", "r+t");
	
	if (Conf != NULL)
	{
		char CatchAllLib[128];
		char CatchAllFunc[128];
		char szSection[128];
		char szBuffer[256];
		
		int GotMatch = false;
		
		do
		{
			memset(szBuffer, 0, 256);
			fgets(szBuffer, 256, Conf);
			
			if (szBuffer[0] == '[')
			{
				memset(szSection, 0, 128);
				strncpy(szSection, szBuffer + 1, strlen(szBuffer) - 2);
			}
			else if ((szBuffer[0] != '#') && (szBuffer[0] != 0))
			{
				char * szName = GetParmName(szBuffer);
				char * szValue = GetParmValue(szBuffer, true);
				
				if (!stricmpA(szSection, "CatchAll"))
				{
					if (!stricmpA(szName, "LibName"))		strcpy(CatchAllLib, szValue);
					else if (!stricmpA(szName, "FuncName"))	strcpy(CatchAllFunc, szValue);
				}
				else if (!stricmpA(szSection, lpszRequest))
				{
					if (!stricmpA(szName, "LibName"))		strcpy(szHandler, szValue);
					else if (!stricmpA(szName, "FuncName"))	strcpy(szSymbol, szValue);
					GotMatch = true;
				}
			}
		} while (!feof(Conf))
		
		if (!GotMatch)
		{
			strcpy(szHandler, CatchAllLib);
			strcpy(szSymbol, CatchAllFunc);
		}
		
		fclose(Conf);
	}
	
	strcat(szSymbol, "__FP12_RequestDataP8_EnvData");
	
	void * Lib = LoadLib(szHandler);
	ReqHandler = (ModuleReqFunc)FindFunc(Lib, szSymbol);
	
	tagRequestData ReqData;
	ReqData.MySQL = &Main.MySQL;
	strcpy(ReqData.szRequest, lpszRequest);
	ReqData.MakeRequest = MakeRequest;
	
	int ret = ReqHandler(&ReqData, &Main.Env);
	
	FreeLib(Lib);
	
	return ret;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]