digitalmars.D.learn - How to Fix Weird Build Failure with "-release" but OK with "-debug"?
- apz28 (22/22) Jul 20 2021 VisualD project - Any hint to work around
- Mathias LANG (4/16) Jul 20 2021 It seems the compiler is doing extra analysis and seeing that a
- apz28 (13/16) Jul 21 2021 ```d
- apz28 (3/20) Jul 21 2021 The entire codes is available from github
- Steven Schveighoffer (10/34) Jul 21 2021 1. That filename is totally wrong, or the function name is totally
- Dukc (4/7) Jul 21 2021 DMD complains about dereferences in three different lines. I
- apz28 (8/16) Jul 22 2021 Look like DMD has some bug. If I changed this line
- Steven Schveighoffer (6/24) Jul 22 2021 I don't know what an FbConnection is, but it looks like you call
- apz28 (11/39) Jul 22 2021 FbConnection is a class, FbXdrReader is a struct and for this
- Steven Schveighoffer (11/21) Jul 23 2021 I have a feeling that line is backwards.
- apz28 (8/14) Jul 23 2021 The -debug build with passing unit-tests so no problem there.
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/9) Jul 23 2021 There is definitely something wrong with the compiler. That build time
- Steven Schveighoffer (8/23) Jul 23 2021 That is a separate problem. That build is hung, and you likely have
- bauss (6/28) Jul 21 2021 The problem here is not actually -release but -O.
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
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__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAbIt 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
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
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:The entire codes is available from github https://github.com/apz28/dlang/blob/main/source/pham/db/db_skdatabase.d#L138It 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
On 7/21/21 7:56 AM, apz28 wrote:On Wednesday, 21 July 2021 at 11:52:39 UTC, apz28 wrote: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). -SteveOn Wednesday, 21 July 2021 at 04:52:44 UTC, Mathias LANG wrote:The entire codes is available from github https://github.com/apz28/dlang/blob/main/source/pham/db/db_skdatabase.d#L138It 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
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). -SteveDMD complains about dereferences in three different lines. I suspect it's `this` reference that is `null`.
Jul 21 2021
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: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?2. It's hard for me to see where the null dereference would be in that function (the `bool` implementation is pretty simple). -SteveDMD complains about dereferences in three different lines. I suspect it's `this` reference that is `null`.
Jul 22 2021
On 7/22/21 2:38 PM, apz28 wrote:On Wednesday, 21 July 2021 at 20:39:54 UTC, Dukc wrote: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. -SteveOn Wednesday, 21 July 2021 at 14:15:51 UTC, Steven Schveighoffer wrote: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?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`.
Jul 22 2021
On Thursday, 22 July 2021 at 18:56:43 UTC, Steven Schveighoffer wrote:On 7/22/21 2:38 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 to the module displayed in error message https://github.com/apz28/dlang/blob/main/source/pham/db/db_fbbuffer.d#L527On Wednesday, 21 July 2021 at 20:39:54 UTC, Dukc wrote: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. -SteveOn Wednesday, 21 July 2021 at 14:15:51 UTC, Steven Schveighoffer wrote: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?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`.
Jul 22 2021
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#L527I 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
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. -SteveThe -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
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 SSDThere is definitely something wrong with the compiler. That build time is ridiculously high. Ali
Jul 23 2021
On 7/23/21 3:30 PM, apz28 wrote:On Friday, 23 July 2021 at 18:44:47 UTC, Steven Schveighoffer wrote: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. -SteveOn 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
Jul 23 2021
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__T13readArrayImplTbZQsMFNfCQCeQCc8database12DbNameColumnZAbThe 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