Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when starting ign-gazebo if LC_NUMERIC in set to a locale with comma as a decimal separator #207

Closed
1 task done
osrf-migration opened this issue Nov 13, 2018 · 2 comments
Labels
bug Something isn't working major

Comments

@osrf-migration
Copy link

Original report (archived issue) by Silvio Traversaro (Bitbucket: traversaro).


Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:

Description

Remake of https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/issues/60/error-when-starting-gazebo-if-lc_numeric (#60) . : )

I recently tried to test the work in progress version of ign-gazebo, and on my system I got a locale-related error (similar to
https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/issues/60/error-when-starting-gazebo-if-lc_numeric (#60) , ros/urdfdom#98
and ros/urdfdom#98).

Steps to Reproduce

Launch ign-gazebo with a locale in which the decimal separator is not .:

LC_NUMERIC=it_IT ign-gazebo

Expected behavior:
If launched with the C locale, ign-gazebo start correctly:

straversaro@iiticublap103:~/src/gazebo-superbuild/build-ign-gcc-8/install/bin$ LC_ALL="C" ./ign-gazebo --verbose 3
[Msg] Ignition Gazebo v0.1.0~pre1
[GUI] [Msg] Loading config [/home/straversaro/src/gazebo-superbuild/build-ign-gcc-8/install/share/ignition/gazebo0/gui/gui.config]
[GUI] [Msg] World [default] initialized with [default_physics] physics profile.
[GUI] [Msg] Loading plugin [Scene3D]
[GUI] [Msg] Added plugin [3D View] to main window
[GUI] [Msg] Loading plugin [WorldControl]
[GUI] [Msg] Added plugin [World control] to main window
[GUI] [Msg] Loading plugin [WorldStats]
[GUI] [Msg] Added plugin [World stats] to main window
[GUI] [Msg] Serving scene information on [/world/default/scene/info]
[GUI] [Msg] Serving scene graph on [/world/default/scene/graph]
[GUI] [Msg] Publishing pose messages on [/world/default/pose/info]
[GUI] [Msg] Loading plugin [ignition-rendering1-ogre]

Actual behavior:

straversaro@iiticublap103:~/src/gazebo-superbuild/build-ign-gcc-8/install/bin$ ./ign-gazebo --verbose 3
[Msg] Ignition Gazebo v0.1.0~pre1
[GUI] [Msg] Loading config [/home/straversaro/src/gazebo-superbuild/build-ign-gcc-8/install/share/ignition/gazebo0/gui/gui.config]
Error [Param.cc:395] Invalid argument. Unable to set value [.1 ] for key[near].
Exception [Param.cc:44] SDF ASSERTION                     
Invalid parameter
In function       : Param
Assert expression : this->ValueFromString(_default)
terminate called after throwing an instance of 'sdf::v8::AssertionInternalError'
Aborted (core dumped)

Reproduces how often:

Everytime.

Versions

Ubuntu 18.04
sdformat branch : gz11

Additional Information

Checking the backtrace, it seems that the call sequence is:
sdf::Element::AddValue --> sdf::Element::CreateParam --> sdf::Param::Param --> sdf::Param::ValueFromString

A related commit is https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/commits/f6af03cf3a63d3a6dd1492a2f6031475625a71cd (3488a30) ,
but I am not sure why I never experienced this, as template<typename T> void Param::Init(const std::string &_value)
method was prone to this locale error as well.

A proper solution could be to substitute calls to str::stod with a locale-safe custom function as done in
https://github.com/ros/urdfdom_headers/pull/42/files . An alternative, for the branch of SDFormat that support C++17
would be to use std::from_chars. Unfortunately, not all the strings
that represent a valid XML floating point number are valid inputs to std::from_chars (for example, +1.0 is not a valid input to
std::to_chars), so even this is not a trivial solution.

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


See pull request #492

@osrf-migration
Copy link
Author

Original comment by Silvio Traversaro (Bitbucket: traversaro).


  • changed state from "new" to "resolved"

Fixed with https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/pull-requests/492/fix-locale-problems-of-std-stringstream/diff .

@osrf-migration osrf-migration added major bug Something isn't working labels Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major
Projects
None yet
Development

No branches or pull requests

1 participant