Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-20 Thread Mathias LANG via Digitalmars-d-learn

On Wednesday, 21 July 2021 at 03:25:03 UTC, apz28 wrote:

with below error message:
..\..\pham\db\db_skdatabase.d(140): Error: null dereference in 
function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb
..\..\pham\db\db_skdatabase.d(139): Error: null dereference in 
function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb
Error: null dereference in function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb
..\..\pham\db\db_skdatabase.d(138): Error: null dereference in 
function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb


It seems the compiler is doing extra analysis and seeing that a 
null pointer is being dereferenced. Can you provide the code for 
"pham\db\db_skdatabase.d" at L138 through 140 ?


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-21 Thread apz28 via Digitalmars-d-learn

On Wednesday, 21 July 2021 at 04:52:44 UTC, Mathias LANG wrote:



It seems the compiler is doing extra analysis and seeing that a 
null pointer is being dereferenced. Can you provide the code 
for "pham\db\db_skdatabase.d" at L138 through 140 ?


```d
package(pham.db):  // Line# 133
final DbReadBuffer acquireSocketReadBuffer(size_t 
capacity = DbDefaultSize.socketReadBufferLength) nothrow @safe

{
version (TraceFunction) dgFunctionTrace();

if (_socketReadBuffer is null)
_socketReadBuffer = 
createSocketReadBuffer(capacity);

return _socketReadBuffer;
}
```


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-21 Thread apz28 via Digitalmars-d-learn

On Wednesday, 21 July 2021 at 11:52:39 UTC, apz28 wrote:

On Wednesday, 21 July 2021 at 04:52:44 UTC, Mathias LANG wrote:



It seems the compiler is doing extra analysis and seeing that 
a null pointer is being dereferenced. Can you provide the code 
for "pham\db\db_skdatabase.d" at L138 through 140 ?


```d
package(pham.db):  // Line# 133
final DbReadBuffer acquireSocketReadBuffer(size_t 
capacity = DbDefaultSize.socketReadBufferLength) nothrow @safe

{
version (TraceFunction) dgFunctionTrace();

if (_socketReadBuffer is null)
_socketReadBuffer = 
createSocketReadBuffer(capacity);

return _socketReadBuffer;
}
```


The entire codes is available from github
https://github.com/apz28/dlang/blob/main/source/pham/db/db_skdatabase.d#L138


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-21 Thread bauss via Digitalmars-d-learn

On Wednesday, 21 July 2021 at 03:25:03 UTC, apz28 wrote:

VisualD project - Any hint to work around

DMD version:
DMD32 D Compiler v2.096.0-rc.1-dirty
Copyright (C) 1999-2021 by The D Language Foundation, All 
Rights Reserved written by Walter Bright


Failed Build Command line:
dmd -release -m32mscoff -O -inline -dip25 -dip1000 
-preview=fixAliasThis -X -Xf"Win32\Release\db_library.json" -c 
-of"Win32\Release\db_library.obj" 
@Win32\Release\db_library.build.rsp


with below error message:
..\..\pham\db\db_skdatabase.d(140): Error: null dereference in 
function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb
..\..\pham\db\db_skdatabase.d(139): Error: null dereference in 
function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb
Error: null dereference in function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb
..\..\pham\db\db_skdatabase.d(138): Error: null dereference in 
function 
_D4pham2db10fbdatabase7FbArray__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAb


The problem here is not actually -release but -O.

-O will check for null derefences in your code when using @safe I 
believe.


I didn't inspect your code much further, as I'm short on time 
right now, but you should have a starting point now at least.


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn

On 7/21/21 7:56 AM, apz28 wrote:

On Wednesday, 21 July 2021 at 11:52:39 UTC, apz28 wrote:

On Wednesday, 21 July 2021 at 04:52:44 UTC, Mathias LANG wrote:



It seems the compiler is doing extra analysis and seeing that a null 
pointer is being dereferenced. Can you provide the code for 
"pham\db\db_skdatabase.d" at L138 through 140 ?


    ```d
    package(pham.db):  // Line# 133
    final DbReadBuffer acquireSocketReadBuffer(size_t capacity = 
DbDefaultSize.socketReadBufferLength) nothrow @safe

    {
    version (TraceFunction) dgFunctionTrace();

    if (_socketReadBuffer is null)
    _socketReadBuffer = createSocketReadBuffer(capacity);
    return _socketReadBuffer;
    }
    ```


