Conversation
|
What is the exact error? As far as I see in the code, these handlers are checked for null before calling them. Maybe problem is with example? |
The application crashes, segfaults. I ran it on Android 15 under Termux (clang) and Linux (probably clang again) where it crashed. Using gdb, the crash is caused by assigning null to a std::function. The crash can be reproduced on Lunux by compiling with clang and just using example-chat, the faulty code is in Crow, not the example. The check for null isn't the problem, it's assigning null that's the problem. |
|
Ok, thanks for info. So the only thing is that you can create lambda_wrapper with nullptr. |
| ReturnType operator()(Args... args) const | ||
| { | ||
| if (valid_) | ||
| { | ||
| return func_(args...); | ||
| } | ||
| throw call_error(); | ||
| } |
There was a problem hiding this comment.
I don't really understand what lambda_wrapper does 🙂 After all, std just throws as well
https://en.cppreference.com/w/cpp/utility/functional/function/operator()
Exceptions
Throws std::bad_function_call if *this does not store a callable function target, i.e. !*this == true.
|
I have encountered the same problem and don't know how to fix it yet. |
example-chat has runtime errors because std::function<> is assigned null in places.
This is a fix for that, with unittests.