Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hangs on certain code #10

Closed
Abscissa opened this issue May 30, 2013 · 20 comments
Closed

Hangs on certain code #10

Abscissa opened this issue May 30, 2013 · 20 comments

Comments

@Abscissa
Copy link

From vibe-d/vibe.d#231 (comment):

bother. Thanks. I installed mysql 5.0 and it still locks up on this code
which I got from the unittests:

auto c = mdb.lockConnection();
scope(exit) c.close();
writeln("do");
MetaData md = MetaData(c);
string[] dbList = md.databases();
writeln("done");

I'll see if I can find where its blocking.
...
hmmm, I think its my build process. the mysql test app works if I build it with dub. Weird thing is that phobos sockets are supposed to be opt in on the version I've got.

@rjmcguire: Can you grab the latest master of mysql-native and try with that? I don't know if you're using 32- or 64-bit, but I did add some 64-bit fixes since the version where phobos was opt-in. But even if you're using 32-bit, it'll be easier to figure out if we're both working from the latest master.

@Abscissa
Copy link
Author

I'm unable to reproduce the problem using this code on Win32/DMD 2.062/Vibe.d 0.7.15 with the latest master of mysqln-native:

import std.stdio;
import mysql.db;

void main()
{
    auto mdb = new MysqlDB("host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb");
    auto c = mdb.lockConnection();
    scope(exit) c.close();
    writeln("do");
    MetaData md = MetaData(c);
    string[] dbList = md.databases();
    writeln("done");
}

And this cmdline:

rdmd --force -I...pathTo...\vibe.d-0.7.15\source -I...pathTo...\vibe.d-0.7.15\import -version=VibeLibeventDriver ...pathTo.../vibe.d-0.7.15/lib/win-i386/event2.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/eay.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/ssl.lib -oftest_10 -version=Have_vibe_d test_10.d

@rjmcguire
Copy link

Hi Nick,

Thanks for testing, it is some weird combination of the build command with
vibe.d and mysql-native. If I build with dub it just doesn't happen. I'm
going to try your provided example just now.
I'm on ubuntu 13.04 64bit.

Cheers,

On Thu, May 30, 2013 at 9:55 PM, Nick Sabalausky
[email protected]:

I'm unable to reproduce the problem using this code on Win32/DMD
2.062/Vibe.d 0.7.15 with the latest master of mysqln-native:

import std.stdio;
import mysql.db;

void main()
{
auto mdb = new MysqlDB("host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb");
auto c = mdb.lockConnection();
scope(exit) c.close();
writeln("do");
MetaData md = MetaData(c);
string[] dbList = md.databases();
writeln("done");
}

And this cmdline:

rdmd --force -I...pathTo...\vibe.d-0.7.15\source -I...pathTo...\vibe.d-0.7.15\import -version=VibeLibeventDriver ...pathTo.../vibe.d-0.7.15/lib/win-i386/event2.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/eay.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/ssl.lib -oftest_10 -version=Have_vibe_d test_10.d


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-18704003
.

@Abscissa
Copy link
Author

Thanks for testing, it is some weird combination of the build command
with vibe.d and mysql-native. If I build with dub it just doesn't
happen. I'm going to try your provided example just now.
I'm on ubuntu 13.04 64bit.

What build command does result in the problem?

@rjmcguire
Copy link

I have to build and then link because otherwise the linker never seems to
resolve vibe.d with its libevent dependency.

/usr/bin/dmd -c -J./ -w -g -debug -version=VibeCustomMain -version=LIBEV4
-version=VibeLibeventDriver -version=Have_vibe_d -ofdip_buildfile.o main.d
-I...pathto.../vibe.d/source -I...pathto.../mysql-native/source
-I...pathto.../libevent -I...pathto.../openssl
/usr/bin/gcc -L--export-dynamic -ovibeexample3 dip_buildfile.o
 ...pathto.../libevent/liblibevent.a ...pathto.../openssl/libopenssl.a
-lssl -lcrypto ../../github.com/rjmcguire/vibe.d/libvibe-d.a ../../
github.com/rejectedsoftware/mysql-native/libmysql-native.a -lphobos2
-lpthread -levent -levent_pthreads

module main;

import vibe.d;
import std.stdio;
import std.string : indexOf, format;
import std.algorithm;
import std.variant;

//import mysql.db;
import mysql.connection;

int main(string[] args)
{
setLogLevel(LogLevel.trace);
//download("http://google.com/", "test.html");
auto conn = new Connection("host", "root", "pass", "db");
    writeln("database pool created");
    auto c = conn;
    scope(exit) c.close();
    MetaData md = MetaData(c);
    writeln("getting databases");
    string[] dbList = md.databases();
    writeln("done"); // we never get here.
//processCommandLineArgs(args);
return runEventLoop();
}

On Thu, May 30, 2013 at 10:12 PM, Nick Sabalausky
[email protected]:

Thanks for testing, it is some weird combination of the build command
with vibe.d and mysql-native. If I build with dub it just doesn't
happen. I'm going to try your provided example just now.
I'm on ubuntu 13.04 64bit.

What build command does result in the problem?


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-18705001
.

@rjmcguire
Copy link

The closest I can get to compiling the below results in:
rdmd -version=VibeLibeventDriver -version=Have_vibe_d -I../../
github.com/rejectedsoftware/mysql-native/source/ -I../../
github.com/rejectedsoftware/vibe.d/source/ -I../../
github.com/D-Programming-Deimos/libevent/ main.d
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(252):
Error: undefined identifier 'acquire'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(253):
Error: undefined identifier 'release'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(254):
Error: undefined identifier 'isOwner'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(255):
Error: undefined identifier 'isOwner'

On Thu, May 30, 2013 at 9:55 PM, Nick Sabalausky
[email protected]:

I'm unable to reproduce the problem using this code on Win32/DMD
2.062/Vibe.d 0.7.15 with the latest master of mysqln-native:

import std.stdio;
import mysql.db;

void main()
{
auto mdb = new MysqlDB("host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb");
auto c = mdb.lockConnection();
scope(exit) c.close();
writeln("do");
MetaData md = MetaData(c);
string[] dbList = md.databases();
writeln("done");
}

And this cmdline:

rdmd --force -I...pathTo...\vibe.d-0.7.15\source -I...pathTo...\vibe.d-0.7.15\import -version=VibeLibeventDriver ...pathTo.../vibe.d-0.7.15/lib/win-i386/event2.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/eay.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/ssl.lib -oftest_10 -version=Have_vibe_d test_10.d


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-18704003
.

@rjmcguire
Copy link

err, forgot to say. That is after I updated to latest mysql-native.

On Thu, May 30, 2013 at 11:40 PM, Rory McGuire [email protected] wrote:

The closest I can get to compiling the below results in:
rdmd -version=VibeLibeventDriver -version=Have_vibe_d -I../../
github.com/rejectedsoftware/mysql-native/source/ -I../../
github.com/rejectedsoftware/vibe.d/source/ -I../../
github.com/D-Programming-Deimos/libevent/ main.d
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(252):
Error: undefined identifier 'acquire'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(253):
Error: undefined identifier 'release'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(254):
Error: undefined identifier 'isOwner'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(255):
Error: undefined identifier 'isOwner'

On Thu, May 30, 2013 at 9:55 PM, Nick Sabalausky <[email protected]

wrote:

I'm unable to reproduce the problem using this code on Win32/DMD
2.062/Vibe.d 0.7.15 with the latest master of mysqln-native:

import std.stdio;
import mysql.db;

void main()
{
auto mdb = new MysqlDB("host=localhost;port=3306;user=testuser;pwd=testpassword;db=testdb");
auto c = mdb.lockConnection();
scope(exit) c.close();
writeln("do");
MetaData md = MetaData(c);
string[] dbList = md.databases();
writeln("done");
}

And this cmdline:

rdmd --force -I...pathTo...\vibe.d-0.7.15\source -I...pathTo...\vibe.d-0.7.15\import -version=VibeLibeventDriver ...pathTo.../vibe.d-0.7.15/lib/win-i386/event2.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/eay.lib ...pathTo.../vibe.d-0.7.15/lib/win-i386/ssl.lib -oftest_10 -version=Have_vibe_d test_10.d


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-18704003
.

@Abscissa
Copy link
Author

On Thu, 30 May 2013 14:07:14 -0700
rjmcguire [email protected] wrote:

I have to build and then link because otherwise the linker never
seems to resolve vibe.d with its libevent dependency.
/usr/bin/dmd -c -J./ -w -g -debug -version=VibeCustomMain
-version=LIBEV4 -version=VibeLibeventDriver -version=Have_vibe_d
-ofdip_buildfile.o main.d -I...pathto.../vibe.d/source
-I...pathto.../mysql-native/source -I...pathto.../libevent
-I...pathto.../openssl /usr/bin/gcc -L--export-dynamic -ovibeexample3
dip_buildfile.o ...pathto.../libevent/liblibevent.a ...pathto.../openssl/libopenssl.a
-lssl -lcrypto ../../github.com/rjmcguire/vibe.d/libvibe-d.a ../../
github.com/rejectedsoftware/mysql-native/libmysql-native.a -lphobos2
-lpthread -levent -levent_pthreads

Hmm, it's difficult for me to attempt it that way since I'm not sure
where all my openssl and libevent stuff is (I normally just let apt-get
handle those libs "magically" ;) ).

On my Debian 6 box with libevent v2.0-5, this command works:

rdmd -version=VibeCustomMain -version=VibeLibeventDriver
-version=Have_vibe_d -I../../mysql-native/source/
-I../../vibe.d/source/ -I../../vibe.d/import -L-levent -L-lssl
-L-lcrypto main.d

That actually does reach "done" for me. I wonder if maybe the way
you're linking is causing some incorrect version of libevent to be
used, thus somehow resulting in some deadlock?

Oh, and I'd toss in a "stdout.flush();" right after you write "done"
just to make extra sure the message isn't simply getting lost in some
buffer.

@Abscissa
Copy link
Author

On Thu, 30 May 2013 14:40:30 -0700
rjmcguire [email protected] wrote:

The closest I can get to compiling the below results in:
rdmd -version=VibeLibeventDriver -version=Have_vibe_d -I../../
github.com/rejectedsoftware/mysql-native/source/ -I../../
github.com/rejectedsoftware/vibe.d/source/ -I../../
github.com/D-Programming-Deimos/libevent/ main.d
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(252):
Error: undefined identifier 'acquire'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(253):
Error: undefined identifier 'release'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(254):
Error: undefined identifier 'isOwner'
../../
github.com/rejectedsoftware/mysql-native/source/mysql/connection.d(255):
Error: undefined identifier 'isOwner'

That's very strange. Is that with vibe.d v0.7.15 or something else? Can
you give me the commit hash on that vibe.d?

s-ludwig added a commit that referenced this issue May 31, 2013
acquire/release/isOwner was removed recently.
@s-ludwig
Copy link

That was caused by the latest master changes, where the explicit acquire/release was removed in favor of implicit ownership during the call to one of the blocking functions. I've fixed it in mysql-native, but probably it also makes sense to add deprecated dummy versions of those functions before the next release...

@rjmcguire
Copy link

On Fri, May 31, 2013 at 8:04 AM, Nick Sabalausky
[email protected]:

Hmm, it's difficult for me to attempt it that way since I'm not sure
where all my openssl and libevent stuff is (I normally just let apt-get
handle those libs "magically" ;) ).

the libevent.a is actually just the d files from deimos, so that I don't
get linking errors referring to the d module.
I'm also using libevent v2.0-5.

On my Debian 6 box with libevent v2.0-5, this command works:

rdmd -version=VibeCustomMain -version=VibeLibeventDriver
-version=Have_vibe_d -I../../mysql-native/source/
-I../../vibe.d/source/ -I../../vibe.d/import -L-levent -L-lssl
-L-lcrypto main.d

That actually does reach "done" for me. I wonder if maybe the way
you're linking is causing some incorrect version of libevent to be
used, thus somehow resulting in some deadlock?

Oh, and I'd toss in a "stdout.flush();" right after you write "done"
just to make extra sure the message isn't simply getting lost in some
buffer.

I'm pretty sure that writeln does a flush. I know that write doesn't.
Anyway the actual problem I'm seeing is that my mysql login authenticator
locks up so when I submit
login credentials the page just keeps loading and loading, tracked it to
the mysql query not working.

@rjmcguire
Copy link

Seems you need to make the dub package depend on vibe now:

Building configuration "library", build type debug
Running dmd...
source/mysql/db.d(8): Error: module connectionpool is in file
'vibe/core/connectionpool.d' which cannot be read

On Fri, May 31, 2013 at 9:08 AM, Sönke Ludwig [email protected]:

That was caused by the latest master changes, where the explicit acquire/
release was removed in favor of implicit ownership during the call to one
of the blocking functions. I've fixed it in mysql-native, but probably it
also makes sense to add deprecated dummy versions of those functions before
the next release...


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-18727253
.

@s-ludwig
Copy link

Seems you need to make the dub package depend on vibe now: Building configuration "library", build type debug Running dmd... source/mysql/db.d(8): Error: module connectionpool is in file 'vibe/core/connectionpool.d' which cannot be read

It's supposed to use vibe.d only when it's added as a dependency by another package (and thus Have_vibe_d gets defined by DUB). I think in your case you pass -version=Have_vibe_d on the compiler command line, but don't pass the import directory for vibe.d.

@s-ludwig
Copy link

BTW, not sure if this helps, but when debugging why something works with DUB and not when compiling directly, you can run dub build -v or dub build --rdmd -v to see the exact command line that is used for building.

@rjmcguire
Copy link

thanks, you nailed it. I had put Have_vibe_d in the library config in
package.json. Seems there is no way to compile a libmysql-native.a file if
you don't do that though.

BTW: how do you get dub to use the system installed packages? It doesn't
use them by default.

On Fri, May 31, 2013 at 9:16 AM, Sönke Ludwig [email protected]:

Seems you need to make the dub package depend on vibe now: Building
configuration "library", build type debug Running dmd...
source/mysql/db.d(8): Error: module connectionpool is in file
'vibe/core/connectionpool.d' which cannot be read

It's supposed to use vibe.d only when it's added as a dependency by
another package (and thus Have_vibe_d gets defined by DUB). I think in
your case you pass -version=Have_vibe_d on the compiler command line, but
don't pass the import directory for vibe.d.


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-18727627
.

@rjmcguire
Copy link

thanks yes I've used that quite a few times.

On Fri, May 31, 2013 at 9:20 AM, Rory McGuire [email protected] wrote:

thanks, you nailed it. I had put Have_vibe_d in the library config in
package.json. Seems there is no way to compile a libmysql-native.a file if
you don't do that though.

BTW: how do you get dub to use the system installed packages? It doesn't
use them by default.

On Fri, May 31, 2013 at 9:16 AM, Sönke Ludwig [email protected]:

Seems you need to make the dub package depend on vibe now: Building
configuration "library", build type debug Running dmd...
source/mysql/db.d(8): Error: module connectionpool is in file
'vibe/core/connectionpool.d' which cannot be read

It's supposed to use vibe.d only when it's added as a dependency by
another package (and thus Have_vibe_d gets defined by DUB). I think in
your case you pass -version=Have_vibe_d on the compiler command line,
but don't pass the import directory for vibe.d.


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-18727627
.

@s-ludwig
Copy link

Seems there is no way to compile a libmysql-native.a file if you don't do that though.

I've just committed a fix for compiling mysql-native without the Have_vibe_d (using dub build). I had to remove a static assert, which unfortunately result in a worse error message when someone tries to use MysqlDB without vibe.d available... hm.. maybe a dummy template would work instead...

BTW: how do you get dub to use the system installed packages? It doesn't use them by default.

It should automatically use them, but should also prefer user installed packages and packages installed in the .dub folder of a project. However, I'm currently reworking how packages are looked up and installed. So probably, if there is a bug, it will be fixed in the process.

@rjmcguire
Copy link

On Fri, May 31, 2013 at 9:29 AM, Sönke Ludwig [email protected]:

Seems there is no way to compile a libmysql-native.a file if you don't do
that though.

I've just committed a fix for compiling mysql-native without the
Have_vibe_d (using dub build). I had to remove a static assert, which
unfortunately result in a worse error message when someone tries to use
MysqlDB without vibe.d available... hm.. maybe a dummy template would
work instead...

BTW: how do you get dub to use the system installed packages? It doesn't
use them by default.

It should automatically use them, but should also prefer user installed
packages and packages installed in the .dub folder of a project. However,
I'm currently reworking how packages are looked up and installed. So
probably, if there is a bug, it will be fixed in the process.

Thanks. it doesn't seem to ever find the system packages it installed on my
system.

BTW: how does one access the session from a function that is registered
with registerRestInterface()?

Need a way to check what details a authenticated user can see.

Thanks.

@s-ludwig
Copy link

BTW: how does one access the session from a function that is registered with registerRestInterface()?

Need a way to check what details a authenticated user can see.

A REST service should never have a session running (or it is no actual REST interface), so there is no direct way to do this. But a possibility is to register an interception handler that puts the session parameters (or any other parameters) in the HTTPServerRequest.params map and add the appropriate parameter to the method in the class passed to registerRestInterface: Conceptually:

class Intf {
    void test(string _username) { ... }
}

auto router = new URLRouter;
router.any("*", (req, res) { req.param["username"] = req.session["username"]; });
registerRestInterface(router, new Intf);

BTW: That e-mail reply feature of github is seriously broken. How on earth do they think it's a good idea to remove all formatting and even all line breaks from a mail?

@rjmcguire
Copy link

On Fri, May 31, 2013 at 1:50 PM, Sönke Ludwig [email protected]:

A REST service should never have a session running (or it is no actual
REST interface), so there is no direct way to do this. But a possibility is
to register an interception handler that puts the session parameters (or
any other parameters) in the HTTPServerRequest.params map and add the
appropriate parameter to the method in the class passed to
registerRestInterface: Conceptually:

class Intf {
void test(string _username) { ... }
}

auto router = new URLRouter;
router.any("*", (req, res) { req.param["username"] = req.session["username"]; });
registerRestInterface(router, new Intf);

BTW: That e-mail reply feature of github is seriously broken. How on
earth do they think it's a good idea to remove all formatting and even all
line breaks from a mail?

Very true. If the user supplied req.param["username"] it would be
overridden so that should work for me to be able to keep the auth stuff in
the any route.

@Abscissa
Copy link
Author

Abscissa commented Oct 5, 2014

I'm closing this since the original problem has been resolved.

@Abscissa Abscissa closed this as completed Oct 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants