Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi All,

We have developed an application with huawei C5300 phone. We have generated the mod file and it is running properly on the device.

Now, when we change the .h file variables .i.e. add/change the variables and generate the mod file and load it on the device, the device displays "Application Error- Memory Access " and restarts.

Has anyone faced this problem while programming for Huawei C5300 phone.. or any other phone...

Any suggestions will help ...

Thanks in advance.

Weird, Please try a clean build.
-Karthik

Weird, Please try a clean build.
-Karthik

Ya... problem seems weird.
Now , We came to know that application does not allow addition of variable in structure defined.
Structure used was as follows :-
typedef struct _UpdateDetails
{
char szAppState[40];
short szCountRecords;
char m_ContractNo[10][31];
char m_TransID[10][21];
char m_PTPDate[10][13];
char m_PTPTime[10][20];
char m_ChangeAdd[10][256];
char m_ChangeMob[10][16];
char m_ChangePh1[10][16];
char m_ChangePh2[10][16];
char m_PayMode[10][2];
char m_AmountPaid[10][19];
char m_InstrumentNo[10][17];
char m_DrawnOnBank[10][16];
char m_InstruDate[10][12];
char m_PDCAmount[10][19];
char m_PDCNoofChq[10][4];
char m_PDCDate[10][13];
char m_flg_RCStatus[10][2];
char m_BrokenPTPRemarks[10][256];
char m_ReceiptNo[10][21];
char m_ReceiptDate[10][21];
char m_ActionSaved[10][7];
char m_ListType[10][2];
int32 StartTime;
}UpdateDetails;
Now, If we add 1 new variable in this structure, the application crashes.
Any idea, what is the max size of the structure?
Or limitation of structure?

Ya... problem seems weird.
Now , We came to know that application does not allow addition of variable in structure defined.
Structure used was as follows :-
typedef struct _UpdateDetails
{
char szAppState[40];
short szCountRecords;
char m_ContractNo[10][31];
char m_TransID[10][21];
char m_PTPDate[10][13];
char m_PTPTime[10][20];
char m_ChangeAdd[10][256];
char m_ChangeMob[10][16];
char m_ChangePh1[10][16];
char m_ChangePh2[10][16];
char m_PayMode[10][2];
char m_AmountPaid[10][19];
char m_InstrumentNo[10][17];
char m_DrawnOnBank[10][16];
char m_InstruDate[10][12];
char m_PDCAmount[10][19];
char m_PDCNoofChq[10][4];
char m_PDCDate[10][13];
char m_flg_RCStatus[10][2];
char m_BrokenPTPRemarks[10][256];
char m_ReceiptNo[10][21];
char m_ReceiptDate[10][21];
char m_ActionSaved[10][7];
char m_ListType[10][2];
int32 StartTime;
}UpdateDetails;
Now, If we add 1 new variable in this structure, the application crashes.
Any idea, what is the max size of the structure?
Or limitation of structure?

If a clean build doesn't solve the problem. You can try arranging the structure variables so that least memory is wasted in the padding.
Please declare the struct members in the below order.
struct{
//All pointeres/Arrays/Struct's declaration
//All integer/4 byte variable declaration
//All short/2 byte variable declaration
//All char/1 byte variable declaration

In your case move the short szCountRecords; to the end of the structure. Also the structure seems quite big, hope you are checking NULL pointer after MALLOC.
-Karthik

If a clean build doesn't solve the problem. You can try arranging the structure variables so that least memory is wasted in the padding.
Please declare the struct members in the below order.
struct{
//All pointeres/Arrays/Struct's declaration
//All integer/4 byte variable declaration
//All short/2 byte variable declaration
//All char/1 byte variable declaration

In your case move the short szCountRecords; to the end of the structure. Also the structure seems quite big, hope you are checking NULL pointer after MALLOC.
-Karthik

structure size is big, i think in ur case use of list in place of arrays would be help full or make ur array as like da folllowing
char*egarray[n];//n represents index how much u req.

structure size is big, i think in ur case use of list in place of arrays would be help full or make ur array as like da folllowing
char*egarray[n];//n represents index how much u req.

This structure is not suited for an embedded system application :eek: :rolleyes: ..The size is too big and elements are not arranged properly for alignment. :rolleyes: For instance, there are lots of 2d char arrays of large sizes(also odd sizes like 31)
I assume that the code was written long time back and you are now trying to modify something for enhancement!!! Now it will be very very risky to change all 2d arrays to pointers!!! :mad:
I feel that some where, the size of this structure is used to some kind of manipulation or some operations might be based on the size of structure.. :confused: :confused: But it will be very difficult to debug unless one is in that fire bowl!!! :D :D

This structure is not suited for an embedded system application :eek: :rolleyes: ..The size is too big and elements are not arranged properly for alignment. :rolleyes: For instance, there are lots of 2d char arrays of large sizes(also odd sizes like 31)
I assume that the code was written long time back and you are now trying to modify something for enhancement!!! Now it will be very very risky to change all 2d arrays to pointers!!! :mad:
I feel that some where, the size of this structure is used to some kind of manipulation or some operations might be based on the size of structure.. :confused: :confused: But it will be very difficult to debug unless one is in that fire bowl!!! :D :D

Alright, thanks for the replies..
But since now I want to use all the 2D variables as mentioned in the structure, ..
Can any one suggest what can i use instead of structures?
Or what is the optimized way of defining such huge amount of variables apart from structure declaration..

Alright, thanks for the replies..
But since now I want to use all the 2D variables as mentioned in the structure, ..
Can any one suggest what can i use instead of structures?
Or what is the optimized way of defining such huge amount of variables apart from structure declaration..

mk.manju wrote:structure size is big, i think in ur case use of list in place of arrays would be help full or make ur array as like da folllowing
char*egarray[n];//n represents index how much u req.
use list or use 2 dimensional arrays itself in ur srtructure by allocating memory dynamically to those arrays as shown
char* egarray[10];
egarray[n]= Malloc//n ranges from 0 to 9;
the above will help u to reduce da size of structure

mk.manju wrote:structure size is big, i think in ur case use of list in place of arrays would be help full or make ur array as like da folllowing
char*egarray[n];//n represents index how much u req.
use list or use 2 dimensional arrays itself in ur srtructure by allocating memory dynamically to those arrays as shown
char* egarray[10];
egarray[n]= Malloc//n ranges from 0 to 9;
the above will help u to reduce da size of structure

shahmiki wrote:Now, If we add 1 new variable in this structure, the application crashes.
Any idea, what is the max size of the structure?
Or limitation of structure?
Instead of manipulating the structure why dont u put the new data in some other structure and provide those along with this structure during update of file or db???This way u can avoid the unnecessary trouble of all the above issues :rolleyes:

shahmiki wrote:Now, If we add 1 new variable in this structure, the application crashes.
Any idea, what is the max size of the structure?
Or limitation of structure?
Instead of manipulating the structure why dont u put the new data in some other structure and provide those along with this structure during update of file or db???This way u can avoid the unnecessary trouble of all the above issues :rolleyes:

Oceans eleven wrote:Instead of manipulating the structure why dont u put the new data in some other structure and provide those along with this structure during update of file or db???This way u can avoid the unnecessary trouble of all the above issues :rolleyes:
I tried adding the variable in a different structure, but it was of no use.
Application still crashed.
Some kind of memory corruption is there I guess..
Can u guys tell me how to figure out how much memory(heap) is available currently on the device? If I can check that.. then i ll understand whether it is memory issue or not ..
Thanks in advance.
- shahmiki

Oceans eleven wrote:Instead of manipulating the structure why dont u put the new data in some other structure and provide those along with this structure during update of file or db???This way u can avoid the unnecessary trouble of all the above issues :rolleyes:
I tried adding the variable in a different structure, but it was of no use.
Application still crashed.
Some kind of memory corruption is there I guess..
Can u guys tell me how to figure out how much memory(heap) is available currently on the device? If I can check that.. then i ll understand whether it is memory issue or not ..
Thanks in advance.
- shahmiki

The structure seems to be very hard on the memory usage. What is size of the structure - ie., sizeof(that-structure);
Check out whether the size is the reason by increasing the dimension of an existing member. like
char m_ContractNo[10][31];
to something like
char m_ContractNo[20][31];
shahmiki wrote:
I tried adding the variable in a different structure, but it was of no use.
Application still crashed.
Is this structure added to the applet structure? If so try making it as a pointer to that structure and dynamically allocate it. Because the size of the applet structure is limited.
Hope this helps

The structure seems to be very hard on the memory usage. What is size of the structure - ie., sizeof(that-structure);
Check out whether the size is the reason by increasing the dimension of an existing member. like
char m_ContractNo[10][31];
to something like
char m_ContractNo[20][31];
shahmiki wrote:
I tried adding the variable in a different structure, but it was of no use.
Application still crashed.
Is this structure added to the applet structure? If so try making it as a pointer to that structure and dynamically allocate it. Because the size of the applet structure is limited.
Hope this helps

It very likely that you are overwriting memory. Please check the array initialization if you are overwriting memory and if you are doing any unaligned memory access.
If you are using visual studio 2005 you can using the MSVC's 4 byte alignment feature and data break point to figure out the problem.

It very likely that you are overwriting memory. Please check the array initialization if you are overwriting memory and if you are doing any unaligned memory access.
If you are using visual studio 2005 you can using the MSVC's 4 byte alignment feature and data break point to figure out the problem.

Yipee !!! , Issue resolved.
I created a new workspace.
Made a new project.
Added all my concerned files in this new project. And additional variables required in this new project application. And my application started woking on the device...
- shahmiki

Yipee !!! , Issue resolved.
I created a new workspace.
Made a new project.
Added all my concerned files in this new project. And additional variables required in this new project application. And my application started woking on the device...
- shahmiki

I am facing the same problem. Even my application is not running even once on this Huwaei 5300..pls post some helpful thread

I am facing the same problem. Even my application is not running even once on this Huwaei 5300..pls post some helpful thread

Mke new workspace for ur application.
Add the concerned .h and .c files.
Then compile and rebuild your applicaiton with this new workspace and check on the device.
Mostly it should solve your problem.

Mke new workspace for ur application.
Add the concerned .h and .c files.
Then compile and rebuild your applicaiton with this new workspace and check on the device.
Mostly it should solve your problem.

R u trying to fill an array or string so that it increases size of destination by it original size.

R u trying to fill an array or string so that it increases size of destination by it original size.

Check available memory before initializing your new member variable and after initializing the new member variable. May the the arrays goes out of memory and its restart the phone.

Check available memory before initializing your new member variable and after initializing the new member variable. May the the arrays goes out of memory and its restart the phone.