www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Help me please fix the bug

reply Majestio <majestio ya.ru> writes:
==============================================================
log:
==============================================================

[majestio freebsd ~/Projects/webapp]$ dub
Performing "debug" build using /usr/local/bin/dmd for x86_64.
taggedalgebraic 0.10.11: target for configuration "library" is up 
to date.
eventcore 0.8.34: building configuration "kqueue"...
/home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/po
ix/kqueue.d(43,46): Error: function
'eventcore.drivers.posix.kqueue.KqueueEventLoop.this.__lambda1' is not nothrow
/home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/p
six/kqueue.d(41,2): Error: nothrow constructor
'eventcore.drivers.posix.kqueue.KqueueEventLoop.this' may throw
/home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/po
ix/kqueue.d(60,20): Error: function 'core.sys.freebsd.sys.event.kevent' is not
nothrow
/home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/po
ix/kqueue.d(48,16): Error: nothrow function
'eventcore.drivers.posix.kqueue.KqueueEventLoop.doProcessEvents' may throw
/usr/local/bin/dmd failed with exit code 1.

==============================================================
source kqueue.d:
==============================================================

/**
     BSD kqueue based event driver implementation.

     Kqueue is an efficient API for asynchronous I/O on BSD 
flavors, including
     OS X/macOS, suitable for large numbers of concurrently open 
sockets.
*/
module eventcore.drivers.posix.kqueue;
 safe: /* nogc:*/ nothrow:

version (FreeBSD) enum have_kqueue = true;
else version (DragonFlyBSD) enum have_kqueue = true;
else version (OSX) enum have_kqueue = true;
else enum have_kqueue = false;

static if (have_kqueue):

public import eventcore.drivers.posix.driver;
import eventcore.internal.utils;

import core.time : Duration;
import core.sys.posix.sys.time : timespec, time_t;

version (OSX) import core.sys.darwin.sys.event;
else version (FreeBSD) import core.sys.freebsd.sys.event;
else version (DragonFlyBSD) import 
core.sys.dragonflybsd.sys.event;
else static assert(false, "Kqueue not supported on this OS.");


import core.sys.linux.epoll;


alias KqueueEventDriver = PosixEventDriver!KqueueEventLoop;

final class KqueueEventLoop : PosixEventLoop {
     private {
         int m_queue;
         kevent_t[] m_changes;
         kevent_t[] m_events;
     }

     this()
      safe nothrow {
         m_queue = ()  trusted { return kqueue(); } ();
         m_events.length = 100;
         assert(m_queue >= 0, "Failed to create kqueue.");
     }

     override bool doProcessEvents(Duration timeout)
      trusted {
         import std.algorithm : min;
         //assert(Fiber.getThis() is null, "processEvents may not 
be called from within a fiber!");

         //print("wait %s", m_events.length);
         timespec ts;
         long secs, hnsecs;
         timeout.split!("seconds", "hnsecs")(secs, hnsecs);
         ts.tv_sec = cast(time_t)secs;
         ts.tv_nsec = cast(uint)hnsecs * 100;

         auto ret = kevent(m_queue, m_changes.ptr, 
cast(int)m_changes.length, m_events.ptr, 
cast(int)m_events.length, timeout == Duration.max ? null : &ts);
         m_changes.length = 0;
         m_changes.assumeSafeAppend();

         //print("kevent returned %s", ret);

         if (ret > 0) {
             foreach (ref evt; m_events[0 .. ret]) {
                 //print("event %s %s", evt.ident, evt.filter, 
evt.flags);
                 assert(evt.ident <= uint.max);
                 auto fd = cast(FD)cast(int)evt.ident;
                 if (evt.flags & (EV_EOF|EV_ERROR))
                     notify!(EventType.status)(fd);
                 switch (evt.filter) {
                     default: break;
                     case EVFILT_READ: 
notify!(EventType.read)(fd); break;
                     case EVFILT_WRITE: 
notify!(EventType.write)(fd); break;
                 }
                 // EV_SIGNAL, EV_TIMEOUT
             }
             return true;
         } else return false;
     }

     override void dispose()
     {

         import core.sys.posix.unistd : close;
         close(m_queue);
     }

     override void registerFD(FD fd, EventMask mask, bool 
edge_triggered = true)
     {
         //print("register %s %s", fd, mask);
         kevent_t ev;
         ev.ident = fd;
         ev.flags = EV_ADD|EV_ENABLE;
         if (edge_triggered) ev.flags |= EV_CLEAR;
         if (mask & EventMask.read) {
             ev.filter = EVFILT_READ;
             m_changes ~= ev;
         }
         if (mask & EventMask.write) {
             ev.filter = EVFILT_WRITE;
             m_changes ~= ev;
         }
         //if (mask & EventMask.status) ev.events |= 
EPOLLERR|EPOLLRDHUP;
     }

     override void unregisterFD(FD fd, EventMask mask)
     {
         kevent_t ev;
         ev.ident = fd;
         ev.flags = EV_DELETE;
         m_changes ~= ev;
     }

     override void updateFD(FD fd, EventMask old_mask, EventMask 
new_mask, bool edge_triggered = true)
     {
         //print("update %s %s", fd, mask);
         kevent_t ev;
         auto changes = old_mask ^ new_mask;

         if (changes & EventMask.read) {
             ev.filter = EVFILT_READ;
             ev.flags = new_mask & EventMask.read ? EV_ADD : 
EV_DELETE;
             if (edge_triggered) ev.flags |= EV_CLEAR;
             m_changes ~= ev;
         }

         if (changes & EventMask.write) {
             ev.filter = EVFILT_WRITE;
             ev.flags = new_mask & EventMask.write ? EV_ADD : 
EV_DELETE;
             if (edge_triggered) ev.flags |= EV_CLEAR;
             m_changes ~= ev;
         }

         //if (mask & EventMask.status) ev.events |= 
EPOLLERR|EPOLLRDHUP;
     }
}
May 17 2018
next sibling parent reply Mike Franklin <slavo5150 yahoo.com> writes:
On Friday, 18 May 2018 at 05:44:12 UTC, Majestio wrote:
 ==============================================================
 log:
 ==============================================================

 [majestio freebsd ~/Projects/webapp]$ dub
 Performing "debug" build using /usr/local/bin/dmd for x86_64.
 taggedalgebraic 0.10.11: target for configuration "library" is 
 up to date.
 eventcore 0.8.34: building configuration "kqueue"...
 /home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/po
