Skip to content

Stack exaustion while value_from(std::filesystem::path) #975

@RoyBellingan

Description

@RoyBellingan

PLEASE DON'T FORGET TO "STAR" THIS REPOSITORY :)

Are you inviting me to have multiple account or more friend ?

Version of Boost

1.84

Steps necessary to reproduce the problem

#include <boost/json/src.hpp>
#include <filesystem>
#include <iostream>

namespace bj = boost::json;

int main() {
	std::filesystem::path p = "/cry";
	
	auto ref = bj::value_from(p);
	auto ser = bj::serialize(ref);
	std::cout << ser;
}

if the path is EMPTY it works fine, but if there is something it leads to a stack exausting crash, remaining struct inside those 2

loop (first one is gcc the other clang, quite similar but a bit different)

image(8)

image(9)

Also using

void tag_invoke(const bj::value_from_tag&, bj::value& jv, const std::filesystem::path& t) {
	jv = t.string();
}

std::filesystem::path tag_invoke(const bj::value_to_tag<std::filesystem::path>&, const boost::json::value& jv) {
	std::filesystem::path path = std::string_view(jv.as_string());
	return path;
}

or

void tag_invoke(const bj::value_from_tag&, bj::value& jv, const std::filesystem::__cxx11::path& t) {
	jv = t.string();
}

std::filesystem::path tag_invoke(const bj::value_to_tag<std::filesystem::__cxx11::path>&, const boost::json::value& jv) {
	std::filesystem::path path = std::string_view(jv.as_string());
	return path;
}

Does not help (in fact looks like they are not even used...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions