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

Add XXH_NAMESPACE, for namespace emulation in C #1065

Merged
merged 1 commit into from
May 25, 2017

Conversation

elemoine
Copy link

I've been trying to use rosbag in a PostgreSQL extension based on Multicorn. But that doesn't work in PostgreSQL 9.6. I get SIGSEGV crashes. See https://github.com/elemoine/FdwRosTest for a complete test case with instructions on how to reproduce the bug.

The issue is that the postgresql 9.6 binary uses liblz4, which, as the roslz4 code, includes xxhash.h and xxhash.c. So when run in PostgreSQL the roslz4 code uses the XXH32_ symbols from liblz4 instead of its own symbols. This results in SIGSEGV crashes.

This PR introduces the XXH_NAMESPACE pre-processor variable for namespacing XXH32_ symbols. I did not invent anything – the latest xxHash code already uses that.

Alternatively, the roslz4 code could be updated to include the latest xxHash code. But that would require changes to the lz4s.c code, as the xxHash API has changed.

PROPERTIES COMPILE_FLAGS "-Wno-sign-compare" COMPILE_DEFINITIONS "XXH_NAMESPACE=ROSLZ4_")
set_source_files_properties(
src/xxhash.c
PROPERTIES COMPILE_DEFINITIONS "XXH_NAMESPACE=ROSLZ4_")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please set the compile definitions for both files in a single call:

set_source_files_properties(
  src/lz4s.c src/xxhash.c
  PROPERTIES COMPILE_DEFINITIONS "XXH_NAMESPACE=ROSLZ4_")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@elemoine elemoine force-pushed the xxh-namespace branch 2 times, most recently from 95426a1 to 8cf0966 Compare May 23, 2017 16:49
src/lz4s.c
PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
src/lz4s.c src/xxhash.c
PROPERTIES COMPILE_FLAGS "-Wno-sign-compare" COMPILE_DEFINITIONS "XXH_NAMESPACE=ROSLZ4_")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a separate set_source_files_properties call since -Wno-sign-compare is not necessary for src/xxhash.c.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes. Done. Thanks!

@dirk-thomas
Copy link
Member

The patch looks good. Just waiting for CI...

@elemoine
Copy link
Author

Thanks for reviewing. This issue has caused me major headhaches!

@dirk-thomas
Copy link
Member

@ros-pull-request-builder retest this please

@elemoine
Copy link
Author

The build error doesn't seem to be related to my change.

@dirk-thomas
Copy link
Member

The build error doesn't seem to be related to my change.

No worries, the failure is related to a different package. The problem has already been fixed but the Docker image is still using a previous version. It will start working in bit.

@dirk-thomas
Copy link
Member

@ros-pull-request-builder retest this please

@dirk-thomas
Copy link
Member

Thanks!

@dirk-thomas dirk-thomas merged commit ac9f45f into ros:lunar-devel May 25, 2017
elemoine pushed a commit to LI3DS/fdw-li3ds that referenced this pull request May 26, 2017
ros/ros_comm#1065 was merged, so the master branch of ros_comm can now be used.
@elemoine elemoine deleted the xxh-namespace branch May 26, 2017 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants