GoogleCloudPlatform / iot-device-sdk-embedded-c

Cloud IoT Device SDK for Connectivity to IoT Core.
Other
247 stars 83 forks source link

memory limiter: Usage of IOTC_PLATFORM_BASE_POSIX is ungrounded #68

Open pfalcon opened 5 years ago

pfalcon commented 5 years ago

src/libiotc/debug_extensions/memory_limiter/iotc_memory_limiter.c has code like:

#ifdef IOTC_PLATFORM_BASE_POSIX
  int no_of_backtraces =
      backtrace(entry->backtrace_symbols_buffer, MAX_BACKTRACE_SYMBOLS);
  entry->backtrace_symbols_buffer_size = no_of_backtraces;
#endif

However, there's no backtrace() function defined by POSIX, which can be verified at http://pubs.opengroup.org/onlinepubs/9699919799/ . Instead, it appears to a Glibc extension.

This causes a build failure for Zephyr port (full Zephyr port, as worked on by Linaro, not just native_posix pseudo-target, which leaks host headers into the build).

As far as I could say, a proper fix for this would be to define a specific compile-time configuration option for this, something like IOTC_PLATFORM_HAS_BACKTRACE. I'm not sure about iot-device-sdk-embedded-c's approach to such matters and naming conventions for config options, so posting this as an RFC.

pfalcon commented 5 years ago

cc: @d3zd3z, @galak