Facing issue of error (Segmentation fault ) signal 11 while running my application

Hi,

I have created one project application with multi thread and timer in mangoh red (WP8548 module).

My application get stop by giving error as segmentation fault. it is failing after running some time .

In debug , thread 1 is showing segmentation fault. screen shot is attached herewith.

I was tried to trace memory address 0X475e88c4 and 0Xb6e93df4 but could not find option on developer studio to track it in my code.

I want to know where exactly this 2 address pointing in my code .

log file attached herewith : MangOH_Red_logs_file.log (1.9 MB)

Kindly give me some guideline or solution for this error, I have stuck to it .

Hi,

Along with above error, also noticed error of “modemDaemon segmentation fault signal 11” when I commented some code .
I am using modem service apis : le_sim, le_mdc, le_mrc, le_adc etc
and
using dataConnectService for data connection in my project.

my error logs are as follows:

cellNetService[516]/framework T=main | LE_FILENAME ClientSocketHangUp() 852 | Session closed by server (cellNetService.cellNetService.le_sim:5003e8cf806c2137854dd150a6a8b2ff). Mar 28 13:09:06 | tr300[2919]/framework T=main | LE_FILENAME ClientSocketHangUp() 852 | Session closed by server (tr300.TR300Component.le_sim:5003e8cf806c2137854dd150a6a8b2ff). Mar 28 13:09:06 | INFO | tr300[2919] | gnss_enable failed -14 Mar 28 13:09:06 | dcsDaemon[517]/framework T=main | LE_FILENAME ClientSocketHangUp() 852 | Session closed by server (dcsDaemon.dataConnectionService.le_mdc:f51d46d0916e8217f8268ebd7f42baa0). Mar 28 13:09:06 | tr300[2919]/framework T=Sim Check | le_mrc_client.c le_mrc_GetNextCellularNetworkScan() 3094 | Valid response was not received from server Mar 28 13:09:06 | supervisor[467]/supervisor T=main | proc.c proc_SigChildHandler() 1956 | Process 'modemDaemon' (PID: 520) has exited due to signal 11 (Segmentation fault). Mar 28 13:09:06 | _appStopClient[12939]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2! Mar 28 13:09:06 | supervisor[467]/supervisor T=main | app.c app_SigChildHandler() 3227 | Process 'modemDaemon' in app 'modemService' faulted: Restarting process. Mar 28 13:09:06 | _appStopClient[12956]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2! Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | proc.c proc_Start() 1190 | Starting process 'modemDaemon' with pid 12955 Mar 28 13:09:06 | supervisor[467]/supervisor T=main | proc.c proc_SigChildHandler() 1942 | Process 'cellNetService' (PID: 516) has exited with exit code 1. Mar 28 13:09:06 | supervisor[12955]/supervisor T=main | proc.c proc_Start() 1155 | Execing 'modemDaemon' Mar 28 13:09:06 | supervisor[467]/supervisor T=main | app.c app_SigChildHandler() 3227 | Process 'cellNetService' in app 'cellNetService' faulted: Restarting process. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | proc.c proc_Start() 1190 | Starting process 'cellNetService' with pid 12971 Mar 28 13:09:06 | supervisor[12971]/supervisor T=main | proc.c proc_Start() 1155 | Execing 'cellNetService' Mar 28 13:09:06 | wifiService[524]/daemon T=main | le_wifiClient.c CloseSessionEventHandler() 414 | sessionRef 0x27dcc GetFirstSessionRef (nil) Mar 28 13:09:06 | wifiService[524]/framework T=main | le_wifiClient_server.c CleanupClientData() 195 | Client 0x27dcc is closed !!! Mar 28 13:09:06 | supervisor[467]/supervisor T=main | proc.c proc_SigChildHandler() 1942 | Process 'dcsDaemon' (PID: 517) has exited with exit code 1. Mar 28 13:09:06 | _appStopClient[12972]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2! Mar 28 13:09:06 | powerManagerService[522]/powerMgr T=main | le_pm.c OnClientConnect() 173 | Connection from client pid = 12955. Mar 28 13:09:06 | modemDaemon[12955]/le_pa T=main | pa_qmi.c _le_pa_COMPONENT_INIT() 66 | Start the QMI PA initialization. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | app.c app_SigChildHandler() 3227 | Process 'dcsDaemon' in app 'dataConnectionService' faulted: Restarting process. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100. Mar 28 13:09:06 | supervisor[467]/supervisor T=main | proc.c proc_Start() 1190 | Starting process 'dcsDaemon' with pid 12987 Mar 28 13:09:06 | supervisor[12987]/supervisor T=main | proc.c proc_Start() 1155 | Execing 'dcsDaemon' Mar 28 13:09:06 | modemDaemon[12955]/swiQmi T=main | swiQmi.c InitService() 367 | Init QMI service QMI_SERVICE_NAS (0) Mar 28 13:09:06 | modemDaemon[12955]/swiQmi T=main | swiQmi.c PrintServiceDetails() 343 | Service.0: library_version.6 idl_version.1 service_id.0x3 idl_minor_version.143 Mar 28 13:09:07 | modemDaemon[12955]/swiQmi T=main | swiQmi.c StartService() 107 | qmi_client_get_service_list rc=0, numServices=1 Mar 28 13:09:07 | gpioService[519]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionCloseHandlerFunc() 1107 | Releasing GPIO 22 Mar 28 13:09:07 | gpioService[519]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionCloseHandlerFunc() 1107 | Releasing GPIO 23 Mar 28 13:09:07 | supervisor[467]/supervisor T=main | proc.c proc_SigChildHandler() 1942 | Process 'tr300' (PID: 2919) has exited with exit code 1. Mar 28 13:09:07 | supervisor[467]/supervisor T=main | proc.c GetFaultAction() 1744 | No fault action specified for process 'tr300'. Assuming 'ignore'. Mar 28 13:09:07 | gpioService[519]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionCloseHandlerFunc() 1107 | Releasing GPIO 24 Mar 28 13:09:07 | supervisor[467]/supervisor T=main | app.c app_SigChildHandler() 3221 | Process 'tr300' in app 'TR300' faulted: Ignored. Mar 28 13:09:07 | _appStopClient[12993]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2! Mar 28 13:09:07 | supervisor[467]/supervisor T=main | apps.c DeactivateAppContainer() 340 | Application 'TR300' has stopped.

why these internal services are getting failed and modemDaemon is getting segmentation error.

If any one aware of it, kindly reply.

Hey @rups,

I’m definitely not an expert in this area (especially multi threaded programming), so this may be inaccurate, but based on your logs, it looks to me like you’re running out of memory. Next time you’re running your app, have a look at the current memory usage by invoking cat /proc/meminfo from a remote terminal session (SSH).

I’m curious: what problem are you trying to solve with multithreading? I’ve had really good luck handling concurrency using Legato IPC so I definitely recommend this approach.

Cheers!

Thank you nick for your reply.

I will check memory usage with command mention by you.

I have not used Legato IPC before and done multi threading in different platform project. so using same here too.

In 2nd reply I have added logs which is giving me “modemDaemon” error as segmentation fault. and that service get stopped.
is it different from memory issue or problem in using these services ?
because now I got “posDaemon” service error as signal 9 (killed) which was used in positioning Service to get GPS location.

if you know about it, kindly guide

I’m not sure what is the source of the segfault in the tr300 process. Can you explain why you need two threads in this process?

Hey @rups,

The only time I’ve been core services segfault is when the machine runs out of memory (which is why I think you may be running out of memory). We saw this happen when recording too much data without pushing it out using the le_avdata API.

If you’re at all curious about solving concurrency problems using IPC, checkout some of the examples in the Legato source. I found there were a few specifics not mentioned in the docs that I had to sort of figure out on my own (most notably when you define an array argument in a .api file you implicitly get a size pointer directly after it), so if you’re having issues let me know and I can post some more complex sample code.

Cheers!

Hi dfrey

In application, onr is main thread and another thread I am using for data send and receive process.
I am running timer and some interval time I am sending some data to server using that 2nd thread . To separate this socket method, I have used this thread.
I have removed all unwanted loops or thread which was initially started.
and
Initiated handlers in main thread for services like GPS service , SMS service, Data connect service, le_mrc for network registration and le_sim for sim registration checking .

signal 11 error is now resolved.
Now Application get stopped when “posDaemon” service get killed with error “signal 9” at api call “le_gnss_GetLocation()”.
Error logs as below:

Mar 30 17:37:33 | tr300_290318[18222]/framework T=main | le_gnss_client.c le_gnss_GetPositionState() 1837 | Sending message to server and waiting for response : 4 bytes sent Mar 30 17:37:33 | tr300_290318[18222]/TR300_290318Component T=main | GpsLocation.cpp posHandlerFunc() 52 | position state 2 Mar 30 17:37:33 | tr300_290318[18222]/framework T=main | le_gnss_client.c le_gnss_GetLocation() 1921 | Sending message to server and waiting for response : 4 bytes sent Mar 30 17:37:34 | tr300_290318[18222]/framework T=main | le_gnss_client.c le_gnss_GetLocation() 1924 | Valid response was not received from server Mar 30 17:37:34 | supervisor[468]/supervisor T=main | proc.c proc_SigChildHandler() 1956 | Process 'posDaemon' (PID: 8408) has exited due to signal 9 (Killed). Mar 30 17:37:35 | supervisor[468]/supervisor T=main | app.c app_SigChildHandler() 3227 | Process 'posDaemon' in app 'positioningService' faulted: Restarting process. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | proc.c proc_Start() 1190 | Starting process 'posDaemon' with pid 17590 Mar 30 17:37:35 | supervisor[17590]/supervisor T=main | proc.c proc_Start() 1155 | Execing 'posDaemon' Mar 30 17:37:35 | _appStopClient[17575]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2! Mar 30 17:37:35 | posDaemon[17590]/swiQmi T=main | swiQmi.c InitService() 367 | Init QMI service QMI_SERVICE_DMS (2) Mar 30 17:37:35 | posDaemon[17590]/swiQmi T=main | swiQmi.c PrintServiceDetails() 343 | Service.2: library_version.6 idl_version.1 service_id.0x2 idl_minor_version.35 Mar 30 17:37:35 | posDaemon[17590]/swiQmi T=main | swiQmi.c StartService() 107 | qmi_client_get_service_list rc=0, numServices=1 Mar 30 17:37:35 | dcsDaemon[517]/dataConnectionService T=main | dcsServer.c CloseSessionEventHandler() 2113 | Client 0x28a3c killed, remove allocated resources Mar 30 17:37:35 | gpioService[519]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionCloseHandlerFunc() 1107 | Releasing GPIO 22 Mar 30 17:37:35 | supervisor[468]/supervisor T=main | proc.c proc_SigChildHandler() 1942 | Process 'tr300_290318' (PID: 18222) has exited with exit code 1. Mar 30 17:37:35 | supervisor[468]/supervisor T=main | proc.c GetFaultAction() 1744 | No fault action specified for process 'tr300_290318'. Assuming 'ignore'. Mar 30 17:37:35 | modemDaemon[520]/modemDaemon T=main | le_antenna.c le_antenna_RemoveStatusEventHandler() 376 | Invalid reference ((nil)) provided! Mar 30 17:37:35 | gpioService[519]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionCloseHandlerFunc() 1107 | Releasing GPIO 23 Mar 30 17:37:35 | gpioService[519]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionCloseHandlerFunc() 1107 | Releasing GPIO 24 Mar 30 17:37:35 | dcsDaemon[517]/dataConnectionService T=main | dcsServer.c SetDefaultGateway() 1010 | Default gateway or interface is empty Mar 30 17:37:35 | supervisor[468]/supervisor T=main | app.c app_SigChildHandler() 3221 | Process 'tr300_290318' in app 'TR300_290318' faulted: Ignored. Mar 30 17:37:35 | _appStopClient[17598]/framework T=main | LE_FILENAME CreateSocket() 550 | Socket opened as standard i/o file descriptor 2! Mar 30 17:37:35 | supervisor[468]/supervisor T=main | apps.c DeactivateAppContainer() 340 | Application 'TR300_290318' has stopped.

