www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to Fix Weird Build Failure with "-release" but OK with "-debug"?

reply apz28 <home home.com> writes:
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
Jul 20 2021
next sibling parent reply Mathias LANG <geod24 gmail.com> writes:
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 ?
Jul 20 2021
parent reply apz28 <home home.com> writes:
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 final DbReadBuffer acquireSocketReadBuffer(size_t capacity = DbDefaultSize.socketReadBufferLength) nothrow safe { version (TraceFunction) dgFunctionTrace(); if (_socketReadBuffer is null) _socketReadBuffer = createSocketReadBuffer(capacity); return _socketReadBuffer; } ```
Jul 21 2021
parent reply apz28 <home home.com> writes:
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 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
Jul 21 2021
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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         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.dat base.DbNameColumn)` which seems to be located [here](https://github.com/apz28/dlang/blob/02989b94bfe306d723f2780e010c61f71f873cbe/source/pham/db/d _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
Jul 21 2021
parent reply Dukc <ajieskola gmail.com> writes:
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`.
Jul 21 2021
parent reply apz28 <home home.com> writes:
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?
Jul 22 2021
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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/ b_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
Jul 22 2021
parent reply apz28 <home home.com> writes:
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 to the module displayed in error message https://github.com/apz28/dlang/blob/main/source/pham/db/db_fbbuffer.d#L527
Jul 22 2021
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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

 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
Jul 23 2021
parent reply apz28 <home home.com> writes:
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
Jul 23 2021
next sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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
Jul 23 2021
prev sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
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
Jul 23 2021
prev sibling parent bauss <jj_1337 live.dk> writes:
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.
Jul 21 2021