Modify

Opened 9 years ago

Closed 8 years ago

#2782 closed Bugs (fixed)

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 (0)

Change History (4)

comment:1 Changed 9 years ago by anonymous

Component: Noneprogram_options
Owner: set to Vladimir Prus

comment:2 Changed 9 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 9 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 8 years ago by Vladimir Prus

Resolution: fixed
Status: newclosed

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

Fixes #2782.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Vladimir Prus.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.