ix/kqueue.d(43,46): Error: function
'eventcore.drivers.posix.kqueue.KqueueEventLoop.this.__lambda1' is not nothrow
 /home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/p
six/kqueue.d(41,2): Error: nothrow constructor
'eventcore.drivers.posix.kqueue.KqueueEventLoop.this' may throw
 /home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/po
ix/kqueue.d(60,20): Error: function 'core.sys.freebsd.sys.event.kevent' is not
nothrow
 /home/majestio/.dub/packages/eventcore-0.8.34/eventcore/source/eventcore/drivers/po
ix/kqueue.d(48,16): Error: nothrow function
'eventcore.drivers.posix.kqueue.KqueueEventLoop.doProcessEvents' may throw
 /usr/local/bin/dmd failed with exit code 1.
I'm not sure, but I recently fixed an issue very much related to this: https://github.com/dlang/dmd/pull/8184 I'm curious if you could download one of the nightly compilers and test if it is still problem: http://nightlies.dlang.org/dmd-master-2018-05-18/ Mike
May 17 2018
parent reply Majestio <majestio ya.ru> writes:
On Friday, 18 May 2018 at 06:02:46 UTC, Mike Franklin wrote:
 On Friday, 18 May 2018 at 05:44:12 UTC, Majestio wrote:
 I'm curious if you could download one of the nightly compilers 
 and test if it is still problem:  
 http://nightlies.dlang.org/dmd-master-2018-05-18/

 Mike
About dmd-master-2018-05-18 ... build.sh: ============================================= export PATH=/home/majestio/Projects/dmd2/freebsd/bin64:$PATH export LD_LIBRARY_PATH=/home/majestio/Projects/dmd2/freebsd/lib64:$LD_LIBRARY_PATH rm -fR ~/.dub fetch http://nightlies.dlang.org/dmd-master-2018-05-18/dmd.master.freebsd-64.tar.xz tar xf dmd.master.freebsd-64.tar.xz rm -f dmd.master.freebsd-64.tar.xz echo -ne '\n\n\n\n\n\n\n' | dub init hello --type=vibe.d cd hello dub 2>&1 | tee logfile.log logfile.log: ============================================= Fetching libevent 2.0.2+2.0.16 (getting selected version)... Fetching diet-ng 1.4.5 (getting selected version)... Fetching taggedalgebraic 0.10.11 (getting selected version)... Fetching openssl 1.1.6+1.0.1g (getting selected version)... Fetching botan 1.12.9 (getting selected version)... Fetching stdx-allocator 2.77.1 (getting selected version)... Fetching vibe-d 0.8.3 (getting selected version)... Fetching memutils 0.4.10 (getting selected version)... Fetching vibe-core 1.4.0 (getting selected version)... Fetching libasync 0.8.3 (getting selected version)... Fetching botan-math 1.0.3 (getting selected version)... Fetching eventcore 0.8.34 (getting selected version)... Performing "debug" build using /usr/home/majestio/Projects/dmd2/freebsd/bin64/dmd for x86_64. taggedalgebraic 0.10.11: building configuration "library"... eventcore 0.8.34: building configuration "kqueue"... stdx-allocator 2.77.1: building configuration "library"... vibe-core 1.4.0: building configuration "kqueue"... vibe-d:utils 0.8.3: building configuration "library"... vibe-d:data 0.8.3: building configuration "library"... /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2513,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/data/vibe/d ta/json.d(2518,25): Deprecation: function `std.exception.enforceEx!(JSONException).enforceEx!bool.enforceEx` is deprecated - Use `enforce`. `enforceEx` will be removed with 2.089. vibe-d:crypto 0.8.3: building configuration "library"... diet-ng 1.4.5: building configuration "library"... vibe-d:stream 0.8.3: building configuration "library"... /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/stream/vibe/strea /wrapper.d(179,22): Error: no property `connected` for type `const(InterfaceProxy!(ConnectionStream))` /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/stream/vibe/strea /wrapper.d(187,19): Error: no property `connected` for type `InterfaceProxy!(ConnectionStream)` /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/stream/vibe/strea /wrapper.d(188,15): Error: no property `close` for type `InterfaceProxy!(ConnectionStream)` /home/majestio/.dub/packages/vibe-d-0.8.3/vibe-d/stream/vibe/strea /wrapper.d(198,22): Error: no property `waitForData` for type `InterfaceProxy!(ConnectionStream)` /usr/home/majestio/Projects/dmd2/freebsd/bin64/dmd failed with exit code 1.
May 18 2018
parent reply Seb <seb wilzba.ch> writes:
On Friday, 18 May 2018 at 09:59:27 UTC, Majestio wrote:
 On Friday, 18 May 2018 at 06:02:46 UTC, Mike Franklin wrote:
 [...]
About dmd-master-2018-05-18 ... build.sh: ============================================= [...]
FWIW instead of such a build script, you could have used the install script which does this for you: curl https://dlang.org/install.sh | bash -s dmd-nightly Full docs: https://dlang.org/install
May 18 2018
parent Majestio <majestio ya.ru> writes:
On Friday, 18 May 2018 at 10:18:42 UTC, Seb wrote:
 On Friday, 18 May 2018 at 09:59:27 UTC, Majestio wrote:
 On Friday, 18 May 2018 at 06:02:46 UTC, Mike Franklin wrote:
 [...]
About dmd-master-2018-05-18 ... build.sh: ============================================= [...]
FWIW instead of such a build script, you could have used the install script which does this for you: curl https://dlang.org/install.sh | bash -s dmd-nightly Full docs: https://dlang.org/install
Thanks I'll know.
May 18 2018
prev sibling parent reply Mike Franklin <slavo5150 yahoo.com> writes:
On Friday, 18 May 2018 at 05:44:12 UTC, Majestio wrote:

     this()
      safe nothrow {
         m_queue = ()  trusted { return kqueue(); } ();
         m_events.length = 100;
         assert(m_queue >= 0, "Failed to create kqueue.");
     }
Also, I believe this is __lambda1: m_queue = () trusted { return kqueue(); } (); Is `kqueue()` nothrow? You probably need to decorate that lambda with `nothrow`. (i.e. put a `nothrow` right after ` trusted`. Mike
May 18 2018
parent reply Majestio <majestio ya.ru> writes:
On Friday, 18 May 2018 at 07:28:39 UTC, Mike Franklin wrote:
 On Friday, 18 May 2018 at 05:44:12 UTC, Majestio wrote:

     this()
      safe nothrow {
         m_queue = ()  trusted { return kqueue(); } ();
         m_events.length = 100;
         assert(m_queue >= 0, "Failed to create kqueue.");
     }
Also, I believe this is __lambda1: m_queue = () trusted { return kqueue(); } (); Is `kqueue()` nothrow? You probably need to decorate that lambda with `nothrow`. (i.e. put a `nothrow` right after ` trusted`. Mike
`kqueue()` is not nothrow. From log: "Error: function 'core.sys.freebsd.sys.event.kqueue' is not nothrow" This decoration does not solve the problem :(
May 18 2018
parent Mike Franklin <slavo5150 yahoo.com> writes:
On Friday, 18 May 2018 at 09:35:28 UTC, Majestio wrote:

 Also, I believe this is __lambda1:

 m_queue = ()  trusted { return kqueue(); } ();

 Is `kqueue()` nothrow?  You probably need to decorate that 
 lambda with `nothrow`.  (i.e. put a `nothrow` right after 
 ` trusted`.

 Mike
`kqueue()` is not nothrow. From log: "Error: function 'core.sys.freebsd.sys.event.kqueue' is not nothrow" This decoration does not solve the problem :(
But you're calling it from a `nothrow` function through a lambda that is also not `nothrow`. Decorate your lambda as `nothrow` and then, if you can't make `kqueue()` `nothrow`, put it in a try-catch and figure out what to do if it does throw. m_queue = () trusted nothrow { try { return kqueue(); } catch(Exception ex) { // what do you want to do about it? } } (); Mike
May 18 2018