cancel
Showing results for 
Search instead for 
Did you mean: 

C API: deserialization fails when connected in same process

mathias_gaunard
New Contributor
Hi,

I have been trying to transfer K objects from one process to another, and I have been using the b9 and d9 functions to attempt to so.

I am using b9 with mode 3, though I have also tried -1, 1 and 2 as well.

d9 (and its validation counterpart okx) work fine so long as I don't call khpu previously in the same process. If I do, then okx fails, and d9 segfaults on a call to ss.

The only symbols in the data are for the names of the columns of table.

There seems to be some funny business going on with symbols whenever I am connected to a live KDB/Q instance. What am I doing wrong?

Thanks for any assistance.
2 REPLIES 2

mathias_gaunard
New Contributor
On Mon, 22 Mar 2021 at 11:36, Mathias Gaunard wrote:> There seems to be some funny business going on with symbols whenever I am connected to a live KDB/Q instance. What am I doing wrong?Looking into this some more, I found out that the first byte of theserialized data generated by b9 was 0 if not connected in the sameprocess, and 1 if connected.By hacking that byte to be whatever it should be, I gotdeserialization to work just fine.What is the reasoning behind this?

Hi Mathias,

The problem you're describing seems to be related to a missed initialization call. If you have not opened a connection yet and try to deserialize, you need to initialize the library first.

You can use the following code to initialize the library:

khp("", -1); // initialise memory if not opening connection before allocation

 

ps: I do notice this was asked a year ago, hope my answer is helpful for anyone else running into the same issue and arriving here from a search.