Do not adjust externally allocated segments#7171
Conversation
See this pygmt post for details. The problem was that the gmtio_adjust_segment did not check the allocation mode of the vectors it was trying to free, thus trying to free memory not belonging to GMT. ternary converts the incoming a,b,c[,z] to x,y[,z] in in the process tries to remove that extra column.
Yes, I can confirm that this PR fixes the SEGV bug. As what you said, the variable to which is unexpected. |
|
Yes, I do agree this is unexpected. Given that nobody will plot 2 Tb of points in a ternary (we hope) it is probably OK if ternary inside does the duplication to avoid surprises on the other end. But I think this is possibly also true for other situations. Many grid operators modify the input grid rather than duplicate, for instance. |
It would be better if ternary can do the duplication on the C side. |
See this pygmt post for details. The problem was that ternary converts the incoming
a,b,c[,z]tox,y[,z]and in the process tries to remove that extra column. This ends up in gmtio_adjust_segment which did not check the allocation mode of the vectors it was trying to free, thus trying to free memory not belonging to GMT. So this is an API bug in a function rarely called.Description of proposed changes
Check allocation status of the affected vectors and only free if allocated by GMT, else set to NULL.
Question: If you examine
dfafter the plot has finished you will see that the content has changed since ternary changes it. If you feel that is not right and should be considered read-only memory then your ternary pyGMT wrapper needs to pass GMT_IS_DUPLICATE instead of GMT_IS_REFERENCE. You can make a decision on that but at least the SEGV bug in the API has been fixed, I hope.