The entire codes is available from github
https://github.com/apz28/dlang/blob/main/source/pham/db/db_skdatabase.d#L138 



1. That filename is totally wrong, or the function name is totally 
wrong. ddemangle says the function is `@safe bool[] 
pham.db.fbdatabase.FbArray.readArrayImpl!(bool).readArrayImpl(pham.db.database.DbNameColumn)` 
which seems to be located 
[here](https://github.com/apz28/dlang/blob/02989b94bfe306d723f2780e010c61f71f873cbe/source/pham/db/db_fbdatabase.d#L142) 
But the line numbers also don't match. maybe an inlining issue?


2. It's hard for me to see where the null dereference would be in that 
function (the `bool` implementation is pretty simple).


-Steve


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-21 Thread Dukc via Digitalmars-d-learn
On Wednesday, 21 July 2021 at 14:15:51 UTC, Steven Schveighoffer 
wrote:
2. It's hard for me to see where the null dereference would be 
in that function (the `bool` implementation is pretty simple).


-Steve


DMD complains about dereferences in three different lines. I 
suspect it's `this` reference that is `null`.


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-22 Thread apz28 via Digitalmars-d-learn

On Wednesday, 21 July 2021 at 20:39:54 UTC, Dukc wrote:
On Wednesday, 21 July 2021 at 14:15:51 UTC, Steven 
Schveighoffer wrote:
2. It's hard for me to see where the null dereference would be 
in that function (the `bool` implementation is pretty simple).


-Steve


DMD complains about dereferences in three different lines. I 
suspect it's `this` reference that is `null`.


Look like DMD has some bug. If I changed this line 
https://github.com/apz28/dlang/blob/02989b94bfe306d723f2780e010c61f71f873cbe/source/pham/db/db_fbdatabase.d#L148


from: auto reader = FbXdrReader(null, response.data);
to: auto reader = FbXdrReader(fbConnection, response.data);

then the error go away. FbXdrReader constructor allows to accept 
null for that parameter. Is it "safe" means not allow to pass 
null?


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn

On 7/22/21 2:38 PM, apz28 wrote:

On Wednesday, 21 July 2021 at 20:39:54 UTC, Dukc wrote:

On Wednesday, 21 July 2021 at 14:15:51 UTC, Steven Schveighoffer wrote:
2. It's hard for me to see where the null dereference would be in 
that function (the `bool` implementation is pretty simple).




DMD complains about dereferences in three different lines. I suspect 
it's `this` reference that is `null`.


Look like DMD has some bug. If I changed this line 
https://github.com/apz28/dlang/blob/02989b94bfe306d723f2780e010c61f71f873cbe/source/pham/db/db_fbdatabase.d#L148 



from: auto reader = FbXdrReader(null, response.data);
to: auto reader = FbXdrReader(fbConnection, response.data);

then the error go away. FbXdrReader constructor allows to accept null 
for that parameter. Is it "safe" means not allow to pass null?


I don't know what an FbConnection is, but it looks like you call 
something on it. Your code is immense, and github search really *really* 
sucks. So I can't get better information. But if it's a class, and that 
is a normal member, it is indeed dereferencing a null pointer.


-Steve


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-22 Thread apz28 via Digitalmars-d-learn
On Thursday, 22 July 2021 at 18:56:43 UTC, Steven Schveighoffer 
wrote:

On 7/22/21 2:38 PM, apz28 wrote:

On Wednesday, 21 July 2021 at 20:39:54 UTC, Dukc wrote:
On Wednesday, 21 July 2021 at 14:15:51 UTC, Steven 
Schveighoffer wrote:
2. It's hard for me to see where the null dereference would 
be in that function (the `bool` implementation is pretty 
simple).




DMD complains about dereferences in three different lines. I 
suspect it's `this` reference that is `null`.


Look like DMD has some bug. If I changed this line 
https://github.com/apz28/dlang/blob/02989b94bfe306d723f2780e010c61f71f873cbe/source/pham/db/db_fbdatabase.d#L148



from: auto reader = FbXdrReader(null, response.data);
to: auto reader = FbXdrReader(fbConnection, response.data);

then the error go away. FbXdrReader constructor allows to 
accept null for that parameter. Is it "safe" means not allow 
to pass null?


I don't know what an FbConnection is, but it looks like you 
call something on it. Your code is immense, and github search 
really *really* sucks. So I can't get better information. But 
if it's a class, and that is a normal member, it is indeed 
dereferencing a null pointer.


-Steve


FbConnection is a class, FbXdrReader is a struct and for this 
call, response.data is not null & its' length will be greater 
than zero and FbConnection is not being used. So why DMD try to 
evaluate at compiled time hence error
1. Should not evaluate at compile time for this function 
call/construct
2. The error message is missing proper line # or nothing related 
to the module displayed in error message


https://github.com/apz28/dlang/blob/main/source/pham/db/db_fbbuffer.d#L527



Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-23 Thread Steven Schveighoffer via Digitalmars-d-learn

On 7/22/21 7:43 PM, apz28 wrote:

FbConnection is a class, FbXdrReader is a struct and for this call, 
response.data is not null & its' length will be greater than zero and 
FbConnection is not being used. So why DMD try to evaluate at compiled 
time hence error

1. Should not evaluate at compile time for this function call/construct
2. The error message is missing proper line # or nothing related to the 
module displayed in error message


https://github.com/apz28/dlang/blob/main/source/pham/db/db_fbbuffer.d#L527



I have a feeling that line is backwards.

It says: if the buffer has length, ignore it and use the connection, 
otherwise use the (empty) buffer data.


So perhaps this is actually a real error that is being flagged (because 
it's inlined)?


In any case, it's possible that fbConnection being null does not mean a 
null dereference, but I'd have to see the class itself. I'm surprised if 
you don't get a null dereference in non-release mode, unless this code 
is never actually called.


-Steve


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-23 Thread apz28 via Digitalmars-d-learn
On Friday, 23 July 2021 at 18:44:47 UTC, Steven Schveighoffer 
wrote:

On 7/22/21 7:43 PM, apz28 wrote:



In any case, it's possible that fbConnection being null does 
not mean a null dereference, but I'd have to see the class 
itself. I'm surprised if you don't get a null dereference in 
non-release mode, unless this code is never actually called.


-Steve


The -debug build with passing unit-tests so no problem there.
The -release build is having problem. After make change to 
accommodate it, it takes forever to build. I started it yesterday 
11AM and it is still compiling now (more than a day already.) It 
takes a full 100% core and peek memory usage is 2.2GB. The 
hard-drive is SSD


Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-23 Thread Ali Çehreli via Digitalmars-d-learn

On 7/23/21 12:30 PM, apz28 wrote:

> The -debug build with passing unit-tests so no problem there.
> The -release build is having problem. After make change to accommodate
> it, it takes forever to build. I started it yesterday 11AM and it is
> still compiling now (more than a day already.) It takes a full 100% core
> and peek memory usage is 2.2GB. The hard-drive is SSD

There is definitely something wrong with the compiler. That build time 
is ridiculously high.


Ali



Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-23 Thread Steven Schveighoffer via Digitalmars-d-learn

On 7/23/21 3:30 PM, apz28 wrote:

On Friday, 23 July 2021 at 18:44:47 UTC, Steven Schveighoffer wrote:

On 7/22/21 7:43 PM, apz28 wrote:



In any case, it's possible that fbConnection being null does not mean 
a null dereference, but I'd have to see the class itself. I'm 
surprised if you don't get a null dereference in non-release mode, 
unless this code is never actually called.




The -debug build with passing unit-tests so no problem there.
The -release build is having problem. After make change to accommodate 
it, it takes forever to build. I started it yesterday 11AM and it is 
still compiling now (more than a day already.) It takes a full 100% core 
and peek memory usage is 2.2GB. The hard-drive is SSD


That is a separate problem. That build is hung, and you likely have 
found a bug in the compiler. I have never seen a build last more than a 
few minutes at the most.


If the code you posted is not crashing with a segfault, then it's 
possible there is a code generation issue. I still believe you have your 
check backwards.


-Steve