Bug 276187 - devel/cpprestsdk: json.h breaks with the FreeBSD std::unique_ptr
Summary: devel/cpprestsdk: json.h breaks with the FreeBSD std::unique_ptr
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Fernando Apesteguía
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-07 21:26 UTC by Jan-Espen Oversand
Modified: 2024-01-08 17:54 UTC (History)
1 user (show)

See Also:
fernape: merge-quarterly?


Attachments
Patch files to de-inline the failing constructor and destructor (1.70 KB, patch)
2024-01-07 21:26 UTC, Jan-Espen Oversand
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan-Espen Oversand 2024-01-07 21:26:44 UTC
Created attachment 247517 [details]
Patch files to de-inline the failing constructor and destructor

A simple #include <cpprestsdk/json.h> fails with errors like this:

In file included from /usr/include/c++/v1/iostream:43:
In file included from /usr/include/c++/v1/ios:221:
In file included from /usr/include/c++/v1/__locale:18:
In file included from /usr/include/c++/v1/mutex:191:
In file included from /usr/include/c++/v1/__memory/shared_ptr.h:31:
/usr/include/c++/v1/__memory/unique_ptr.h:63:19: error: invalid application of 'sizeof' to an incomplete type 'web::json::details::_Value'
    static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
                  ^~~~~~~~~~~
/usr/include/c++/v1/__memory/unique_ptr.h:297:7: note: in instantiation of member function 'std::default_delete<web::json::details::_Value>::operator()' requested here
      __ptr_.second()(__tmp);
      ^
/usr/include/c++/v1/__memory/unique_ptr.h:263:75: note: in instantiation of member function 'std::unique_ptr<web::json::details::_Value>::reset' requested here
  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
                                                                          ^
/usr/local/include/cpprest/json.h:716:14: note: in instantiation of member function 'std::unique_ptr<web::json::details::_Value>::~unique_ptr' requested here
    explicit value(std::unique_ptr<details::_Value> v) : m_value(std::move(v))
             ^
/usr/local/include/cpprest/json.h:35:7: note: forward declaration of 'web::json::details::_Value'
class _Value;
      ^
1 error generated.

Suggested patch included. De-inlining the constructor and destructor makes the sizeof(_Value) available to std::unique_ptr.
Comment 1 Fernando Apesteguía freebsd_committer freebsd_triage 2024-01-08 08:10:43 UTC
Hi Jan,

Is this patch needed too for bug #276188? Or 2.10.19 is also broken?
Comment 2 Mina Galić freebsd_triage 2024-01-08 08:11:50 UTC
is this specific to a FreeBSD version, or does it happen everywhere?
Comment 3 Jan-Espen Oversand 2024-01-08 08:18:28 UTC
(In reply to Fernando Apesteguía from comment #1)

This is also a problem with the 2.10.19 version, and in fact the same patches should work fine (without fuzz) with both versions of cpprestsdk.
Comment 4 Jan-Espen Oversand 2024-01-08 08:22:34 UTC
(In reply to Mina Galić from comment #2)

Tested on FreeBSD 14.0. I can test 13.2 later, but it might take me a few days. But bottom line, I guess cpprestsdk has been developed against the gcc stdc++ library, and the clang libcpp might differ slightly with regards to type completeness requirements.
Comment 5 Fernando Apesteguía freebsd_committer freebsd_triage 2024-01-08 08:29:05 UTC
(In reply to Jan-Espen Oversand from comment #3)
Then this should be committed before bug #276188.

Thanks.
Comment 6 Fernando Apesteguía freebsd_committer freebsd_triage 2024-01-08 17:53:39 UTC
Committed,

Thanks!
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-01-08 17:54:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6cbfd8b1e7dc89a48a126867b180813df46c19e4

commit 6cbfd8b1e7dc89a48a126867b180813df46c19e4
Author:     Jan-Espen Oversand <sigsegv@radiotube.org>
AuthorDate: 2024-01-08 08:33:05 +0000
Commit:     Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2024-01-08 17:53:11 +0000

    devel/cpprestsdk: Fix include of json.h

    De-inlining the constructor and destructor makes the sizeof(_Value) available to
    std::unique_ptr.

    PR:             276187
    Reported by:    sigsegv@radiotube.org

 devel/cpprestsdk/Makefile                            |  1 +
 .../files/patch-include_cpprest_json.h (new)         | 20 ++++++++++++++++++++
 devel/cpprestsdk/files/patch-src_json_json.cpp (new) | 19 +++++++++++++++++++
 3 files changed, 40 insertions(+)