Highlighted
Contributor.
Contributor.
260 views

C Interpreter memory access violation

Hi All,

I am using loadrunner 11(web protocol) .am executing with 100 users and users are coming out after 10 minutes  of execution due to C interpreter run time error memory violation exception access_violation received.

am connecting mysql yog database to retreive test data for execution.

SQL yog uses only saving test data.mmdrv memory also increasing at same time.am not using any c code in my script.my script will retrieve test data from DB,processing request and saving into DB again.

 

0 Likes
2 Replies
Highlighted
Contributor.
Contributor.

Re: C Interpreter memory access violation

Sample and Supporting files details

dll files
*******
libmysql.dll

Header files
**********
Ptt_MySql
my_alloc
my_list
mysql
mysql_com
mysql_time
mysql_version
Ptt_MySql
typelib

Scripts
Global.h
#define MYSQLSERVER ""
#define MYSQLUSERNAME ""
#define MYSQLPASSWORD " "
#define MYSQLDB ""
#define MYSQLPORT ""

#endif // _GLOBALS_H
//char sqQuery[512]; // The MySQL query to be executed
MYSQL *Mconn; // The MySQL connection string
int MyRC; //

Initpart
lr_load_dll("libmySQL.dll");

Action part

lr_param_sprintf("sqQuery", "select * from *** where *** IS NULL LIMIT 1 FOR UPDATE");
 Mconn = lr_mysql_connect(MYSQLSERVER, MYSQLUSERNAME, MYSQLPASSWORD, MYSQLDB, atoi(MYSQLPORT));

isEmpty();

 lr_mysql_query(Mconn, "BEGIN");
 lr_mysql_query(Mconn, lr_eval_string ("{sqQuery}"));

 lr_save_string(row[0][0].cell,"***");
 lr_save_string(row[1][0].cell,"***");
 lr_save_string(row[2][0].cell,"***");

 lr_param_sprintf("sqQuery", "UPDATE ***.***SET ***_DataStat='%s_%s_%s' where ****='%s'",lr_eval_string("{p_Time}"),lr_eval_string("{p_Vuser}"),lr_eval_string("{p_Iteration}"),lr_eval_string("{*****_***}"));
isEmpty();

 lr_mysql_query(Mconn, lr_eval_string ("{sqQuery}"));
 lr_mysql_query(Mconn, "COMMIT");

 lr_param_sprintf("sqQuery","delete from ***.***where ****_DataStat is not null");
isEmpty();

 lr_mysql_query(Mconn, lr_eval_string ("{sqQuery}"));

 lr_mysql_query(Mconn, "COMMIT");
 lr_mysql_disconnect(Mconn);

After Scenario completion it will go saving into DB again


 Mconn = lr_mysql_connect(MYSQLSERVER, MYSQLUSERNAME, MYSQLPASSWORD, MYSQLDB, atoi(MYSQLPORT));
lr_param_sprintf("sqQuery", "INSERT INTO *** (A,B<C) VALUES ('%s','%s','%s')",lr_eval_string("{A}"),lr_eval_string("{B}"),lr_eval_string("{C}"));

isEmpty();

 lr_mysql_query(Mconn, "BEGIN");
    lr_mysql_query(Mconn, lr_eval_string ("{sqQuery}"));
 lr_mysql_query(Mconn, "COMMIT");

 lr_mysql_disconnect(Mconn);

 

 return 0;
}
isEmpty()
{

    if (Mconn==NULL)
    {
 lr_output_message ("Connection String empty");
 lr_vuser_status_message ("Iteration -- %s-- Stopped due to connection string null",lr_eval_string ("{p_Iteration}"));
 lr_exit (LR_EXIT_ITERATION_AND_CONTINUE,LR_STOP);
 }
 else
       { if(strlen(lr_eval_string("{sqQuery}"))==0)
   {
            lr_output_message ("Query String empty");
   lr_vuser_status_message ("Iteration -- %s-- Stopped due to Query string null",lr_eval_string ("{p_Iteration}"));
   lr_mysql_disconnect(Mconn);
            lr_exit (LR_EXIT_ITERATION_AND_CONTINUE,LR_STOP);
   }
  }

 return 0;
}

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: C Interpreter memory access violation

I found the library on the internet (Not sure if this is the most recent repository). Did a quick check: it looks like there is no protection for fiels that are longer then the allocated amount of space (99 chars) Ptt_MySql.h(96).

You might try to limit the allocation of resources from that library as much as possible:

- One connection per user: open it in vuser_init() and close it in vuser_end().

- Use prepared statements and reuse them (if possible).

- Note that all memory consumed by lr_evel_* functions are freed at the end of an iteration. Use global buffers to store data that needs to survive an iteration.

Signature:
Reward community members who take time to respond and help.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.