Re: (Unofficial) Discord Server!

2018-04-19 Thread Basile B. via Digitalmars-d
On Tuesday, 17 April 2018 at 16:44:11 UTC, Vladimir Panteleev 
wrote:

On Tuesday, 17 April 2018 at 06:43:16 UTC, JN wrote:
I prefer ergonomics of Discord/Slack/Gitter over IRC, although 
in the long run I guess IRC is good for the openness compared 
to proprietiary solution.


Have you tried Matrix / Riot?

https://riot.im/app/#/room/#freenode_#d:matrix.org


I've tried Matrix yesterday and was disapointed.

1/ One can think that there are many people but actually 90% of 
them are connected to IRC via a soft client.
2/ pseudos are no properly updated. To test i've used 0kb 
yesterday. It's still listed, right now (as M0kb[m]) but i'm not 
connected to Matrix since 20 hours i'd say.


In conclusion i still like more IRC...maybe Matrix is also about 
user using their smart phone, but so far i really don't see the 
point.





Re: DIP-1000 scope analysis doesn't kick in for small-size-optimized GC-string

2018-04-19 Thread Radu via Digitalmars-d

On Thursday, 19 April 2018 at 17:36:19 UTC, Per Nordlöw wrote:

I'm now satisfied with my SSOString at

https://github.com/nordlow/phobos-next/blob/master/src/sso_string.d

However, I'm having problems within making lifetime analysis 
via scope kick in. For instance, the function `f` at


https://github.com/nordlow/phobos-next/blob/master/src/sso_string.d#L219

shouldn't compile, but it does.

Have I missed something or is this yet another corner-case that 
requires a new bugzilla issue?


Walter?

Andrei?


Removing `scope` from the function prototype will work. See 
https://run.dlang.io/is/BIYSY4


I think it is a bug, but might be wrong as dip1000 spec is not 
up2date.


Re: D IDE Coedit 3.6.7 - now with an integrated terminal emulator.

2018-04-19 Thread Basile B. via Digitalmars-d-announce

On Tuesday, 17 April 2018 at 18:39:27 UTC, Basile B. wrote:
I hadn't announced the 5 or 6 latest releases (3.6.x series) 
but this one comes with an integrated terminal emulator (linux 
only), a bit like Geany does, if you see what i mean.


See https://github.com/BBasile/Coedit/releases for changelog 
and download links.


Now 3.6.8 with hotfixes for the Terminal. When libvte was not 
setup you could get an error message. Also i think that only 
vte-devel was supported (the so file w/o number at the end). Same 
links.


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Dmitry Olshansky via Digitalmars-d

On Friday, 20 April 2018 at 00:11:25 UTC, Matthias Klumpp wrote:

On Thursday, 19 April 2018 at 18:45:41 UTC, kinke wrote:

[...]


Jup, I did that already, it just took a really long time to run 
because when I made the change to print errno I also enabled 
detailed GC profiling (via the PRINTF* debug options). Enabling 
the INVARIANT option for the GC is completely broken by the 
way, I enforced the compile to work by casting to shared, with 
the result of the GC locking up forever at the start of the 
program.


[...]


I think the order of operations is wrong, here is an example from 
containers:


allocator.dispose(buckets);
static if (useGC)
GC.removeRange(buckets.ptr);

If GC triggers between dispose and removeRange, it will likely 
segfault.



[1]: https://github.com/dlang-community/containers


Re: wstring double quotes to string double quotes

2018-04-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 19, 2018 23:24:05 Joel via Digitalmars-d-learn wrote:
> On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe wrote:
> > On Thursday, 19 April 2018 at 21:53:52 UTC, Joel wrote:
> >> I have a program that uses string double quotes, but copies
> >> from wstring double quotes. The wstring double quotes are in
> >> string type (sourceTxt is a string with wstring double quotes).
> >
> > quotes are quotes, you don't need to convert to wstring here.
> >
> > I really don't think it should be throwing that error
> > regardless... but you also should be able to just do
> >
> > string[] sourceLines = sourceTxt.replace("”", `"`).split("\n");
> >
> > and skip the wstring part entirely.
>
> That worked! Thanks Adam.

Given that these functions really shouldn't be throw RangeErrors, please
create a bug report with example code that can someone can just run to
reproduce the issue (your example isn't runnable as-is). That way, the bug
can be fixed. Otherwise, it's probably just going to be lost, and someone
else may hit it in the future. Thanks.

https://issues.dlang.org

- Jonathan M Davis




Re: Feature to get or add value to an associative array.

2018-04-19 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, April 18, 2018 17:19:45 Giles Bathgate via Digitalmars-d 
wrote:
> On Sunday, 15 April 2018 at 22:55:41 UTC, Giles Bathgate wrote:
> > Time for a bikeshed discussion...
>
> I have had some thoughts about the name and would like to share
> my idea.
>
> Firstly to summarise here are the names that have been
> found/discussed so far:
>
> C#   : GetOrAdd
> Java : computeIfAbsent
> Python   : setdefault
> Rust : entry(key).or_insert_with
>
> Jordan Wilson: getOrAdd, getOrSet
> User1234 : valueOrDefault
> Nicholas Wilson  : getOrInsert
> Steven Schveighoffer : getPtr, getRef, getInitialized
> Nick Treleaven   : slot
> MrSmith  : getOrCreate
>
> My latest idea is just a working title, but I think I prefer it
> to my original getOrAdd.
>
> Giles Bathgate   : require
>
> My thinking is that if you `require` there to be a value in the
> associative array, then you should have the ability to add one
> iff it doesn't exist. It name also has parallels with the term in
> other programming languages to require a module, meaning to
> import it if it hasn't already been loaded.

Out of all of those, I _really_ hope that you don't go with require. It
sounds like the sort of thing that you'd get in a library having to do with
unit testing or contracts and gives no indication whatsoever as to what it
does. The only one in that list that seems similarly opaque is slot. Those
names say nothing about either getting a value or adding / inserting one.
Every other name at least gives some clue as to what the function does.

If I were adding it, and we already had get, I would just make it an
optional argument to get, which wouldn't necessarily be clear about
inserting, but it would at least be clear about getting. However, since we
used overloaded operators, there's no get.

Another option would be getOrInit, though I agree that they're all kind of
ugly.

Either way, IMHO, getOrAdd is infinitely better than require.

- Jonathan M Davis



Re: dxml 0.3.0 released

2018-04-19 Thread Jonathan M Davis via Digitalmars-d-announce
On Thursday, April 19, 2018 23:00:03 Jesse Phillips via Digitalmars-d-
announce wrote:
> On Thursday, 19 April 2018 at 14:40:58 UTC, Jonathan M Davis
>
> wrote:
> > I won't repeat everything that's in the changelog, but the
> > biggest changes are that writer support has now been added, and
> > it's now possible to configure how the parser handles
> > non-standard entity references.
>
> In reference to
> http://jmdavisprog.com/docs/dxml/0.3.0/dxml_writer.html#.XMLWriter.writeTe
> xt
>
> "XMLWritingException if the given text is not legal in the text
> portion of an XML document."
>
> Is this to say that the text must be encoded
> (dxml.util.encodeText) prior to calling this or it will throw if
> the text contains "<"?
>
> This should be clearer in the documentation.

Yes. I would have thought that that was clear. It throws if any of the
characters or sequence of characters in the argument aren't legal in the
text portion of an XML document. Those characters that can be legally
present in encoded form but not in their literal form can be encoded first
with encodeText. I'll try to make the documentation clearer.

- Jonathan M Davis



Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Matthias Klumpp via Digitalmars-d

On Friday, 20 April 2018 at 00:11:25 UTC, Matthias Klumpp wrote:

[...]
Jup, I did that already, it just took a really long time to run 
because when I made the change to print errno [...]


I forgot to mention that, the error code was 12, ENOMEM, so this 
is actually likely not a relevant issue afterall.




Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Matthias Klumpp via Digitalmars-d

On Thursday, 19 April 2018 at 18:45:41 UTC, kinke wrote:
On Thursday, 19 April 2018 at 17:01:48 UTC, Matthias Klumpp 
wrote:
Something that maybe is relevant though: I occasionally get 
the following SIGABRT crash in the tool on machines which have 
the SIGSEGV crash:

```
Thread 53 "appstream-gener" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fdfe98d4700 (LWP 7326)]
0x75040428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or 
directory.

(gdb) bt
#0  0x75040428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54

#1  0x7504202a in __GI_abort () at abort.c:89
#2  0x00780ae0 in core.thread.Fiber.allocStack(ulong, 
ulong) (this=0x7fde0758a680, guardPageSize=4096, sz=20480) at 
src/core/thread.d:4606
#3  0x007807fc in 
_D4core6thread5Fiber6__ctorMFNbDFZvmmZCQBlQBjQBf 
(this=0x7fde0758a680, guardPageSize=4096, sz=16384, dg=...)

at src/core/thread.d:4134
#4  0x006f9b31 in 
_D3std11concurrency__T9GeneratorTAyaZQp6__ctorMFDFZvZCQCaQBz__TQBpTQBiZQBx (this=0x7fde0758a680, dg=...)
at 
/home/ubuntu/dtc/dmd/generated/linux/debug/64/../../../../../druntime/import/core/thread.d:4126
#5  0x006e9467 in 
_D5asgen8handlers11iconhandler5Theme21matchingIconFilenamesMFAyaSQCl5utils9ImageSizebZC3std11concurrency__T9GeneratorTQCfZQp (this=0x7fdea2747800, relaxedScalingRules=true, size=..., iname=...) at ../src/asgen/handlers/iconhandler.d:196
#6  0x006ea75a in 
_D5asgen8handlers11iconhandler11IconHandler21possibleIconFilenamesMFAyaSQCs5utils9ImageSizebZ9__lambda4MFZv (this=0x7fde0752bd00)

at ../src/asgen/handlers/iconhandler.d:392
#7  0x0082fdfa in core.thread.Fiber.run() 
(this=0x7fde07528580) at src/core/thread.d:4436
#8  0x0082fd5d in fiber_entryPoint () at 
src/core/thread.d:3665

#9  0x in  ()
```


You probably already figured that the new Fiber seems to be 
allocating its 16KB-stack, with an additional 4 KB guard page 
at its bottom, via a 20 KB mmap() call. The abort seems to be 
triggered by mprotect() returning -1, i.e., a failure to 
disallow all access to the the guard page; so checking `errno` 
should help.


Jup, I did that already, it just took a really long time to run 
because when I made the change to print errno I also enabled 
detailed GC profiling (via the PRINTF* debug options). Enabling 
the INVARIANT option for the GC is completely broken by the way, 
I enforced the compile to work by casting to shared, with the 
result of the GC locking up forever at the start of the program.


Anyway, I think for a chance I actually produced some useful 
information via the GC debug options:

Given the following crash:
```
#0  0x007f1d94 in 
_D2gc4impl12conservativeQw3Gcx4markMFNbNlPvQcZv (this=..., 
ptop=0x7fdfce7fc010, pbot=0x7fdfcdbfc010)

at src/gc/impl/conservative/gc.d:1990
p1 = 0x7fdfcdbfc010
p2 = 0x7fdfce7fc010
stackPos = 0
[...]
```
The scanned range seemed fairly odd to me, so I searched for it 
in the (very verbose!) GC debug output, which yielded:

```
235.25: 0xc4f090.Gcx::addRange(0x8264230, 0x8264270)
235.244460: 0xc4f090.Gcx::addRange(0x7fdfcdbfc010, 0x7fdfce7fc010)
235.253861: 0xc4f090.Gcx::addRange(0x8264300, 0x8264340)
235.253873: 0xc4f090.Gcx::addRange(0x8264390, 0x82643d0)
```
So, something is calling addRange explicitly there, causing the 
GC to scan a range that it shouldn't scan. Since my code doesn't 
add ranges to the GC, and I looked at the generated code from 
girtod/GtkD and it very much looks fine to me, I am currently 
looking into EMSI containers[1] as the possible culprit.
That library being the issue would also make perfect sense, 
because this issue started to appear with such a frequency only 
after containers were added (there was a GC-related crash before, 
but that might have been a different one).


So, I will look into that addRange call next.

[1]: https://github.com/dlang-community/containers



[Issue 18782] New: Documentation error: ProtectionAttributes should say Visibility Attributes

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18782

  Issue ID: 18782
   Summary: Documentation error: ProtectionAttributes should say
Visibility Attributes
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: james.blac...@gmail.com

This section: https://dlang.org/spec/class.html#access_control

links to: https://dlang.org/spec/attribute.html#ProtectionAttribute

but should link to:

https://dlang.org/spec/attribute.html#visibility_attributes

As the anchor #ProtectionAttribute does not exist, nor does the term in the
attributes definitions page.

--


[Issue 18781] New: std.string.replace: RangeError when replacing with inconsistent string types

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18781

  Issue ID: 18781
   Summary: std.string.replace: RangeError when replacing with
inconsistent string types
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: dhase...@gmail.com

void main()
{
import std.string : replace;
"”quote”"w.replace("”", `"`);
}


This crashes with:

core.exception.RangeError@/usr/include/dmd/phobos/std/array.d(2167): Range
violation

??:? _d_arrayboundsp [0x42c4ee]
/usr/include/dmd/phobos/std/array.d:2167 pure @safe void
std.array.replaceInto!(immutable(wchar),
std.array.Appender!(immutable(wchar)[]).Appender, immutable(char)[],
immutable(char)[]).replaceInto(std.array.Appender!(immutable(wchar)[]).Appender,
immutable(wchar)[], immutable(char)[], immutable(char)[]) [0x42b107]
/usr/include/dmd/phobos/std/array.d:2098 pure @safe immutable(wchar)[]
std.array.replace!(immutable(wchar), immutable(char)[],
immutable(char)[]).replace(immutable(wchar)[], immutable(char)[],
immutable(char)[]) [0x42a01b]
wstringcrash.d:4 _Dmain [0x429669]


Note that the string operated on is a wstring, and the replacements are
strings.

Conversely, calling `replace(string, wstring, wstring)` tends to result in
invalid UTF-8 sequences:

"☃ world.".replace("☃"w, `:`w);

std.utf.UTFException@/usr/include/dmd/phobos/std/utf.d(1380): Invalid UTF-8
sequence (at index 2)

--


Re: wstring double quotes to string double quotes

2018-04-19 Thread Joel via Digitalmars-d-learn

On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe wrote:

On Thursday, 19 April 2018 at 21:53:52 UTC, Joel wrote:
I have a program that uses string double quotes, but copies 
from wstring double quotes. The wstring double quotes are in 
string type (sourceTxt is a string with wstring double quotes).


quotes are quotes, you don't need to convert to wstring here.

I really don't think it should be throwing that error 
regardless... but you also should be able to just do


string[] sourceLines = sourceTxt.replace("”", `"`).split("\n");

and skip the wstring part entirely.


That worked! Thanks Adam.


Re: dxml 0.3.0 released

2018-04-19 Thread Jesse Phillips via Digitalmars-d-announce
On Thursday, 19 April 2018 at 14:40:58 UTC, Jonathan M Davis 
wrote:


I won't repeat everything that's in the changelog, but the 
biggest changes are that writer support has now been added, and 
it's now possible to configure how the parser handles 
non-standard entity references.


In reference to 
http://jmdavisprog.com/docs/dxml/0.3.0/dxml_writer.html#.XMLWriter.writeText


"XMLWritingException if the given text is not legal in the text 
portion of an XML document."


Is this to say that the text must be encoded 
(dxml.util.encodeText) prior to calling this or it will throw if 
the text contains "<"?


This should be clearer in the documentation.


Re: dxml 0.3.0 released

2018-04-19 Thread aberba via Digitalmars-d-announce
On Thursday, 19 April 2018 at 14:40:58 UTC, Jonathan M Davis 
wrote:
Well, since I'm going to be talking about dxml at dconf, and 
it's likely that I'll be talking about stuff that was not in 
the 0.2.* releases, it seemed like I should get a new release 
out before dconf. So, here it is.


dxml 0.3.0 has now been released.

I won't repeat everything that's in the changelog, but the 
biggest changes are that writer support has now been added, and 
it's now possible to configure how the parser handles 
non-standard entity references.


Please report any bugs that you find via github.

Changelog: http://jmdavisprog.com/changelog/dxml/0.3.0.html
Documentation: http://jmdavisprog.com/docs/dxml/0.3.0/
Github: https://github.com/jmdavis/dxml/tree/v0.3.0
Dub: http://code.dlang.org/packages/dxml

- Jonathan M Davis


I understand XML is more powerful for some stuff... however XML 
libs naming conventions generally seem verbose (thanks 
Microsoft)...I've never used XML beyound HTML though. I started 
with JSON and has always been JSON.


Re: Small Buffer Optimization for string and friends

2018-04-19 Thread Manu via Digitalmars-d
On 19 April 2018 at 02:22, Walter Bright via Digitalmars-d
 wrote:
> On 4/8/2012 7:26 AM, Manu wrote:
>>
>> Is it realistic that anyone can actually use raw d-string's in an app that
>> performs a lot of string manipulation? I bet most people end up with a
>> custom string class anyway...
>> Who's written a string-heavy app without their own string helper class? I
>> ended up with a string class within about half an hour of trying to work
>> with D strings (initially just to support stack strings, then it grew).
>
>
> Warp (a fast C preprocessor)
>
> https://github.com/facebookarchive/warp

Cool story... 6 years later! :P


Re: wstring double quotes to string double quotes

2018-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 19 April 2018 at 21:53:52 UTC, Joel wrote:
I have a program that uses string double quotes, but copies 
from wstring double quotes. The wstring double quotes are in 
string type (sourceTxt is a string with wstring double quotes).


quotes are quotes, you don't need to convert to wstring here.

I really don't think it should be throwing that error 
regardless... but you also should be able to just do


string[] sourceLines = sourceTxt.replace("”", `"`).split("\n");

and skip the wstring part entirely.


wstring double quotes to string double quotes

2018-04-19 Thread Joel via Digitalmars-d-learn
I have a program that uses string double quotes, but copies from 
wstring double quotes. The wstring double quotes are in string 
type (sourceTxt is a string with wstring double quotes).


The following code crashes with an array.d(2211): Range violation 
error:


import std.conv : to;
import std.string : replace;

auto sourceTxtW = sourceTxt.to!wstring;
sourceTxtW.replace("”", `"`);
auto sourceTxtR = sourceTxtW.to!string;
sourceLines = sourceTxtR.split("\n");


Re: DPushBot for Discord

2018-04-19 Thread WebFreak001 via Digitalmars-d-announce

On Thursday, 19 April 2018 at 20:53:40 UTC, WebFreak001 wrote:
Hi, I made a tool which periodically monitors dub for new 
packages and a DFeed subscription for new posts and then sends 
updates to a discord webhook.


If you host it yourself you can put in any subscription ATOM 
feed, so you could monitor your own projects, etc. and 
broadcast them on your discord server.


It would probably be very easy to port this to slack too.

Currently this is deployed on the D Code Club (which you 
totally should join, all the cool stuff is on there and we have 
nearly 200 members) if you want to see it live: 
https://discord.gg/bMZk9Q4


(to be honest, this is just a test post to check if the DFeed 
thing is working properly with this feed)


oops forgot the source code: 
https://github.com/WebFreak001/d-push-bot


DPushBot for Discord

2018-04-19 Thread WebFreak001 via Digitalmars-d-announce
Hi, I made a tool which periodically monitors dub for new 
packages and a DFeed subscription for new posts and then sends 
updates to a discord webhook.


If you host it yourself you can put in any subscription ATOM 
feed, so you could monitor your own projects, etc. and broadcast 
them on your discord server.


It would probably be very easy to port this to slack too.

Currently this is deployed on the D Code Club (which you totally 
should join, all the cool stuff is on there and we have nearly 
200 members) if you want to see it live: 
https://discord.gg/bMZk9Q4


(to be honest, this is just a test post to check if the DFeed 
thing is working properly with this feed)


Re: Getting the overload set of a template

2018-04-19 Thread Simen Kjærås via Digitalmars-d-learn

On Thursday, 19 April 2018 at 13:57:04 UTC, Simen Kjærås wrote:

On Tuesday, 17 April 2018 at 14:22:27 UTC, Arafel wrote:

Hi!

Is there any way to get the full set of templates that are 
"overloaded" (in my case, based on constraints)?


Currently, there is no way (that I've found, at least) to do 
this. If you have a workaround, that's great, but there really 
should be a way - probably __traits(getOverloads). Having 
__traits(getOverloads) return templates as well should fix some 
of the issues __traits(getOverloads) has, as a bonus.


https://github.com/dlang/dmd/pull/8195

--
  Simen


[Issue 7549] typeof of overloaded function picks the lexically first one

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=7549

Simen Kjaeraas  changed:

   What|Removed |Added

 CC||luka8...@owave.net

--- Comment #9 from Simen Kjaeraas  ---
*** Issue 8780 has been marked as a duplicate of this issue. ***

--


[Issue 8780] std.traits.ReturnType of overloaded functions

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8780

Simen Kjaeraas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||simen.kja...@gmail.com
 Resolution|--- |DUPLICATE

--- Comment #4 from Simen Kjaeraas  ---


*** This issue has been marked as a duplicate of issue 7549 ***

--


[Issue 7549] typeof of overloaded function picks the lexically first one

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=7549

Simen Kjaeraas  changed:

   What|Removed |Added

 CC||mattbowiewil...@gmail.com

--- Comment #8 from Simen Kjaeraas  ---
*** Issue 18777 has been marked as a duplicate of this issue. ***

--


[Issue 16206] traits getOverloads fails when one of the overload is a templatized function

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16206

Simen Kjaeraas  changed:

   What|Removed |Added

 CC||simen.kja...@gmail.com

--- Comment #2 from Simen Kjaeraas  ---
PR: https://github.com/dlang/dmd/pull/8195

--


[Issue 18777] std.traits.RetrunType ambiguity

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18777

Simen Kjaeraas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||simen.kja...@gmail.com
 Resolution|--- |DUPLICATE

--- Comment #2 from Simen Kjaeraas  ---


*** This issue has been marked as a duplicate of issue 7549 ***

--


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread kinke via Digitalmars-d

On Thursday, 19 April 2018 at 17:01:48 UTC, Matthias Klumpp wrote:
Something that maybe is relevant though: I occasionally get the 
following SIGABRT crash in the tool on machines which have the 
SIGSEGV crash:

```
Thread 53 "appstream-gener" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fdfe98d4700 (LWP 7326)]
0x75040428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or 
directory.

(gdb) bt
#0  0x75040428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54

#1  0x7504202a in __GI_abort () at abort.c:89
#2  0x00780ae0 in core.thread.Fiber.allocStack(ulong, 
ulong) (this=0x7fde0758a680, guardPageSize=4096, sz=20480) at 
src/core/thread.d:4606
#3  0x007807fc in 
_D4core6thread5Fiber6__ctorMFNbDFZvmmZCQBlQBjQBf 
(this=0x7fde0758a680, guardPageSize=4096, sz=16384, dg=...)

at src/core/thread.d:4134
#4  0x006f9b31 in 
_D3std11concurrency__T9GeneratorTAyaZQp6__ctorMFDFZvZCQCaQBz__TQBpTQBiZQBx (this=0x7fde0758a680, dg=...)
at 
/home/ubuntu/dtc/dmd/generated/linux/debug/64/../../../../../druntime/import/core/thread.d:4126
#5  0x006e9467 in 
_D5asgen8handlers11iconhandler5Theme21matchingIconFilenamesMFAyaSQCl5utils9ImageSizebZC3std11concurrency__T9GeneratorTQCfZQp (this=0x7fdea2747800, relaxedScalingRules=true, size=..., iname=...) at ../src/asgen/handlers/iconhandler.d:196
#6  0x006ea75a in 
_D5asgen8handlers11iconhandler11IconHandler21possibleIconFilenamesMFAyaSQCs5utils9ImageSizebZ9__lambda4MFZv (this=0x7fde0752bd00)

at ../src/asgen/handlers/iconhandler.d:392
#7  0x0082fdfa in core.thread.Fiber.run() 
(this=0x7fde07528580) at src/core/thread.d:4436
#8  0x0082fd5d in fiber_entryPoint () at 
src/core/thread.d:3665

#9  0x in  ()
```


You probably already figured that the new Fiber seems to be 
allocating its 16KB-stack, with an additional 4 KB guard page at 
its bottom, via a 20 KB mmap() call. The abort seems to be 
triggered by mprotect() returning -1, i.e., a failure to disallow 
all access to the the guard page; so checking `errno` should help.


Re: Getting the overload set of a template

2018-04-19 Thread Simen Kjærås via Digitalmars-d-learn

On Thursday, 19 April 2018 at 14:16:21 UTC, Alex wrote:

On Thursday, 19 April 2018 at 13:57:04 UTC, Simen Kjærås wrote:
Currently, there is no way (that I've found, at least) to do 
this. If you have a workaround, that's great, but there really 
should be a way - probably __traits(getOverloads). Having 
__traits(getOverloads) return templates as well should fix 
some of the issues __traits(getOverloads) has, as a bonus.




Would it be possible at all? I mean, if the two following codes 
are equivalent

´´´
@S("Has foo_A") template foo(string s) if (s == "a") {
enum foo = "foo_A";
}
@S("Has foo_B") template foo(string s) if (s == "b") {
enum foo = "foo_B";
}
´´´


´´´
template foo(string s)
{
static if (s == "a")
{
   @S("Has foo_A") enum foo = "foo_A";
}
else static if (s == "b")
{
  @S("Has foo_B") enum foo = "foo_B";
}
}
´´´

How would you define a "template overload"?
And which "overloads" would you like to get if constraints are 
more general?
And last but not least, the getOverloads is defined on 
functions, which are callable, whereas templates are not, in 
general...


Your first example defines two templates (which are overloads of 
the same name), the second only one. There's no ambiguity there.


Since template instantiation is analogous to function calling 
(though one is a compile-time action, the other a run-time one), 
talking about template overloads in the same way as function 
overloads makes perfect sense. Whether the result of 
instantiating the template is a function, a value, or a type, 
it's an overload of the template.


--
  Simen


[Issue 18780] Inconsistent behavior with Variant holding int converting to unsigned types

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18780

monkeywork...@hotmail.com changed:

   What|Removed |Added

 CC||monkeywork...@hotmail.com

--- Comment #1 from monkeywork...@hotmail.com ---
Looks like the problem is with std.traits.ImplicitConversionTargets:

pragma(msg, ImplicitConversionTargets!int); //(long, ulong, float, double,
real)

But it appears to be intentional. From ImplicitConversionTargets:


Note:
The possible targets are computed more conservatively than the
language allows, eliminating all dangerous conversions. For example,
`ImplicitConversionTargets!double` does not include `float`.

template ImplicitConversionTargets(T)
{
static if (is(T == bool))

else static if (is(T == int))
alias ImplicitConversionTargets =
AliasSeq!(long, ulong, CentTypeList, float, double, real);
else static if...
}

I don't know if it's better to change Variant or create a new, more permissible
version of ImplicitConversionTargets.

--


Re: dxml 0.3.0 released

2018-04-19 Thread H. S. Teoh via Digitalmars-d-announce
On Thu, Apr 19, 2018 at 05:21:15PM +, Suliman via Digitalmars-d-announce 
wrote:
> Am I right remember that this lib is planed to be included as std.xml
> replacement?

Yes.  I'm really looking forward to that.


T

-- 
A linguistics professor was lecturing to his class one day. "In English," he 
said, "A double negative forms a positive. In some languages, though, such as 
Russian, a double negative is still a negative. However, there is no language 
wherein a double positive can form a negative." A voice from the back of the 
room piped up, "Yeah, yeah."


Re: dxml 0.3.0 released

2018-04-19 Thread Jonathan M Davis via Digitalmars-d-announce
On Thursday, April 19, 2018 17:21:15 Suliman via Digitalmars-d-announce 
wrote:
> Am I right remember that this lib is planed to be included as
> std.xml replacement?

It is a potential candidate to replace std.xml. It is currently the plan
that once I feel that it's complete enough and battle-tested enough, I will
submit it to the Phobos review process, after which it may or may not end up
in Phobos. That will depend entirely on how that process goes.

The only other potential candidate that I'm aware of was a GSoC project that
stalled after the student disappeared (presumably, he got busy with school
again and never got back to it), and it shows no sign of ever being
completed.

- Jonathan M Davis



Re: DIP-1000 scope analysis doesn't kick in for small-size-optimized GC-string

2018-04-19 Thread Per Nordlöw via Digitalmars-d

On Thursday, 19 April 2018 at 17:36:19 UTC, Per Nordlöw wrote:
However, I'm having problems within making lifetime analysis 
via scope kick in. For instance, the function `f` at


https://github.com/nordlow/phobos-next/blob/master/src/sso_string.d#L219


Note that qualifying `opSlice` as `inout` doesn't help.


DIP-1000 scope analysis doesn't kick in for small-size-optimized GC-string

2018-04-19 Thread Per Nordlöw via Digitalmars-d

I'm now satisfied with my SSOString at

https://github.com/nordlow/phobos-next/blob/master/src/sso_string.d

However, I'm having problems within making lifetime analysis via 
scope kick in. For instance, the function `f` at


https://github.com/nordlow/phobos-next/blob/master/src/sso_string.d#L219

shouldn't compile, but it does.

Have I missed something or is this yet another corner-case that 
requires a new bugzilla issue?


Walter?

Andrei?


Re: dxml 0.3.0 released

2018-04-19 Thread Suliman via Digitalmars-d-announce
Am I right remember that this lib is planed to be included as 
std.xml replacement?


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Matthias Klumpp via Digitalmars-d

On Thursday, 19 April 2018 at 08:30:45 UTC, Kagamin wrote:
On Wednesday, 18 April 2018 at 22:24:13 UTC, Matthias Klumpp 
wrote:

size_t memSize = pooltable.maxAddr - minAddr;
(https://github.com/ldc-developers/druntime/blob/ldc/src/gc/impl/conservative/gc.d#L1982
 )
That wouldn't make sense for a pool size...

The machine this is running on has 16G memory, at the time of 
the crash the software was using ~2.1G memory, with 130G 
virtual memory due to LMDB memory mapping (I wonder what 
happens if I reduce that...)


If big LMDB mapping causes a problem, try a test like this:
---
import core.memory;
void testLMDB()
{
//how do you use it?
}
void test1()
{
void*[][] a;
foreach(i;0..10)a~=new void*[1];
void*[][] b;
foreach(i;0..10)b~=new void*[1];
b=null;
GC.collect();

testLMDB();

GC.collect();
foreach(i;0..10)a~=new void*[1];
foreach(i;0..10)b~=new void*[1];
b=null;
GC.collect();
}
---


I tried something similar, with no effect.
Something that maybe is relevant though: I occasionally get the 
following SIGABRT crash in the tool on machines which have the 
SIGSEGV crash:

```
Thread 53 "appstream-gener" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fdfe98d4700 (LWP 7326)]
0x75040428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or 
directory.

(gdb) bt
#0  0x75040428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54

#1  0x7504202a in __GI_abort () at abort.c:89
#2  0x00780ae0 in core.thread.Fiber.allocStack(ulong, 
ulong) (this=0x7fde0758a680, guardPageSize=4096, sz=20480) at 
src/core/thread.d:4606
#3  0x007807fc in 
_D4core6thread5Fiber6__ctorMFNbDFZvmmZCQBlQBjQBf 
(this=0x7fde0758a680, guardPageSize=4096, sz=16384, dg=...)

at src/core/thread.d:4134
#4  0x006f9b31 in 
_D3std11concurrency__T9GeneratorTAyaZQp6__ctorMFDFZvZCQCaQBz__TQBpTQBiZQBx (this=0x7fde0758a680, dg=...)
at 
/home/ubuntu/dtc/dmd/generated/linux/debug/64/../../../../../druntime/import/core/thread.d:4126
#5  0x006e9467 in 
_D5asgen8handlers11iconhandler5Theme21matchingIconFilenamesMFAyaSQCl5utils9ImageSizebZC3std11concurrency__T9GeneratorTQCfZQp (this=0x7fdea2747800, relaxedScalingRules=true, size=..., iname=...) at ../src/asgen/handlers/iconhandler.d:196
#6  0x006ea75a in 
_D5asgen8handlers11iconhandler11IconHandler21possibleIconFilenamesMFAyaSQCs5utils9ImageSizebZ9__lambda4MFZv (this=0x7fde0752bd00)

at ../src/asgen/handlers/iconhandler.d:392
#7  0x0082fdfa in core.thread.Fiber.run() 
(this=0x7fde07528580) at src/core/thread.d:4436
#8  0x0082fd5d in fiber_entryPoint () at 
src/core/thread.d:3665

#9  0x in  ()
```

This is in the constructor of a std.concurrency.Generator:
auto gen = new Generator!string (...)

I am not sure what to make of this yet though... This goes into 
DRuntime territory that I actually hoped to never have to deal 
with as much as I apparently need to now.




Re: D to Javascript converter (a hacked up dmd)

2018-04-19 Thread Adam D. Ruppe via Digitalmars-d-announce

On Thursday, 19 April 2018 at 16:20:22 UTC, Jonathan I Levi wrote:

Did this thing ever get to a release/usable point?


Not really. I didn't find it worth the trouble after using it in 
a few experimental projects and basically let it go like six 
years ago.


The compiler has significantly changed since then, so it'd have 
to be rewritten. You might use the ldc fork with emscripten 
instead (of you don't mind code bloat. that is something that 
bothers me...)


Re: D vs nim

2018-04-19 Thread Per Nordlöw via Digitalmars-d

On Friday, 10 April 2015 at 18:52:24 UTC, weaselcat wrote:

P.S., the example on the language's frontpage is cool!

http://nim-lang.org/

Why should I be excited?
Nim is the only language that leverages automated proof 
technology to perform a disjoint check for your parallel code. 
Working on disjoint data means no locking is required and yet 
data races are impossible:


I believe Rust's rayon [1] can do this too...

[1] https://github.com/rayon-rs/rayon


Re: GDB + ddemangle

2018-04-19 Thread Craig Dillabaugh via Digitalmars-d-announce

On Thursday, 19 April 2018 at 12:43:36 UTC, ANtlord wrote:
Hello! I've written a piece of glue code that helps to debug D 
code using GDB. The code glues together GDB and ddmangle. 
Checkout the link https://github.com/ANtlord/gdb-ddemangle


PRs are welcome!


Nice work.


Re: D to Javascript converter (a hacked up dmd)

2018-04-19 Thread Jonathan I Levi via Digitalmars-d-announce

Did this thing ever get to a release/usable point?


Re: get literal symbol name without base class/struct as string

2018-04-19 Thread Timoses via Digitalmars-d-learn

On Tuesday, 17 April 2018 at 21:45:45 UTC, Dr.No wrote:

give structs like this:

struct A
{
int a = 10;
string s = "haha";
}

struct B
{
A aDetails;
}

but neither fullyQualifiedName nor stringof give the symbol in 
the way I need.


I'd hint you towards

import std.traits;
pragma(msg, FieldNameTuple!B);
pragma(msg, FieldNameTuple!(Fields!B[0]));


Re: Getting the overload set of a template

2018-04-19 Thread Arafel via Digitalmars-d-learn
Well, if that's the lowering, then it's indeed hard. That doesn't mean 
it shouldn't happen, though... perhaps changing the lowering? I'm no 
compiles expert, so no idea how).


What I'd like to get is the same that I get using 
__traits(getMember,...), but repeated n times (AliasSeq perhaps?), like 
with regular overloads.


Then, whatever I can do with the first entry (the only one I can get 
currently) should also be possible with the rest. In my case, I'd like 
to access the UDAs, but I can imagine that the use case that allows us 
to get a template keeps being valid for all the "hidden" alternatives.


Also, I think that whether to use "getOverloads" or to add a new trait 
is rather an implementation detail


It's a bit frustrating being able to access only the first of a set...

A.

> Would it be possible at all? I mean, if the two following codes are 
equivalent

> ´´´
>  @S("Has foo_A") template foo(string s) if (s == "a") {
>  enum foo = "foo_A";
>  }
>  @S("Has foo_B") template foo(string s) if (s == "b") {
>  enum foo = "foo_B";
>  }
> ´´´
>
>
> ´´´
>  template foo(string s)
>  {
>  static if (s == "a")
>  {
> @S("Has foo_A") enum foo = "foo_A";
>  }
>  else static if (s == "b")
>  {
>@S("Has foo_B") enum foo = "foo_B";
>  }
>  }
> ´´´
>
> How would you define a "template overload"?
> And which "overloads" would you like to get if constraints are more 
general?
> And last but not least, the getOverloads is defined on functions, 
which are callable, whereas templates are not, in general...


Re: Linux Game Jam 2018

2018-04-19 Thread WebFreak001 via Digitalmars-d

On Thursday, 19 April 2018 at 15:12:12 UTC, bioinfornatics wrote:

On Thursday, 5 April 2018 at 18:30:30 UTC, WebFreak001 wrote:
Hi guys, I am going to make a game for this years linux game 
jam hosted by TheLinuxGamer again, last year I made SpaceD[1]


Just in case anyone else wants to join too, the link is here 
(though joining is optional I think)


https://itch.io/jam/linux-game-jam-2018

It's a 10 day jam, there is a theme this time and it's 
`Versatile Verbs`, check the page for more information


[1]: https://github.com/WebFreak001/SpaceD and 
https://webfreak.itch.io/spaced


Good luck :-)


oh yeah it's finished now, not quite how much I wanted to get 
done, but it works at least (except for animations lol) 
https://webfreak.itch.io/d-man-taiko


getSymbolByUDA and inheritance

2018-04-19 Thread Arafel via Digitalmars-d-learn

Hi,

getSymbolsByUDA doesn't work when inheritance is involved [1]:

```
import std.traits;

void main()
{
pragma(msg, getSymbolsByUDA!(A,S).length);
pragma(msg, getSymbolsByUDA!(B,S).length);
}

class A {
@S("A") int a;
}

class B : A {
@S("B") int b;
}

struct S {
string name;
}
```

The error message seems a bit weird, and after some tinkering, I've been 
able to reproduce it when creating an AliasSeq with members of both the 
parent and the child class [2]:


```
import std.meta;

void main()
{
	pragma(msg, AliasSeq!(__traits(getMember, B, "a"), __traits(getMember, 
B, "b")));

}

class A {
int a;
}

class B : A {
int b;
}
```

It seems that using __traits(getMember,...) is introducing some kind of 
hidden context to the actual class that defines the member... It looks 
like a bug to me, but there might be a reason to do it this way.


Still, whatever the reason, it definitely breaks getSymbolsByUDA when 
inheritance is involved. According to the documentation [3] only nested 
members are excluded (and in any they are just excluded, but still 
compile), so is this a bug?


[1]: https://run.dlang.io/is/502CUB
[2]: https://run.dlang.io/is/9wOIsa
[3]: https://dlang.org/library/std/traits/get_symbols_byuda.html


Re: Linux Game Jam 2018

2018-04-19 Thread bioinfornatics via Digitalmars-d

On Thursday, 5 April 2018 at 18:30:30 UTC, WebFreak001 wrote:
Hi guys, I am going to make a game for this years linux game 
jam hosted by TheLinuxGamer again, last year I made SpaceD[1]


Just in case anyone else wants to join too, the link is here 
(though joining is optional I think)


https://itch.io/jam/linux-game-jam-2018

It's a 10 day jam, there is a theme this time and it's 
`Versatile Verbs`, check the page for more information


[1]: https://github.com/WebFreak001/SpaceD and 
https://webfreak.itch.io/spaced


Good luck :-)


Re: Store struct tuple of alias and access members through it?

2018-04-19 Thread Timoses via Digitalmars-d-learn

On Saturday, 7 April 2018 at 19:21:30 UTC, Simen Kjærås wrote:

import std.meta;
import std.traits;

// List all member functions, and wrap them such that 
myFoo.fun(3) can be called as 
AllMemberFunctions!(typeof(myFoo))[idx](myFoo, 3).

template AllMemberFunctions(T)
{
template createDg(alias fn)
{
static if (__traits(isStaticFunction, fn))
alias createDg = fn;
else
ReturnType!fn createDg(ref T ctx, Parameters!fn 
args)

{
ReturnType!fn delegate(Parameters!fn) fun;
fun.funcptr = 
fun.ptr = cast(void*)
return fun(args);
}
}

alias GetOverloads(string name) = 
AliasSeq!(__traits(getOverloads, T, name));


alias AllMemberFunctions = staticMap!(createDg, 
staticMap!(GetOverloads, __traits(allMembers, T)));

}

--
  Simen


Many thanks for this!!! Was really helpful.

I ended up unfolding the struct members into an array of member 
strings and mapping those to either the struct tuple members or 
the struct function members.
This way I can call all members (normal and bitfield members) in 
order.


Result:
https://gist.github.com/Timoses/c78e599e91b8d05be34aefaf75ca3739


This project is really teaching me some template actions : D.


Re: Rotate array in writefln?

2018-04-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/18/18 3:15 AM, Simen Kjærås wrote:

On Wednesday, 18 April 2018 at 06:54:29 UTC, Chris Katko wrote:
I need to rotate an array by 90 degrees, or have writefln figure that 
out.


I need, say:

0 4 5 6
0 0 0 0
0 0 0 0
0 0 0 0

But it's outputting:

0 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0

int [4][4] data;
file.writeln(format("%(%-(%d %)\n%)", data));


Generally, the solution would be std.range.transposed. However, since 
you're using a int[4][4], that's not a range-of-ranges, and transposed 
don't work out of the box. This helper function should help:


T[][] ror(T, size_t N1, size_t N2)(ref T[N1][N2] arr)
{
     T[][] result = new T[][N2];
     foreach (i, e; arr) {
     result[i] = e.dup;
     }
     return result;
}

unittest
{
     import std.stdio;
     import std.range;

     int [4][4] data;
     data[2][3] = 4;
     writefln("%(%-(%d %)\n%)", data);
     writefln("%(%-(%d %)\n%)", data.ror.transposed);
}



A version without allocating:

T[][N2] ror(T, size_t N1, size_t N2)(ref T[N1][N2] arr)
{
T[][N2] result;
foreach (i, ref e; arr) {
result[i] = e[];
}
return result;
}

...

writefln("%(%-(%d %)\n%)" data.ror[].transposed); // need the slice 
operator here


Keep in mind, you can't simply assign a variable to data.ror[], as the 
backing goes away immediately (OK to use as an rvalue though). And you 
must keep data in scope as long as you are using the result of data.ror.


-Steve


[Issue 18780] New: Inconsistent behavior with Variant holding int converting to unsigned types

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18780

  Issue ID: 18780
   Summary: Inconsistent behavior with Variant holding int
converting to unsigned types
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: alex.jercai...@gmail.com

This code works fine:
 int x = 7;
 Variant a = x;
 assert(a.convertsTo!ulong);

This assert however triggers:
 int x = 7;
 Variant a = x;
 assert(a.convertsTo!uint);

Is this behavior intended?

--


[Issue 17628] formattedWrite is impure on double

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17628

Eduard Staniloiu  changed:

   What|Removed |Added

 CC||edi33...@gmail.com

--- Comment #3 from Eduard Staniloiu  ---
Since `pureMalloc`, `pureCalloc` and `pureFree` got accepted[0], maybe we could
do the same for `sprintf` and `snprintf`?

[0] - https://github.com/dlang/druntime/pull/1836

--


dxml 0.3.0 released

2018-04-19 Thread Jonathan M Davis via Digitalmars-d-announce
Well, since I'm going to be talking about dxml at dconf, and it's likely
that I'll be talking about stuff that was not in the 0.2.* releases, it
seemed like I should get a new release out before dconf. So, here it is.

dxml 0.3.0 has now been released.

I won't repeat everything that's in the changelog, but the biggest changes
are that writer support has now been added, and it's now possible to
configure how the parser handles non-standard entity references.

Please report any bugs that you find via github.

Changelog: http://jmdavisprog.com/changelog/dxml/0.3.0.html
Documentation: http://jmdavisprog.com/docs/dxml/0.3.0/
Github: https://github.com/jmdavis/dxml/tree/v0.3.0
Dub: http://code.dlang.org/packages/dxml

- Jonathan M Davis



Re: Getting the overload set of a template

2018-04-19 Thread Alex via Digitalmars-d-learn

On Thursday, 19 April 2018 at 13:57:04 UTC, Simen Kjærås wrote:
Currently, there is no way (that I've found, at least) to do 
this. If you have a workaround, that's great, but there really 
should be a way - probably __traits(getOverloads). Having 
__traits(getOverloads) return templates as well should fix some 
of the issues __traits(getOverloads) has, as a bonus.




Would it be possible at all? I mean, if the two following codes 
are equivalent

´´´
@S("Has foo_A") template foo(string s) if (s == "a") {
enum foo = "foo_A";
}
@S("Has foo_B") template foo(string s) if (s == "b") {
enum foo = "foo_B";
}
´´´


´´´
template foo(string s)
{
static if (s == "a")
{
   @S("Has foo_A") enum foo = "foo_A";
}
else static if (s == "b")
{
  @S("Has foo_B") enum foo = "foo_B";
}
}
´´´

How would you define a "template overload"?
And which "overloads" would you like to get if constraints are 
more general?
And last but not least, the getOverloads is defined on functions, 
which are callable, whereas templates are not, in general...


Re: Getting the overload set of a template

2018-04-19 Thread Simen Kjærås via Digitalmars-d-learn

On Tuesday, 17 April 2018 at 14:22:27 UTC, Arafel wrote:

Hi!

Is there any way to get the full set of templates that are 
"overloaded" (in my case, based on constraints)?


Currently, there is no way (that I've found, at least) to do 
this. If you have a workaround, that's great, but there really 
should be a way - probably __traits(getOverloads). Having 
__traits(getOverloads) return templates as well should fix some 
of the issues __traits(getOverloads) has, as a bonus.


--
  Simen


[Issue 18772] [ICE] Internal error: dmd\backend\cgcod.c 607 no optimizations

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18772

uplink.co...@googlemail.com changed:

   What|Removed |Added

 CC||uplink.co...@googlemail.com

--- Comment #3 from uplink.co...@googlemail.com ---
the ice happens in alignsection, I'll see what else I can come up with.

--


Re: Program exited with code 1

2018-04-19 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 19 April 2018 at 11:21:52 UTC, Andrey wrote:

On Thursday, 19 April 2018 at 08:37:19 UTC, Andrey wrote:

What will be a solution?


It seems to me that I found a solution - just replace WinMain() 
with main().


That's fine when you want a console app, but it leaves you with a 
console window automatically popping up if you create a windowed 
app.


When using WinMain, you have to manually setup and tear down 
DRuntime as described in the wiki[1]. Alternatively, you can get 
rid of the console window with a main function via linker flags 
-- when using OPTLINK (the default):


-L/SUBSYSTEM:windows

should be enough. With -m32mscoff or -m64, which uses the MS 
linker, you'll both that and this:


-L/ENTRY:mainCRTStartup

[1] https://wiki.dlang.org/D_for_Win32


[Issue 18773] Constraints on buffer re-use for std.zlib should be documented.

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18773

Eduard Staniloiu  changed:

   What|Removed |Added

   Keywords||bootcamp
 CC||edi33...@gmail.com

--


[Issue 17127] bad example code for std.concurrency.Generator

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17127

alex.jercai...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||alex.jercai...@gmail.com
 Resolution|--- |FIXED

--


GDB + ddemangle

2018-04-19 Thread ANtlord via Digitalmars-d-announce
Hello! I've written a piece of glue code that helps to debug D 
code using GDB. The code glues together GDB and ddmangle. 
Checkout the link https://github.com/ANtlord/gdb-ddemangle


PRs are welcome!


Re: making a struct an inputRange with free functions

2018-04-19 Thread jmh530 via Digitalmars-d-learn
On Thursday, 19 April 2018 at 01:33:26 UTC, Jonathan M Davis 
wrote:

[snip]

Occasionally, that aspect of importing and UFCS can be 
annoying, but on the whole, I don't really see why it matters 
much, particularly when actually having the free functions 
available would be an enormous change to how imports work and 
could cause a ton of other problems. It would mean that code 
would be affected by which code imported it rather than just 
the code that it imports, and at that point, you effectively 
lose control over what's going on. It would mean that just like 
C/C++ #includes, you couldn't rely on the module being the same 
every time you imported it. Even if the effect were limited to 
templated code, it would mean that two supposedly identical 
instantiations of a template would not necessarily be identical 
anymore, and they'd have to be recompiled in every module that 
used them. It would be a disaster in the making. mixins are the 
closest that we get to that, but in that case, the programmer 
is specifically stating that they want to reuse that code 
directly in their own module as if it were declared there 
rather than using stuff from other modules. Occasionally, that 
might be limiting, but without those restrictions, you 
basically don't have a module system anymore. And with mixins, 
you have control over what affects your module, whereas having 
the code that imports a module affect it would be more like 
mixing in code from the outside.


And in any case, IMHO, the range API functions aren't really 
functions that make much sense as free functions anyway. 
They're not generic, and they're very much tied to the type 
that they go with - just like opEquals, opAssign, or toString 
are tied to the type. They're inherently pretty much the 
opposite of generic. And even if the import rules somehow let 
you have them as free functions without it causing problems, 
what would it buy you? The only situation I can think of where 
it might be useful is if you're dealing with a type that you 
can't control and thus can't add the member functions to. But 
in that case, you can always just wrap that type in another 
type that does declare the range API. So, I don't think that 
much is lost by not being able to use UFCS to make something a 
range.


- Jonathan M Davis


I get that range functions are very much tied to the type. My 
default is almost always to include them as member functions, and 
I don't favor any big breaking changes.


With respect to this thread, my thinking had gone to that mention 
of anemic domain models on the announce board a few days ago [1]. 
If free functions can't fully replace member functions, then this 
anemic domain model approach would be limited in D.


[1] 
https://forum.dlang.org/thread/kawrnpsyjugwwtknq...@forum.dlang.org


[Issue 18779] New: StatsCollector empty doesn't take into account the parent allocator

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18779

  Issue ID: 18779
   Summary: StatsCollector empty doesn't take into account the
parent allocator
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: trivial
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: edi33...@gmail.com

Currently, std.experimental.allocator.building_blocks.StatsCollector does not
forward to the parent allocator, but instead, makes an assumption based on the
`bytesUsed` option.

`empty` is not the StatsCollector's decision to make, since the parent
allocator might have a different logic based on empty, than just matching
allocations with deallocations.

Please see the example below; adding the unittest in stats_collector.d will
trigger the assert

```
@system unittest
{
import std.experimental.allocator.mallocator : Mallocator;
import std.typecons : Ternary;

static struct MyAlloc
{   
pure nothrow @safe @nogc
Ternary empty()
{   
return Ternary.no;
}   

enum uint alignment = platformAlignment;
void[] allocate(size_t n) { return Mallocator.instance.allocate(n); }
bool deallocate(void[] b) { return Mallocator.instance.deallocate(b); }

static MyAlloc instance;
}   

StatsCollector!(MyAlloc, Options.all) a;
auto buf = a.allocate(42);
a.deallocate(buf);
assert(a.empty == Ternary.no); // fails
}
```

--


Re: Program exited with code 1

2018-04-19 Thread Andrey via Digitalmars-d-learn

On Thursday, 19 April 2018 at 08:37:19 UTC, Andrey wrote:

What will be a solution?


It seems to me that I found a solution - just replace WinMain() 
with main().


Re: D vs nim

2018-04-19 Thread John Belmonte via Digitalmars-d

On Tuesday, 27 March 2018 at 01:19:44 UTC, timotheecour wrote:
I've created a git repo 
https://github.com/timotheecour/D_vs_nim/ with the goal: up to 
date and objective comparison of features between D and nim, 
and 1:1 map of features, tools, idioms and libraries to help D 
users learn nim and vice versa.


I just recently came across Andrei's comparison of D, Rust, and 
Go [1].  I'd love to see that updated and hear his take on Nim.


I don't have experience with Nim yet, but from what I've read it 
seems to match D's 10x "easier to interface with C and C++".  
Other possible 10x items are the GC, macro system, and the 
development community being able to focus their resources at a 
higher level (no linker, competing compilers, headaches targeting 
arm64, etc. etc.).


[1] 
https://www.quora.com/Which-language-has-the-brightest-future-in-replacement-of-C-between-D-Go-and-Rust-And-Why


[Issue 18775] DMD falsely reports deprecation for deprecated implicit casts that were not used in UFCS

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18775

--- Comment #2 from FeepingCreature  ---
Same piece of code, at least.

--


Re: Rotate array in writefln?

2018-04-19 Thread Simen Kjærås via Digitalmars-d-learn

On Thursday, 19 April 2018 at 10:10:41 UTC, Chris Katko wrote:

That makes sense why transpose wouldn't work for my arrays!

So you're saying if I used [][] (dynamic array) that's a range 
of ranges, and it would work?


Yup. Static arrays can't be ranges, since popFront must mutate 
the length, and the length is a part of the type for static 
arrays.



Why is it you have to rework your templates for static vs 
dynamic ranges? Thanks!


Unless I answered this question above, I'm not entirely sure what 
you're asking.


Anyways, for matrix work (which seems to be what you're doing), I 
would suggest taking a look at 
https://github.com/libmir/mir-algorithm. I haven't actually used 
it myself, but seems to be a very good and comprehensive library 
for this purpose.


--
  Simen


Re: Reddit Post: Overview of the Efficient Programming Languages (v.3)

2018-04-19 Thread Per Nordlöw via Digitalmars-d

On Tuesday, 17 April 2018 at 15:10:35 UTC, Nerve wrote:
Overview of the Efficient Programming Languages (v.3): C++, 
Rust, Swift, Scala, Dlang, Kotlin, Nim, Julia, Golang, Python.


http://reddit.com/r/programming/comments/8cw2xn/overview_of_the_efficient_programming_languages/


Nice overview. Thanks.


[Issue 18068] No file names and line numbers in stack trace

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18068

--- Comment #9 from Seb  ---
FWIW my current guess is that its related to a "recent" change in glibc. 

This could also be related:

https://github.com/dlang/druntime/pull/2151

> The latter is how I stumbled on this. LLVM 6.0 led to DWARF v4 debuginfos, 
> rt.backtrace.dwarf doesn't support that version, so no file/line infos => 
> "??:? \0" + exception

--


[Issue 18068] No file names and line numbers in stack trace

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18068

arne.lud...@posteo.de changed:

   What|Removed |Added

 CC||arne.lud...@posteo.de

--- Comment #8 from arne.lud...@posteo.de ---
This problem doesn't seem to affect all Linux systems. So, please report your
Distribution and Kernel (type `uname -r` in shell).

Works: Linux *** 4.4.0-119-generic #143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018
x86_64 x86_64 x86_64 GNU/Linux

Fails: Linux *** 4.15.15-1-ARCH #1 SMP PREEMPT Sat Mar 31 23:59:25 UTC 2018
x86_64 GNU/Linux

--


Re: Rotate array in writefln?

2018-04-19 Thread Chris Katko via Digitalmars-d-learn

On Wednesday, 18 April 2018 at 07:15:47 UTC, Simen Kjærås wrote:

On Wednesday, 18 April 2018 at 06:54:29 UTC, Chris Katko wrote:
I need to rotate an array by 90 degrees, or have writefln 
figure that out.


I need, say:

0 4 5 6
0 0 0 0
0 0 0 0
0 0 0 0

But it's outputting:

0 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0

int [4][4] data;
file.writeln(format("%(%-(%d %)\n%)", data));


Generally, the solution would be std.range.transposed. However, 
since you're using a int[4][4], that's not a range-of-ranges, 
and transposed don't work out of the box. This helper function 
should help:


T[][] ror(T, size_t N1, size_t N2)(ref T[N1][N2] arr)
{
T[][] result = new T[][N2];
foreach (i, e; arr) {
result[i] = e.dup;
}
return result;
}

unittest
{
import std.stdio;
import std.range;

int [4][4] data;
data[2][3] = 4;
writefln("%(%-(%d %)\n%)", data);
writefln("%(%-(%d %)\n%)", data.ror.transposed);
}

--
  Simen


That makes sense why transpose wouldn't work for my arrays!

So you're saying if I used [][] (dynamic array) that's a range of 
ranges, and it would work?


Why is it you have to rework your templates for static vs dynamic 
ranges? Thanks!


Re: Small Buffer Optimization for string and friends

2018-04-19 Thread Walter Bright via Digitalmars-d

On 4/8/2012 7:26 AM, Manu wrote:
Is it realistic that anyone can actually use raw d-string's in an app that 
performs a lot of string manipulation? I bet most people end up with a custom 
string class anyway...
Who's written a string-heavy app without their own string helper class? I ended 
up with a string class within about half an hour of trying to work with D 
strings (initially just to support stack strings, then it grew).


Warp (a fast C preprocessor)

https://github.com/facebookarchive/warp


Re: Program exited with code 1

2018-04-19 Thread Andrey via Digitalmars-d-learn

On Thursday, 19 April 2018 at 08:24:55 UTC, user1234 wrote:
The run-time is not already initialized but the "new" operator 
relies on it.


What will be a solution?


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Kagamin via Digitalmars-d

foreach(i;0..1)
10 is too much


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Kagamin via Digitalmars-d
On Wednesday, 18 April 2018 at 22:24:13 UTC, Matthias Klumpp 
wrote:

size_t memSize = pooltable.maxAddr - minAddr;
(https://github.com/ldc-developers/druntime/blob/ldc/src/gc/impl/conservative/gc.d#L1982
 )
That wouldn't make sense for a pool size...

The machine this is running on has 16G memory, at the time of 
the crash the software was using ~2.1G memory, with 130G 
virtual memory due to LMDB memory mapping (I wonder what 
happens if I reduce that...)


If big LMDB mapping causes a problem, try a test like this:
---
import core.memory;
void testLMDB()
{
//how do you use it?
}
void test1()
{
void*[][] a;
foreach(i;0..10)a~=new void*[1];
void*[][] b;
foreach(i;0..10)b~=new void*[1];
b=null;
GC.collect();

testLMDB();

GC.collect();
foreach(i;0..10)a~=new void*[1];
foreach(i;0..10)b~=new void*[1];
b=null;
GC.collect();
}
---


Re: Program exited with code 1

2018-04-19 Thread user1234 via Digitalmars-d-learn

On Thursday, 19 April 2018 at 08:13:00 UTC, Andrey wrote:

Hello,
I wrote a small test code with WinApi:


import core.runtime;
import std.utf;

import core.sys.windows.windows;
import core.sys.windows.wingdi;

class Test
{
public this() nothrow
{

}
}

extern(Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, 
int nCmdShow)

{
new Test(); // error is here
return 0;
}


When I run it, there is an error: Program exited with code 1.

If I comment "new Test();" - no error happens. Why?


The run-time is not already initialized but the "new" operator 
relies on it.


Re: Feature to get or add value to an associative array.

2018-04-19 Thread Giles Bathgate via Digitalmars-d

On Wednesday, 18 April 2018 at 21:04:53 UTC, Jordan Wilson wrote:
Thinking seems sound, although having a name starting with 
"get" does have the advantage of being more related to the 
existing get.


Ah yes, good point. I think now we've had the discussion about 
other use cases though that ultimately there might need to be an 
"atomic" AddOrUpdate style function too, which I was thinking 
could just be called 'update'. The necessity to keep them all 
starting with get seemed less important.


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Kagamin via Digitalmars-d
On Wednesday, 18 April 2018 at 17:40:56 UTC, Matthias Klumpp 
wrote:
I get compile errors for the INVARIANT option, and I don't 
actually know how to deal with those properly:

```
src/gc/impl/conservative/gc.d(1396): Error: shared mutable 
method core.internal.spinlock.SpinLock.lock is not callable 
using a shared const object
src/gc/impl/conservative/gc.d(1396):Consider adding 
const or inout to core.internal.spinlock.SpinLock.lock
src/gc/impl/conservative/gc.d(1403): Error: shared mutable 
method core.internal.spinlock.SpinLock.unlock is not callable 
using a shared const object
src/gc/impl/conservative/gc.d(1403):Consider adding 
const or inout to core.internal.spinlock.SpinLock.unlock

```

Commenting out the locks (eww!!) yields no change in behavior 
though.


As a workaround:
(cast(shared)rangesLock).lock();


Program exited with code 1

2018-04-19 Thread Andrey via Digitalmars-d-learn

Hello,
I wrote a small test code with WinApi:


import core.runtime;
import std.utf;

import core.sys.windows.windows;
import core.sys.windows.wingdi;

class Test
{
public this() nothrow
{

}
}

extern(Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int 
nCmdShow)

{
new Test(); // error is here
return 0;
}


When I run it, there is an error: Program exited with code 1.

If I comment "new Test();" - no error happens. Why? How to create 
instances of classes?


DMD v2.077.1, Windows 10.


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Kagamin via Digitalmars-d
On Wednesday, 18 April 2018 at 17:40:56 UTC, Matthias Klumpp 
wrote:

On Wednesday, 18 April 2018 at 10:15:49 UTC, Kagamin wrote:
You can call GC.collect at some points in the program to see 
if they can trigger the crash


I already do that, and indeed I get crashes. I could throw 
those calls into every function though, or make a minimal pool 
size, maybe that yields something...


Can you narrow down the earliest point at which it starts to 
crash? That might identify if something in particular causes the 
crash.


[Issue 18228] this(this a){} doesn't generate postblit ctor; this(this){} does

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18228

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 18228] this(this a){} doesn't generate postblit ctor; this(this){} does

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18228

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/5cebe70bd69496f129bf2284b02fbe1cbcbd3b82
Fix Issue 18228 - this(this a){} doesn't generate postblit ctor; this(this){}
does

https://github.com/dlang/dmd/commit/bbc087e67ea977de2d5f0410d306b510e4baeb92
Merge pull request #8141 from RazvanN7/Issue_18228

Fix Issue 18228 - this(this a){} doesn't generate postblit ctor; this(this){}
does
merged-on-behalf-of: Jacob Carlborg 

--


Re: The 10k Twitter Target

2018-04-19 Thread Joakim via Digitalmars-d-announce

On Thursday, 19 April 2018 at 06:53:05 UTC, Basile B. wrote:

On Monday, 16 April 2018 at 08:39:05 UTC, Mike Parker wrote:
Lately, we've seen a steadily increasing trend of new 
followers on Twitter. We're closing in on the totally 
arbitrary yet emotionally significant number of 10,000. I was 
just thinking how cool it would be to hit that number before 
or during DConf.


Now that my move is behind me and I'm settling in to my new 
house, I have more time to stay on top of things (note that 
"more" does not necessarily equate to "enough"). I'll try to 
keep the tweet stream more active than usual over the coming 
two+ weeks, even while I'm bopping around Germany in the week 
prior to the conference.


If you have a Twitter handle, it would help us out to retweet 
anything interesting you see on @D_Programming. If you aren't 
following us, it would help us out even more for you to become 
a statistic! Let's see if we can turn that 9,781 (as I write 
this) into 10,000 before the Hackathon.


Each time i register to tweeter i got locked for no reasons. 
This happened yesterday again WHILE writing the first message. 
This is a problem when you don't own a smart-phone...


I think people should seriously stop using this service, they 
don't realize but there are probably a bunch of psychos at the 
top of hierarchy of this company.
These abusive lockings are a direct representation of their 
madness.


I agree, which is why I never even bothered to sign up and last 
year stopped checking the 3-4 people's streams I used to follow.


However, like it or not, it is a popular platform, just like 
reddit, so it would be irresponsible for D and Mike not to market 
and publicize there. When they go out of business, we won't have 
that problem anymore.


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Johannes Pfau via Digitalmars-d
Am Thu, 19 Apr 2018 07:04:14 + schrieb Johannes Pfau:

> Am Thu, 19 Apr 2018 06:33:27 + schrieb Johannes Pfau:
> 
> 
>> Generally if you produced a crash in gdb it should be reproducible if
>> you restart the program in gdb. So once you have a crash, you should be
>> able to restart the program and look at the _dso_registry and see the
>> same addresses somewhere. If you then think you see memory corruption
>> somewhere you could also use read or write watchpoints.
>> 
>> But just to be sure: you're not adding any GC ranges manually, right?
>> You could also try to compare the GC range to the address range layout
>> in /proc/$PID/maps .
> 
> Of course, if this is a GC pool / heap range adding breakpoints in the
> sections code won't be useful. Then I'd try to add a write watchpoint on
> pooltable.minAddr / maxAddr, restart the programm in gdb and see where /
> why the values are set.

Having a quick look at https://github.com/ldc-developers/druntime/blob/
ldc/src/gc/pooltable.d: The GC seems to allocate multiple pools using 
malloc, but only keeps track of one minimum/maximum address for all 
pools. Now if there's some other memory area malloced in between these 
pools, you will end up with a huge memory block. When this will get 
scanned and if any of the memory in-between the GC pools is protected, 
you might see the GC crash. However, I don't really know anything about 
the GC code, so some GC expert would have to confirm this.



-- 
Johannes


[Issue 13435] Strange error if struct is a class member and opAssign applied

2018-04-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13435

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/af078566aad8dede82d57c36758a28267df07759
Fix Issue 13435 - Strange error if struct is a class member and opAssign
applied

https://github.com/dlang/dmd/commit/ee576dc6d730c7e1ab5d6b1908a453b1590efec1
Merge pull request #8191 from RazvanN7/Issue_13435

Fix Issue 13435 - Strange error if struct is a class member and opAssign
applied
merged-on-behalf-of: Jacob Carlborg 

--


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Johannes Pfau via Digitalmars-d
Am Thu, 19 Apr 2018 06:33:27 + schrieb Johannes Pfau:

> 
> Generally if you produced a crash in gdb it should be reproducible if
> you restart the program in gdb. So once you have a crash, you should be
> able to restart the program and look at the _dso_registry and see the
> same addresses somewhere. If you then think you see memory corruption
> somewhere you could also use read or write watchpoints.
> 
> But just to be sure: you're not adding any GC ranges manually, right?
> You could also try to compare the GC range to the address range layout
> in /proc/$PID/maps .

Of course, if this is a GC pool / heap range adding breakpoints in the 
sections code won't be useful. Then I'd try to add a write watchpoint on 
pooltable.minAddr / maxAddr, restart the programm in gdb and see where / 
why the values are set.

-- 
Johannes


Re: The 10k Twitter Target

2018-04-19 Thread Basile B. via Digitalmars-d-announce

On Monday, 16 April 2018 at 08:39:05 UTC, Mike Parker wrote:
Lately, we've seen a steadily increasing trend of new followers 
on Twitter. We're closing in on the totally arbitrary yet 
emotionally significant number of 10,000. I was just thinking 
how cool it would be to hit that number before or during DConf.


Now that my move is behind me and I'm settling in to my new 
house, I have more time to stay on top of things (note that 
"more" does not necessarily equate to "enough"). I'll try to 
keep the tweet stream more active than usual over the coming 
two+ weeks, even while I'm bopping around Germany in the week 
prior to the conference.


If you have a Twitter handle, it would help us out to retweet 
anything interesting you see on @D_Programming. If you aren't 
following us, it would help us out even more for you to become 
a statistic! Let's see if we can turn that 9,781 (as I write 
this) into 10,000 before the Hackathon.


Each time i register to tweeter i got locked for no reasons. This 
happened yesterday again WHILE writing the first message. This is 
a problem when you don't own a smart-phone...


I think people should seriously stop using this service, they 
don't realize but there are probably a bunch of psychos at the 
top of hierarchy of this company.
These abusive lockings are a direct representation of their 
madness.


Re: Issues with debugging GC-related crashes #2

2018-04-19 Thread Johannes Pfau via Digitalmars-d
Am Wed, 18 Apr 2018 22:24:13 + schrieb Matthias Klumpp:

> On Wednesday, 18 April 2018 at 22:12:12 UTC, kinke wrote:
>> On Wednesday, 18 April 2018 at 20:36:03 UTC, Johannes Pfau wrote:
>>> Actually this sounds very familiar:
>>> https://github.com/D-Programming-GDC/GDC/pull/236
>>
>> Interesting, but I don't think it applies here. Both start and end
>> addresses are 16-bytes aligned, and both cannot be accessed according
>> to the stack trace (`pbot=0x7fcf4d721010 > at address 0x7fcf4d721010>, ptop=0x7fcf4e321010 > memory at address 0x7fcf4e321010>`). That's quite interesting too:
>> `memSize = 209153867776`. Don't know what exactly it is, but it's a
>> pretty large number (~194 GB).
> 
> size_t memSize = pooltable.maxAddr - minAddr;
> (https://github.com/ldc-developers/druntime/blob/ldc/src/gc/impl/
conservative/gc.d#L1982
> )
> That wouldn't make sense for a pool size...
> 
> The machine this is running on has 16G memory, at the time of the crash
> the software was using ~2.1G memory, with 130G virtual memory due to
> LMDB memory mapping (I wonder what happens if I reduce that...)

I see. Then I'd try to debug where the range originally comes from, try 
adding breakpoints in _d_dso_registry, registerGCRanges and similar 
functions here: https://github.com/dlang/druntime/blob/master/src/rt/
sections_elf_shared.d#L421

Generally if you produced a crash in gdb it should be reproducible if you 
restart the program in gdb. So once you have a crash, you should be able 
to restart the program and look at the _dso_registry and see the same 
addresses somewhere. If you then think you see memory corruption 
somewhere you could also use read or write watchpoints.

But just to be sure: you're not adding any GC ranges manually, right?
You could also try to compare the GC range to the address range layout 
in /proc/$PID/maps .



-- 
Johannes


Re: LockingTextWriter not an output range?

2018-04-19 Thread kookman via Digitalmars-d-learn
On Wednesday, 18 April 2018 at 06:40:15 UTC, rikki cattermole 
wrote:

On 18/04/2018 6:28 PM, kookman wrote:
The below static assert fails. Is this expected? Not the way I 
read the docs.


static assert (isOutputRange(typeof(stdout.lockingTextWriter), 
char));


static assert 
(isOutputRange!(typeof(stdout.lockingTextWriter()), char));


Ah - thank you! (slapping my forehead for wasted 2 hours)