eclipse-iceoryx / eclipse-iceoryx/iceoryx

Potential null pointer dereference

Open
#2,450 6 comments 0 reactions 0 assignees View on GitHub
needs info
Dominant language
C++
Stars
2.2k
Forks
492
Avg merge
18h 57m
Merged PRs (30d)
1

Description

## Required information

**Operating system:**
Ubuntu 20.04/22.04/24.04 LTS

**Compiler version:**
GCC 14.2.0

**Eclipse iceoryx version:**
v2.0.6

**Observed result or behaviour:**
While compiling with -O2 flag following warnings are seen:
```
In constructor ‘iox::cxx::error::error(Targs&& ...) [with Targs = {iox::popo::AllocationError&}; T = iox::popo::AllocationError]’,
63.43 inlined from ‘iox::cxx::expected iox::popo::UntypedPublisherImpl::loan(uint32_t, uint32_t, uint32_t, uint32_t) [with BasePublisherType = iox::popo::BasePublisher<>]’ at /usr/local/include/iceoryx/v2.0.6/iceoryx_posh/internal/popo/untyped_publisher_impl.inl:51:21,
63.43 /usr/local/include/iceoryx/v2.0.6/iceoryx_hoofs/internal/cxx/expected.inl:72:7: error: potential null pointer dereference [-Werror=null-dereference]
63.43 72 | : value(std::forward(args)...)
63.43 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63.43 In file included from /usr/local/include/iceoryx/v2.0.6/iceoryx_posh/internal/popo/untyped_publisher_impl.hpp:79:
63.43 In member function ‘iox::cxx::expected iox::popo::UntypedPublisherImpl::loan(uint32_t, uint32_t, uint32_t, uint32_t) [with BasePublisherType = iox::popo::BasePublisher<>]’,
63.43 /usr/local/include/iceoryx/v2.0.6/iceoryx_posh/internal/popo/untyped_publisher_impl.inl:55:63: error: potential null pointer dereference [-Werror=null-dereference]
63.43 55 | return cxx::success(result.value()->userPayload());
```

**Expected result or behaviour:**
What do you expect to happen?
No warnings.

**Conditions where it occurred / Performed steps:**
Compile with gcc-14.2.0 and -O2 flag

Contributor guide

Open the contributing guide

Research direction

Reproduce the warning with GCC 14.2.0 and -O2, then inspect iceoryx_posh/internal/popo/untyped_publisher_impl.inl around lines 51-55 and iceoryx_hoofs/internal/cxx/expected.inl around line 72. Trace the result and error paths involved in loan(); done means the affected code compiles without the reported null-dereference warnings while preserving its behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.