Hi,
I am new to ace and using ace 5.6.6. Before trying to post on this mail I tried to find in the bug-archive whether this problem has already been reported, but I am not able to access bug-archive.
ACE_Log_Msg_NT_Event_Log log api crashes when ACE_Log_Record msg_data is set quit large (600 char). Has anybody seen this issue or let me know if this has been already reported?
Regards,
Gaurav
Hi,
There have been some bugs fixed when logging large strings, please upgrade to x.7.4
Johnny
Hi,
Can you make a new test, based on an existing test in ACE_wrappers/tests and then report this in bugzilla?
Johnny
From: Gaurav Kulshreshtha
[mailto:gaurav.ku...@onmobile.com]
Sent: donderdag 12 november 2009 15:06
To: jwill...@remedy.nl; ace-...@list.isis.vanderbilt.edu
Subject: RE: [ace-bugs] ACE_Log_Msg_NT_Event_Log not able log a large
string
I am still having the same issue in the latest ace.
Sample code attached.
Regards,
Gaurav
Hi,
Can I prepare a simple test, testing only my failing scenario or does it need to be exhaustive like other tests ?
Hi,
It should be a one button tests like everything under ACE-wrappers/tests, just one simple test that reproduces the bug.
Just as hint, I have tried your sample code with latest ace. Your code sample is bad, it miss to call open () on log, after opening it works.
Regards
Aleksandar V.
From: ace-bugs...@list.isis.vanderbilt.edu [mailto:ace-bugs...@list.isis.vanderbilt.edu]
On Behalf Of Gaurav Kulshreshtha
Sent: Thursday, November 12, 2009 15:06
To: jwill...@remedy.nl; ace-...@list.isis.vanderbilt.edu
Subject: Re: [ace-bugs] ACE_Log_Msg_NT_Event_Log not able log a large string
I am still having the same issue in the latest ace.
Sample code attached.
Regards,
Gaurav
From: Johnny Willemsen [mailto:jwill...@remedy.nl]
Sent: Wednesday, October 21, 2009 6:57 PM
To: Gaurav Kulshreshtha; ace-...@list.isis.vanderbilt.edu
Subject: RE: [ace-bugs] ACE_Log_Msg_NT_Event_Log not able log a large string
Hi,
There have been some bugs fixed when logging large strings, please upgrade to x.7.4
Johnny
From: ace-bugs...@list.isis.vanderbilt.edu [mailto:ace-bugs...@list.isis.vanderbilt.edu]
On Behalf Of Gaurav Kulshreshtha
Sent: woensdag 21 oktober 2009 10:21
To: ace-...@list.isis.vanderbilt.edu
Subject: [ace-bugs] ACE_Log_Msg_NT_Event_Log not able log a large string
Hi,
I am new to ace and using ace 5.6.6. Before trying to post on this mail I tried to find in the bug-archive whether this problem has already been reported, but I am not able to access bug-archive.
ACE_Log_Msg_NT_Event_Log log api crashes when ACE_Log_Record msg_data is set quit large (600 char). Has anybody seen this issue or let me know if this has been already reported?
Regards,
Gaurav
Hi Aleksandar,
I am aware that using the ACE_Log_Msg_NT_Event_Log without open will not work (sample code). I was only concerned about the logged string size in case of crash.
After debugging I found out what part of the code is causing the problem. Maximum size of a logged string is set as 192*2 (ACE_Log_Record::MAXLOGMSGLEN * 2).
ssize_t
ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record)
{
// Make a copy of the log text and replace any newlines with
// CR-LF. Newline characters on their own do not appear correctly in
// the event viewer. We allow for a doubling in the size of the msg
// data for the worst case of all newlines.
const ACE_TCHAR* src_msg_data = log_record.msg_data ();
ACE_TCHAR msg_data [ACE_Log_Record::MAXLOGMSGLEN * 2];
for (size_t i = 0, j = 0;
i < log_record.msg_data_len ();
++i)
{
if (src_msg_data[i] == '\n') (point where code is crashing , buffer overflow)
{
msg_data[j++] = '\r';
msg_data[j++] = '\n';
}
else
msg_data[j++] = src_msg_data[i];
}
Some code…..
}
If the log_record.msg_data () size is greater than 192*2 than there is buffer overflow.
Default msg_data size allocated from heap in the ACE_Log_Record is 192 but it can be increased if the new msg_data set size is larger.
int
ACE_Log_Record::msg_data (const ACE_TCHAR *data)
{
// ACE_TRACE ("ACE_Log_Record::msg_data");
size_t const newlen = ACE_OS::strlen (data) + 1; // Will need room for '\0'
if (newlen > this->msg_data_size_)
{
ACE_TCHAR *new_msg_data = 0;
ACE_NEW_RETURN (new_msg_data, ACE_TCHAR[newlen], -1);
delete [] this->msg_data_;
this->msg_data_ = new_msg_data;
this->msg_data_size_ = newlen;
}
ACE_OS::strcpy (this->msg_data_, data);
this->round_up ();
return 0;
}
Let me know what do you think.
Regards,
Gaurav
>I am aware that using the ACE_Log_Msg_NT_Event_Log without open will not wo=
>rk (sample code). I was only concerned about the logged string size in case=
> of crash.
>After debugging I found out what part of the code is causing the problem. M=
>aximum size of a logged string is set as 192*2 (ACE_Log_Record::MAXLOGMSGL=
>EN * 2).
>
>ssize_t
>ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record)
>{
> // Make a copy of the log text and replace any newlines with
> // CR-LF. Newline characters on their own do not appear correctly in
> // the event viewer. We allow for a doubling in the size of the msg
> // data for the worst case of all newlines.
> const ACE_TCHAR* src_msg_data =3D log_record.msg_data ();
> ACE_TCHAR msg_data [ACE_Log_Record::MAXLOGMSGLEN * 2];
>
> for (size_t i =3D 0, j =3D 0;
> i < log_record.msg_data_len ();
> ++i)
> {
> if (src_msg_data[i] =3D=3D '\n') (point where code is crashing , b=
>uffer overflow)
> {
> msg_data[j++] =3D '\r';
> msg_data[j++] =3D '\n';
> }
> else
> msg_data[j++] =3D src_msg_data[i];
> }
>
> Some code.....
>
>}
>
>If the log_record.msg_data () size is greater than 192*2 than there is buff=
>er overflow.
Yikes!
>Default msg_data size allocated from heap in the ACE_Log_Record is 192 but =
>it can be increased if the new msg_data set size is larger.
>
>int
>ACE_Log_Record::msg_data (const ACE_TCHAR *data)
>{
> // ACE_TRACE ("ACE_Log_Record::msg_data");
> size_t const newlen =3D ACE_OS::strlen (data) + 1; // Will need room for=
> '\0'
> if (newlen > this->msg_data_size_)
> {
> ACE_TCHAR *new_msg_data =3D 0;
> ACE_NEW_RETURN (new_msg_data, ACE_TCHAR[newlen], -1);
> delete [] this->msg_data_;
> this->msg_data_ =3D new_msg_data;
> this->msg_data_size_ =3D newlen;
> }
> ACE_OS::strcpy (this->msg_data_, data);
> this->round_up ();
> return 0;
>}
>
>Let me know what do you think.
It looks to me like we need to do something similar in
ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record), i.e.,
(re)allocate msg_data accordingly. Could you please take a shot at
doing this and let us know how it goes?
Thanks,
Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Vanderbilt University WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203 NET: d.sc...@vanderbilt.edu
Hi Douglas,
I have rebuilt ace with the following 2 changes:
1. Changed the value ACE_MAXLOGMSGLEN in config.h from 192 to 192*4 (can't have default 1024*4 for performance reasons)
2. Changed the ACE_Log_Msg_NT_Event_Log::log implementation to take care of msg_data size (in case it is greater than ACE_Log_Record::MAXLOGMSGLEN).
ssize_t
ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record)
{
const ACE_TCHAR* src_msg_data = log_record.msg_data ();
ACE_TCHAR msg_data [(ACE_Log_Record::MAXLOGMSGLEN * 2)+1];
size_t k=ACE_Log_Record::MAXLOGMSGLEN ;
if(ACE_Log_Record::MAXLOGMSGLEN > log_record.msg_data_len () )
k=log_record.msg_data_len ();
size_t p=0;
for (size_t i = 0, j = 0;
i < k;
++i)
{
if (src_msg_data[i] == '\n')
{
msg_data[j++] = '\r';
msg_data[j++] = '\n';
}
else
msg_data[j++] = src_msg_data[i];
p=j;
}
msg_data[p]='\0';
same old code....
}
It works fine for all the strings length.
Regards,
Gaurav
-----Original Message-----
From: Douglas C. Schmidt [mailto:sch...@dre.vanderbilt.edu]
Sent: Wednesday, November 18, 2009 8:14 PM
To: Gaurav Kulshreshtha; ace-...@cse.wustl.edu; ch...@kohlhoff.com
Subject: Re: [ace-bugs] ACE_Log_Msg_NT_Event_Log not able log a large string
Hi Gaurav,
Yikes!
Thanks,
Doug
------neXtPaRt_1258625903
Content-Type: text/plain;
DISCLAIMER: The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. Please immediately contact the sender if you have received this message in error. Further, this e-mail may contain viruses and all reasonable precaution to minimize the risk arising there from is taken by OnMobile. OnMobile is not liable for any damage sustained by you as a result of any virus in this e-mail. All applicable virus checks should be carried out by you before opening this e-mail or any attachment thereto.
Thank you - OnMobile Global Limited.
------neXtPaRt_1258625903--
> I have rebuilt ace with the following 2 changes:
>
> 1. Changed the value ACE_MAXLOGMSGLEN in config.h from 192 to 192*4 (can't have default 1024*4 for performance reasons)
> 2. Changed the ACE_Log_Msg_NT_Event_Log::log implementation to take care of msg_data size (in case it is greater than ACE_Log_Record::MAXLOGMSGLEN).
>
> ssize_t
> ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record)
> {
>
> const ACE_TCHAR* src_msg_data = log_record.msg_data ();
> ACE_TCHAR msg_data [(ACE_Log_Record::MAXLOGMSGLEN * 2)+1];
>
> size_t k=ACE_Log_Record::MAXLOGMSGLEN ;
> if(ACE_Log_Record::MAXLOGMSGLEN > log_record.msg_data_len () )
> k=log_record.msg_data_len ();
>
> size_t p=0;
> for (size_t i = 0, j = 0;
> i < k;
> ++i)
> {
> if (src_msg_data[i] == '\n')
> {
> msg_data[j++] = '\r';
> msg_data[j++] = '\n';
> }
> else
> msg_data[j++] = src_msg_data[i];
>
> p=j;
> }
> msg_data[p]='\0';
>
> same old code....
>
> }
>
> It works fine for all the strings length.
Great, thanks! I changed some of the variable names. Please see
http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/ace/Log_Msg_NT_Event_Log.cpp
and let me know if this still works for you.
Thanks,
Doug