Modify

Ticket #2782 (closed Bugs: fixed)

Opened 5 years ago

Last modified 5 years ago

boost::program_options::notify crashes when variables_map contains user inserted values

Reported by: boost@… Owned by: vladimir_prus
Milestone: Boost 1.39.0 Component: program_options
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

variables_map is useful as a generic properties map (esp. due to its various parsers). But when variables_map contains user inserted values (a properties map would support adding/setting values. variables_map does allow base std::map::insert being called), notify would crash/segfault/die due to m_value_semantic being null (empty shared_ptr).

I suggest that a simple check be added to the notify function before calling (*it).second.m_value_semantic->notify()

This would make it a lot more convenient for those who build a properties wrapper around program_options. Thanks.

Attachments

Change History

comment:1 Changed 5 years ago by anonymous

  • Owner set to vladimir_prus
  • Component changed from None to program_options

comment:2 Changed 5 years ago by vladimir_prus

Why are you calling 'notify' *after* adding your own values? I am not saying this is wrong, just trying to understand your use case.

comment:3 Changed 5 years ago by anonymous

Here is a use case that arises from modular multi-component options processing: a variables_map is passed to the init functions of components, where their options are parsed. Sometimes, I want to set some property values after parsing in one component and then the variables_map is passed to another component for further processing with its own set options. This currently doesn't work due to the notify crash.

My current workaround is don't call notify ever and missing out 2 nice features (setting a variable via typed_value and of course notifier itself.)

comment:4 Changed 5 years ago by vladimir_prus

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

(In [53440]) Make 'notify' ignore values without associated semantics.

Fixes #2782.

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.