Some weird crashes
simendsjo
simen.endsjo at pandavre.com
Thu Mar 3 12:43:00 PST 2011
On 02.03.2011 18:24, Denis Koroskin wrote:
> On Tue, 01 Mar 2011 23:01:21 +0300, simendsjo
> <simen.endsjo at pandavre.com> wrote:
>
>> On 28.02.2011 20:24, Denis Koroskin wrote:
>>> On Mon, 28 Feb 2011 22:04:44 +0300, simendsjo
>>> <simen.endsjo at pandavre.com> wrote:
>>>
>>>> On 28.02.2011 18:52, simendsjo wrote:
>>>>>
>>>>> // ERROR
>>>>> auto res = mysql_library_init(0, null, null);
>>>>>
>>>>> auto cn = mysql_init(null);
>>>>> auto oldcn = cn;
>>>>>
>>>>> writeln(mysql_errno(cn));
>>>>> assert(cn == oldcn); // when the last assert is active, the above line
>>>>> changes cn and thus fails.
>>>>>
>>>>> auto err = mysql_errno(cn);
>>>>> assert(cn == oldcn);
>>>>
>>>> Btw, if I don't use writeln it doesn't fail..
>>>
>>> I think you have a bug at line 42.
>>>
>>> On a serious note, it might have helped if you'd attached source code,
>>> or at least binaries.
>>
>> Hmmm.. Seems my post last night didn't get through..
>> Here's the code and necessary libraries: http://share1t.com/4xgt2l
>
> What appears to be an error here is in fact an Access Violation at
> mysql_close.
>
> Here is a reduced test-case:
>
> import mysql;
>
> void main()
> {
> auto res = mysql_library_init(0, null, null);
> auto cn = mysql_init(null);
> mysql_close(cn);
> }
>
>
> Then I decided to check whether it is D's fault or not by porting this
> short program to C. Here is what I got:
>
> // mysql.c
> int mysql_server_init(int argc, char **argv, char **groups);
> struct MYSQL* mysql_init(struct MYSQL*);
> void mysql_close(struct MYSQL*);
>
> #define mysql_library_init mysql_server_init
>
> #define NULL 0
>
> #include <stdio.h>
>
> int main()
> {
> int res = mysql_library_init(0, NULL, NULL);
> struct MYSQL* cn = mysql_init(NULL);
> printf("here");
> mysql_close(cn);
> return 0;
> }
>
> This program works fine, BUT try commenting out the "printf" call and it
> crashes, too. That said, it is unlikely to be DMD fault here. Are you
> sure those prototypes and/or .lib/.dll files are fine?
I've gone through the entire file and fixed ever wrong definition I
found. I added the C declarations as a comment before each type.
The same error exists, and I cannot understand why...
The code is pasted here: http://pastebin.com/KwacZ0MY
Does anyone have a clue where to start looking?
More information about the Digitalmars-d-learn
mailing list