raku-community-modules / DBIish

Database interface for Raku
89 stars 31 forks source link

Native call expected argument 1 to reference a native integer, but got CPointer #221

Closed demanuel closed 2 years ago

demanuel commented 2 years ago

Hi!

I first detected this on https://github.com/CurtTilmes/raku-dbpg/issues/17 so i decided to migrate to DBIish, but it looks like it suffers of the same.

Sorry if i shouldn't report it here as well....

Issue:

DBIish dies while executing a select on a table with column type bytea:

> my @rows = $dbh.execute('select * from processed_feedback;').allrows
Native call expected argument 1 to reference a native integer, but got CPointer
  in sub str-to-blob at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/1B6018506ABC08CD131DD147B02C370C56599B7B (DBDish::Pg::Native) line 20
  in sub  at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/EE48EDA05EFB5052583EACDA1ED614EFFB395FED (DBDish) line 54
  in block  at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/722DCB5B6813505E9834D6F0226E6E48F433B21A (DBDish::Pg::StatementHandle) line 1
  in method _row at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/722DCB5B6813505E9834D6F0226E6E48F433B21A (DBDish::Pg::StatementHandle) line 128
  in method row at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/300A6A8F69E68E61F3353B05F301E464D8E9234F (DBDish::StatementHandle) line 93
  in block  at /home/demanuel/.rakubrew/versions/moar-master/install/share/perl6/site/sources/300A6A8F69E68E61F3353B05F301E464D8E9234F (DBDish::StatementHandle) line 132
  in block <unit> at <unknown file> line 1

No issues if in the select there's no "bytea" type field.

Regards, David Santiago

rbt commented 2 years ago

Can you provide a CREATE TABLE statement and INSERT with a value that causes the error?

There is at least some support for bytea data.

demanuel commented 2 years ago

test.txt File attached (it's a sql file but github didn't allowed me to upload it with the sql extension).

The first 15 to 20 inserts are different and then i just copy pasted. The interesting thing is that the problem occurs only if i have a certain amount of records in the DB. If i have less than X records i have no problem.

I don't have time now, but later if required i will provide the threshold number X.

rbt commented 2 years ago

Ah, fun.

I'm able to reproduce on moar-2022.03 but moar-2021.12 works as expected (fails with a different error at 1.9 million entries).

I'll try to narrow it down further.

rbt commented 2 years ago

So, the value doesn't matter. A completely empty value works too.

my @rows = $dbh.execute(q{select ''::bytea from (SELECT * from generate_series(1, 5000)) as series(c)}).allrows;

Also, the exact number of entries required to cause the fault varies a bit, anywhere between 280 to 512 but ~340 is most common.

I believe this is a NativeCall dispatch error that shows itself when JIT kicks in but have no idea how to debug/fix such a thing.

I've forwarded what I could:

https://github.com/rakudo/rakudo/issues/4828

demanuel commented 2 years ago

THanks for the help and the amazing debugging skills. :-)

rbt commented 2 years ago

Confirmed to be a bug in upstream code, so I'm closing this ticket.