Notice

The forum is in read only mode.

  • Page:
  • 1

TOPIC: std::thread in c++ AppMethod 1.16 unusable ?!

std::thread in c++ AppMethod 1.16 unusable ?! 6 years 6 months ago #1456

Can someone please confirm this error for me ? New AppMethod 1.16 plain installed, no beta or anything was installed, no changes to SDK/NDK comming with AppMethod.

Create new C++ project, switch to Android (Using NoteS3 with Samsung official 5.0):

put something like that in:

#include <thread>

....

std::thread t(this_should_work);
t.detach();
.....

void this_should_work() { sleep(10000);}

crashes with Segmentation Fault(11) and callstack:

:A06DA004 execute_native_thread_routine
:B6ECC7BC __pthread_start(void*)
:B6ECA89C __start_thread

or:

:A06CD0D2 std::(anonymous namespace)::default_terminate()
:A06CD014 std::terminate()
:A06CC612 __cxxabiv1::fatalError(message=0xa09a0ae8 "Pure virtual function called!")
:A06CAF18 __cxa_pure_virtual()
:A06DA00C execute_native_thread_routine()
:B6ECC7BC __pthread_start(void*)()
:B6ECA89C __start_thread()
:00000000 ??()

Worked fine in 1.15.

std::thread in c++ AppMethod 1.16 unusable ?! 6 years 6 months ago #1509

Looks like this issue is not going to be resolved, or it's just that nobody realy uses pure c++11 on Android, anyway if you need anonymous thread created on fly, try something like this until threads are fixed:

namespace Threading
{
class TAnonymousThreadTask: public TCppInterfacedObject<TProc>
{
private:
std::function<void()> f;

public:
template<typename _Callable, typename... _Args>
explicit
__fastcall TAnonymousThreadTask(_Callable&& __f, _Args&&... __args)
{
this->f = std::bind(__f,__args...);
}

void __fastcall Invoke()
{
this->f();
}

};

class TAnonymousThread
{
public:
template<typename _Callable, typename... _Args>
static TThread* StartAnonymousThread(_Callable&& __f, _Args&&... __args)
{
TThread *t =TThread::CreateAnonymousThread(new Threading::TAnonymousThreadTask(__f,__args...));
t->Start();
return t;
}
};
}

std::thread in c++ AppMethod 1.16 unusable ?! 6 years 5 months ago #1544

Hi Miki,

Thanks for posting a workaround. There is an issue with the Android NDK and some C++11 support, std::thread in specific, that will be addressed when we up the NDK version. The C++11 code should otherwise work on iOS and Win64 with no issues.
~/jt

std::thread in c++ AppMethod 1.16 unusable ?! 6 years 3 weeks ago #3780

Hi, did you try it on 1.17?

Please improve your code formatting it is hard to read. cheers.

std::thread in c++ AppMethod 1.16 unusable ?! 4 years 4 months ago #8335

I'm facing the same problem with C++ Builder Berlin. Any news according to this issue?
  • Page:
  • 1
Moderators: April Anne