application core dumps when chain-id argument is not provided. #282

Closed
opened 2022-02-18 04:59:34 +00:00 by prandnum · 12 comments
prandnum commented 2022-02-18 04:59:34 +00:00 (Migrated from gitlab.com)

As you can see below in the case of chain-id option when the argument is not given the application core dumps

qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$ ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate
Unknown parameter(s):
  --chainid
  --erew
  --rpc-endpoint1
qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$ ./cli_wallet --chainid --erew --rpc-endpoint1 --chain-id
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >'
  what():  the required argument for option '--chain-id' is missing
Aborted (core dumped)
qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$
Expected behavior: The error should be properly be handled for parameters with no default argument values by mentioning like

qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$ ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate --server-rpc-user
Unknown parameter(s):
  --chainid
  --erew
  --rpc-endpoint1

Missing argument for paramter(s):
  --rpc-tls-certificate
  --server-rpc-user
As you can see below in the case of chain-id option when the argument is not given the application core dumps ``` qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$ ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate Unknown parameter(s): --chainid --erew --rpc-endpoint1 qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$ ./cli_wallet --chainid --erew --rpc-endpoint1 --chain-id terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >' what(): the required argument for option '--chain-id' is missing Aborted (core dumped) qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$ ``` ``` Expected behavior: The error should be properly be handled for parameters with no default argument values by mentioning like qa@PBSA-Dev:~/Pipeline472760902/build/programs/cli_wallet$ ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate --server-rpc-user Unknown parameter(s): --chainid --erew --rpc-endpoint1 Missing argument for paramter(s): --rpc-tls-certificate --server-rpc-user ```
prandnum commented 2022-02-18 04:59:59 +00:00 (Migrated from gitlab.com)

@serkixenos @bobinson

CC: @hbelakon

@serkixenos @bobinson CC: @hbelakon
serkixenos commented 2022-02-18 15:45:47 +00:00 (Migrated from gitlab.com)

Boost program_options does not provide feature similar to collect_unrecognized for cli parameters missing the values, so we are not able to handle them in similar fashion.

We can wrap Boost program_option exception, to handle software termination by Boost, and turn output from this

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >'
  what():  the required argument for option '--chain-id' is missing
Aborted (core dumped)

to this

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >'
  what():  the required argument for option '--chain-id' is missing
Boost program_options does not provide feature similar to collect_unrecognized for cli parameters missing the values, so we are not able to handle them in similar fashion. We can wrap Boost program_option exception, to handle software termination by Boost, and turn output from this ``` terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >' what(): the required argument for option '--chain-id' is missing Aborted (core dumped) ``` to this ``` terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >' what(): the required argument for option '--chain-id' is missing ```
serkixenos commented 2022-02-18 17:37:30 +00:00 (Migrated from gitlab.com)

assigned to @vampik

assigned to @vampik
vampik commented 2022-02-21 08:13:18 +00:00 (Migrated from gitlab.com)

added 3h of time spent

added 3h of time spent
vampik commented 2022-02-21 08:15:25 +00:00 (Migrated from gitlab.com)

mentioned in commit 6bc9eb38f7

mentioned in commit 6bc9eb38f74f53f42d2e4fe1e8b7071aed9de921
vampik commented 2022-02-21 08:24:11 +00:00 (Migrated from gitlab.com)

mentioned in merge request !72

mentioned in merge request !72
vampik commented 2022-02-21 08:26:25 +00:00 (Migrated from gitlab.com)

Now, we don't terminate on exception, but wrap it and generate the follow output:

./cli_wallet --chain-id
the required argument for option '--chain-id' is missing
Now, we don't terminate on exception, but wrap it and generate the follow output: ``` ./cli_wallet --chain-id the required argument for option '--chain-id' is missing ```
vampik commented 2022-02-21 13:57:39 +00:00 (Migrated from gitlab.com)

mentioned in commit 93b57f294d

mentioned in commit 93b57f294df2de8d6a7d829105dded32634068aa
serkixenos commented 2022-02-21 13:57:39 +00:00 (Migrated from gitlab.com)

mentioned in commit 2981613a9e

mentioned in commit 2981613a9e64551f457b93c3071445dea883aa0a
serkixenos commented 2022-02-21 13:58:05 +00:00 (Migrated from gitlab.com)

assigned to @prandnum

assigned to @prandnum
serkixenos commented 2022-02-21 14:16:28 +00:00 (Migrated from gitlab.com)

@prandnum You need to understand limitations of boost program_option class. It does not provide features similar to collect_unrecognized for params missing values. The error message you are seeing

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >'
  what():  the required argument for option '--chain-id' is missing

comes from boost library implementation, not something we coded in our software. We have limited control over how cli params are processed.

@prandnum You need to understand limitations of boost program_option class. It does not provide features similar to collect_unrecognized for params missing values. The error message you are seeing ``` terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_command_line_syntax> >' what(): the required argument for option '--chain-id' is missing ``` comes from boost library implementation, not something we coded in our software. We have limited control over how cli params are processed.
prandnum commented 2022-02-25 07:02:25 +00:00 (Migrated from gitlab.com)
root@4bea5acbdc31:~/peerplays-network# ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate --server-rpc-user
the required argument for option '--server-rpc-user' is missing
root@4bea5acbdc31:~/peerplays-network# ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate
Unknown parameter(s):
  --chainid
  --erew
  --rpc-endpoint1
root@4bea5acbdc31:~/peerplays-network#
``` root@4bea5acbdc31:~/peerplays-network# ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate --server-rpc-user the required argument for option '--server-rpc-user' is missing root@4bea5acbdc31:~/peerplays-network# ./cli_wallet --chainid --erew --rpc-endpoint1 --rpc-tls-certificate Unknown parameter(s): --chainid --erew --rpc-endpoint1 root@4bea5acbdc31:~/peerplays-network# ```
prandnum (Migrated from gitlab.com) closed this issue 2022-02-25 07:02:26 +00:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Peerplays_Blockchain/peerplays_migrated#282
No description provided.