`
My code snippet :

void GpsLocation::posHandlerFunc(le_gnss_SampleRef_t positionSampleRef,
void* contextPtr) {
le_result_t res;

le_gnss_FixState_t state;

res = le_gnss_GetPositionState(positionSampleRef, &state);

if (res == LE_OK) {
	LE_INFO("\n position state %d", state);
	if (state != LE_GNSS_STATE_FIX_NO_POS) {
		GpsFixed = 1;
	} else {
		GpsFixed = 0;
	}
} else {
	LE_INFO("FAILED pos state");
}


if(GpsFixed == 1)
{
int32_t lat = 0;
int32_t longi = 0;
int32_t acc = 0;

memset(latitude, '\0', sizeof(latitude));
memset(longitude, '\0', sizeof(longitude));

res = le_gnss_GetLocation(positionSampleRef, &lat, &longi, &acc);

if (res == LE_OK) {

	LE_INFO("\n location: latitude = %d,   longitude = %d,   accuracy = %d",
			lat, longi, acc);

	char latArray[10];
	char longiArray[11];

	sprintf(latArray, "%0.6f", (float) lat / 1000000);
	sprintf(longiArray, "%0.6f", (float) longi / 1000000);

	LE_INFO("lattitude latArray  %s ", latArray);
	LE_INFO("longitude longiArray  %s ", longiArray);

	mOdometerCurrentValue = fOdometerCalculation(latArray, longiArray,
			PrevLatitude, PrevLongitude);

	mOdometerTotalVal += mOdometerCurrentValue;

	fsaveOdometerValueToFile();

	LE_INFO("\n now convert lat long in protocol standard");

	mOdometerCurrentValue = 0;

	LatLongConversion((const unsigned char*) latArray,
			(const unsigned char*) longiArray, (unsigned char*) latitude,
			(unsigned char*) longitude);

	LE_INFO("\nLat Long converted in defined format ");

	PrevLatitude[0] = latArray[0];
	PrevLatitude[1] = latArray[1];
	PrevLatitude[2] = latArray[2];

	PrevLongitude[0] = longiArray[0];
	PrevLongitude[1] = longiArray[1];
	PrevLongitude[2] = longiArray[2];

} else if (res == LE_FAULT) {
	LE_INFO("failed get location");
} else if (res == LE_OUT_OF_RANGE) {
	LE_INFO("out of range. set to int 32_max");
}

le_result_t result;

// Date parameters
uint16_t year;
uint16_t month;
uint16_t day;

// Time parameters
uint16_t hours;
uint16_t minutes;
uint16_t seconds;
uint16_t milliseconds;

int32_t altitude;
int32_t vAccuracy;

// Get UTC date
result = le_gnss_GetDate(positionSampleRef, &year, &month, &day);

if (result == LE_OK) {
	mYear = year;
	mMonth = month;
	mDay = day;
}

// Get UTC time
result = le_gnss_GetTime(positionSampleRef, &hours, &minutes, &seconds,
		&milliseconds);


// Display time/date format 13:45:30 2009-06-15
LE_INFO("\n %02d:%02d:%02d:%02d %d-%02d-%02d,", hours, minutes, seconds,
		milliseconds, year, month, day);

if (result == LE_OK) {
	mHour = hours;
	mMinutes = minutes;
	mSeconds = seconds;
	mMiliSeconds = milliseconds;
}

// Get altitude
result = le_gnss_GetAltitude(positionSampleRef, &altitude, &vAccuracy);

if (result == LE_OK) {
	LE_INFO("\n Altitude:%d, vAccuracy:%d", altitude / 1000,
			vAccuracy / 10);
	mAltitude = altitude / 1000;
} else {
	LE_INFO("\n Altitude unknown [%d,%d]", altitude, vAccuracy);
}

unsigned int speed = 0;
result = le_gnss_GetHorizontalSpeed(positionSampleRef, &speed, &mSpeedAcc);

if (result == LE_OK) {
	LE_INFO("\n speed %d ", speed);
	mSpeed = speed;
} else {
	LE_INFO("\n Speed unknown [%d,%d]", speed, mSpeedAcc);
}

uint32_t directn = 0;
uint32_t direcAcc = 0;
result = le_gnss_GetDirection(positionSampleRef, &directn, &direcAcc);

if (result == LE_OK) {
	LE_INFO("\n Direction %u ", directn);
	mDirection = directn;
} else {
	LE_INFO("\n Direction unknown ");
}

}

}

`

