Having error getting a Varchar from a DuckDBValue #321
Unanswered
lucap-irion
asked this question in
Q&A
Replies: 2 comments 5 replies
-
|
What error did you get when reading it as string? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I’ve investigated this a bit more. My situation is that I’m not using the native duckdb.dll, but a debug-compiled one, because I’m trying to use it on top of a custom extension that extends profiling.
Only when I use this custom DLL do I get the error: “Critical error detected c0000374” (a heap corruption / memory corruption error typically caused by mismatched C runtime libraries, double-free, buffer overruns, or calling free() on memory allocated by a different CRT).
When I use the native duckdb.dll shipped with your project, it works without any changes.
I also saw your README.md, which says to check out the native code for debugging, but it’s already checked out.
Have you ever encountered issues when using a debug-compiled DuckDB?
…________________________________
From: Giorgi Dalakishvili ***@***.***>
Sent: Thursday, 2 April 2026 17:45
To: Giorgi/DuckDB.NET ***@***.***>
Cc: Luca Prezzi ***@***.***>; Author ***@***.***>
Subject: Re: [Giorgi/DuckDB.NET] Having error getting a Varchar from a DuckDBValue (Discussion #321)
What error did you get when reading it as string?
—
Reply to this email directly, view it on GitHub<#321?email_source=notifications&email_token=ABLVRYTKOHEAIEWJ455YVJT4T2DLHA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNRUGI2TEMJRUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-16425211>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABLVRYVIW5KAV77Y4CAZVN34T2DLHAVCNFSM6AAAAACXKX7YIKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNBSGUZDCMI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Giorgi,
I’m experimenting with your .NET project, and I’m trying to add some
CAPIbindings to your solution, includingNativeMethodsforProfilingInfoand other related pieces.With the
CAPIprofiling info, I can extract profile metrics likeCPU_TIMEas aDuckdbValue, which needs to be converted toVarchar. When I tried to convert the value toVarchar, I got a memory error.Looking at the
DuckDBGetVarchardefinition, I noticed that the return type is notIntPtras aspected from thebut
string:DuckDB.NET/DuckDB.NET.Bindings/NativeMethods/NativeMethods.Value.cs
Line 216 in 96e4851
I changed the return type to
IntPtrand updated theGetValue<T>to use yourToManagedString()on the pointer. It worked fine as expected. This is my first work withCAPIand interop, so I don’t know all the implications of this change, but after reading some blogs, I saw that it’s safer than telling the CLR to implicitly convert the pointer tostring.Do you have any experience or knowledge about this approach? Do you think it’s safe to adopt the
IntPtrapproach instead of the currentstringconversion in the library?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions