Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unary primitive type (101) cause SIGSEGV (Segmentation fault) when query result is processed in c library #30

Open
tojocky opened this issue Oct 4, 2023 · 1 comment

Comments

@tojocky
Copy link

tojocky commented Oct 4, 2023

Hi,

I found that if a query from a table where a value has unary primite type (101) then c library (c.o) ends up in Segmentation fault.

How to reproduce:
create a table with a column type Char (10).
insert some data where a row should contain unary primitive type (101)

create a simple C/C++ that execute the query.

I tried with the latest client version c.0 v.4.0 and it still coring. Unfortunately I cannot paste any code here.

@tojocky tojocky changed the title c.o end up with SIGSEGV (Segmentation fault) when qury return has 101 type (unary primitive) unary primitive type (101) cause SIGSEGV (Segmentation fault) when query result is processed in c library Oct 4, 2023
@sshanks-kx
Copy link
Contributor

kdb+ server

q -p 1234
q)t:([]a:("ab";"cd";(::)));

client program

#include <stdio.h>
#include "k.h"

int main(int argc,char** argv){
    K table,columns,values,col1;
    int x=0;
    int handle=khp("localhost", 1234);
    if(handle<=0){
        printf("Connect fail %d\n",handle);
        return -1;
    }
    printf("Connected\n",handle);
    table=k(handle, "select a from t", (K)0);
    if(table->t!=XT){
        printf("Not a table\n");
        return -1;
    }
    columns=kK(table->k)[0];
    values=kK(table->k)[1];
    col1=kK(values)[0];
    for(x=0;x<col1->n;x++){
        printf("Value type %d\n",kK(col1)[x]->t);
        if(kK(col1)[x]->t==KC)
            printf(" String %.*s\n",kK(col1)[x]->n,kK(col1)[x]->G0);
        else
            printf(" NULL\n");
    }
    r0(table);
    kclose(handle);
    return 1;
}

running i get

Connected
Value type 10
 String ab
Value type 10
 String cd
Value type 101
 NULL

Im not sure if this is what you meant, but doesnt crash for me. It would if I tried to print out a 101 as if it was a string. If you could clarify further if you still have an issue (or if the above causes an issue for you, which platform/version/etc).

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants