Fix for Bug #389419
"MyExe" received signal SIGSEGV, Segmentation fault
Details
Diff Detail
- Repository
- R881 Rust Qt Binding Generator
- Lint
Lint Skipped - Unit
Unit Tests Skipped
After testing, I found that this patch crashes the demo in my docker on a 64 bit machine.
I suspect that the struct qbytearray_t and struct qstring_t should be placed in extern "C" { ... }.
That in turn means that the structs cannot have member functions.
qbytearray_t and qstring_t are passed to C, so they should be PODs. This requires quite large changes.
http://www.cplusplus.com/reference/type_traits/is_pod/
https://en.wikipedia.org/wiki/Plain_Old_Data_Structures#In_C++
I did test the demo using docker - crashed without the patch for me, and works fine with the patch - Arch Linux, 4.15.7-1-ck-haswell, x86_64
I suspect I might need to fire up an actual virtual machine to replicate.
Most of Qt classes are same size as void* to keep ABI compatibility so you can try:
typedef void (*qstring_set)(QString*, void*); void set_qstring(QString* v, void* val) { static_assert(sizeof(void*) >= sizeof(QString), "QString has a bigger size than void*, code below will crash"); *v = *(QString*)&val; }
@anthonyfieroni Just tried the copy pasting your void* idea in. No dice on my machine. Seg faulted trying to run the demo. Captured some valgrind output (attached), in case its of any use. I had to keep my qbytearray segment of the patch in, else it wouldn't even get that far (attached valgrind output for that too).
I'd have thought the same docker on the same hardware would give the same compiled code. I'll have a go at making a version of the patch where there are no qbytearray_t and no qstring_t.