Can you look in to my code and give me reason of failing posdaemon service

Hi nick,
I have checked for sample you have suggested for IPC.
But I have almost completed my application and it will take more time to change flow of logic.

Can you give me sample code for complex application using IPC, as I need to get some data from one handler and use in another process. for example , I usually get all attributes of GPS (Lat, long, speed, date, time) and provide in another class file for usage.
so that I will try and practice for it.

I am facing service failure issue as I have just replied in detailed.
Can you help in this regards ?

Thank you!

Hey @rups,

I’ll get some sample code together for you. Have you checked the memory yet? Like I said, I’ve only ever see platform services fail when the device runs out of memory.

Hi nick,

I have checked memory with command “cat /proc/meminfo” .
while running application with Gps service and handler enabled , memFree and memAvailable values getting decrease constantly .

But When I stopped running Gps handler and service by disabling it in code, the memFree and memAvailable values not much decreased. it is little bit decreased and in between increased also. so not much fall in values.

My Gps handler code is already attached here in above replies.
By referring it, can you tell me , Why free memory values constantly decreases while running gps.
Please tell me reason if you know.

> root@swi-mdm9x15:/proc# cat meminfo 
> MemTotal:         151832 kB
> MemFree:           67760 kB
> MemAvailable:     107036 kB
> Buffers:           11196 kB
> Cached:            29776 kB
> SwapCached:            0 kB
> Active:            26608 kB
> Inactive:          30784 kB
> Active(anon):      18964 kB
> Inactive(anon):      376 kB
> Active(file):       7644 kB
> Inactive(file):    30408 kB
> Unevictable:           0 kB
> Mlocked:               0 kB
> HighTotal:             0 kB
> HighFree:              0 kB
> LowTotal:         151832 kB
> LowFree:           67760 kB
> SwapTotal:             0 kB
> SwapFree:              0 kB
> Dirty:                 0 kB
> Writeback:             0 kB
> AnonPages:         16432 kB
> Mapped:            11036 kB
> Shmem:              2920 kB
> Slab:              18488 kB
> SReclaimable:       7404 kB
> SUnreclaim:        11084 kB
> KernelStack:        1552 kB
> PageTables:         1508 kB
> NFS_Unstable:          0 kB
> Bounce:                0 kB
> WritebackTmp:          0 kB
> CommitLimit:       75916 kB
> Committed_AS:     631344 kB
> VmallocTotal:     770048 kB
> VmallocUsed:      306908 kB
> VmallocChunk:     371708 kB

Hey @rups,

My guess would be that your multithreaded code keeps forking, resulting in increased memory usage. If your memory usage is continuously increasing over time (without bound), this is likely the cause the of the segfault. To my knowledge, multithreaded programming requires a lot discipline and specialized knowledge to avoid bugs like this, so for that reason, I’ve avoided it in favour of inter process communication (IPC) programming (not to mention Legato strongly encourages this).

Inspecting your code, the thing that catches me eye is that latitude and longitude never seem to be declared. Are these global variables that are omitted from the sample?

I have written a small IPC GPS app at work. Let me see if my boss is comfortable open sourcing this. If not, I’ll extract a few snippets and put them in a GitHub repo.

Cheers!

Hey @rups,

My boss @coastalbrandon was cool with me sharing this, so here it is: https://github.com/brnkl/mangoh-gps-monitor.

Hopefully this is helpful!

Cheers!

1 Like

Hi Nick

Thank you so much for giving me sample code . Thanks to @coastalbrandon for your help.

I have implemented gps location code as per given by your sample code.
But still while executing “cat /proc/meminfo” , memAvailable get decreased almost 178000 to 69000 within time interval of 10 - 12 hrs

Can you tell me why this memAvailable get fall down continuously while executing application.
and
Currently I have kept only service handler such as simService handler, dataService handler, smsHandler, mrc service handler and Gps is added in timer as per your sample code.
Rest code is disabled.
Though memory consumption is increasing.

what exactly significance of memAvailable and memfree ?