Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[ace-bugs] ACE_Log_Msg_NT_Event_Log not able log a large string

4 views
Skip to first unread message

Gaurav Kulshreshtha

unread,
Oct 21, 2009, 4:21:01 AM10/21/09
to ace-...@list.isis.vanderbilt.edu

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

Johnny Willemsen

unread,
Oct 21, 2009, 9:26:41 AM10/21/09
to Gaurav Kulshreshtha, ace-...@list.isis.vanderbilt.edu

Hi,

 

There have been some bugs fixed when logging large strings, please upgrade to x.7.4

 

Johnny

Johnny Willemsen

unread,
Nov 12, 2009, 9:07:44 AM11/12/09
to Gaurav Kulshreshtha, ace-...@list.isis.vanderbilt.edu

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

Gaurav Kulshreshtha

unread,
Nov 17, 2009, 7:21:22 AM11/17/09
to jwill...@remedy.nl, ace-...@list.isis.vanderbilt.edu

Hi,

Can I prepare a simple test, testing only my failing scenario or does it need to be exhaustive like other tests ?

Johnny Willemsen

unread,
Nov 17, 2009, 7:27:21 AM11/17/09
to Gaurav Kulshreshtha, ace-...@list.isis.vanderbilt.edu

Hi,

 

It should be a one button tests like everything under ACE-wrappers/tests, just one simple test that reproduces the bug.

Aleksandar Vukajlovic

unread,
Nov 17, 2009, 7:44:27 AM11/17/09
to Gaurav Kulshreshtha, ace-...@list.isis.vanderbilt.edu

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



Finsoft Ltd. Registered in England and Wales No. 3054588, 16-18 Hatton Garden, London, EC1N 8AT

The information in this E-mail is confidential. If you are not the intended recipient please notify the sender immediately and delete this E-mail without reading, using or disseminating the information contained in it. Although Finsoft Ltd believes this E-mail and any attachments are free of any virus or other defect which may affect a computer, it is the responsibility of the recipient to ensure that it is virus free and Finsoft Ltd does not accept any responsibility for any loss or damage arising in any way from its use.

Gaurav Kulshreshtha

unread,
Nov 18, 2009, 7:13:47 AM11/18/09
to Aleksandar Vukajlovic, jwill...@remedy.nl, ace-...@list.isis.vanderbilt.edu

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

Douglas C. Schmidt

unread,
Nov 18, 2009, 9:43:55 AM11/18/09
to gaurav.ku...@onmobile.com, ace-...@cse.wustl.edu, ch...@kohlhoff.com
Hi 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

Gaurav Kulshreshtha

unread,
Nov 19, 2009, 5:05:31 AM11/19/09
to Douglas C. Schmidt, ace-...@cse.wustl.edu, ch...@kohlhoff.com

------neXtPaRt_1258625903
Content-Type: text/plain; charset"us-ascii"
Content-Transfer-Encoding: quoted-printable

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--

Douglas C. Schmidt

unread,
Nov 19, 2009, 3:32:01 PM11/19/09
to Gaurav Kulshreshtha, ace-...@cse.wustl.edu, ch...@kohlhoff.com

Hi Gaurav,

> 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

0 new messages