Modify

Ticket #3525 (closed Bugs: fixed)

Opened 5 years ago

Last modified 4 years ago

problem with example response_file.cpp

Reported by: gvacanti@… Owned by: vladimir_prus
Milestone: Boost 1.42.0 Component: program_options
Version: Boost 1.40.0 Severity: Cosmetic
Keywords: Cc: s.ochsenknecht@…

Description

The example works as advertised when the provided response file is used. If I modify the response file as follows:

-I bar1234567890123456789012345678901234567890 -I biz --magic=10

then the output is garbled:

Include paths: bar12�\pA5678Abar12

I can fix the problem if I add

string sss= ss.str();

and replace the tokenizer line with

tokenizer<char_separator<char> > tok(sss, sep);

I'm not too sure why the problem occurs, as ss.str() is supposed to return a copy.

I work on Linux, gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3

Attachments

patch_ticket3525.diff Download (1.1 KB) - added by s.ochsenknecht@… 4 years ago.
patch

Change History

comment:1 Changed 4 years ago by s.ochsenknecht@…

valgrind shows the errors.

stringstream::str() returns a *copy* of the string. This is a temporary object. The tokenizer does further operations on the string which is descruted already. The string has to live as long as the tokenizer.

So, its not a bug of program_options. I think the testcase has to be adapted. I will attach a patch soon ...

Changed 4 years ago by s.ochsenknecht@…

patch

comment:2 Changed 4 years ago by Sascha Ochsenknecht <s.ochsenknecht@…>

  • Cc s.ochsenknecht@… added

comment:3 Changed 4 years ago by s_ochsenknecht

  • Status changed from new to closed
  • Resolution set to fixed

(In [57808]) correct usage of tokenizer, memory bug, Fixes #3525

comment:4 Changed 4 years ago by s_ochsenknecht

  • Milestone changed from Boost 1.41.0 to Boost 1.42.0
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.