Skip to content

dart-ext loading does not work when using package urls #6264

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

Closed
madsager opened this issue Oct 25, 2012 · 14 comments
Closed

dart-ext loading does not work when using package urls #6264

madsager opened this issue Oct 25, 2012 · 14 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io

Comments

@madsager
Copy link
Contributor

From email thread on misc mailing list:

Here is pseudo-code.

------------- package 'some'---------------

==lib/src/some_extension.dart
import "dart-ext:some_extension";
==EOF

==lib/some.dart
library some;

import 'src/some_extension.dart';
export 'src/some_extension.dart';
==EOF

Inside package all works fine.


--------- application 'mayapp'-------------

Variant #­1 (WORKING, NO PROBLEM)
==myapp.dart

import '../path/to/some/package/some.dart';


Variant #­2 (NOT WORKING, PROBLEMATIC)
==myapp.dart

import 'package:some/some.dart';

unexpected error in library path'package:some/src/some_extension.dart': Error: line 1 pos 1: library handler failed
import 'dart-ext:some_extension';
^

'package:some/some.dart': Error: line 3 pos 1: library handler failed
import 'src/some_extension.dart';
^

@whesse
Copy link
Contributor

whesse commented Oct 26, 2012

This looks like an issue with the package manager. We need to decide if extensions will be hosted by pub, and how it will download their native libraries.

A dart-ext:foo URL for a library import means that the loader will look for a native shared library named foo.dll, libfoo.so, or libfoo.dylib, load it, and run the init_foo function from it. So if we want the package manager to handle this, it must download the appropriate shared library. and place it in the right directory relative to the importing library.

In the example, even if the library is in the right place in the packages cache, the relative URL is not being found correctly. That is an issue that will need to be fixed in IO - perhaps just recognizing the package: scheme. So there is an IO component to this as well.


cc @munificent.
Removed Area-IO label.
Added Area-Pub label.

@whesse
Copy link
Contributor

whesse commented Oct 26, 2012

Marked this as blocking #6290.

@whesse
Copy link
Contributor

whesse commented Oct 26, 2012

I have separated out the package manager aspect of this problem, and filed issue dart:6290 about it. So this bug is just tracking the handling of dart-ext imports into a library that has been loaded with a package: scheme in its URL. Changing the area back to IO.


Removed Area-Pub label.
Added Area-IO label.

@DartBot
Copy link

DartBot commented Nov 5, 2012

This comment was originally written by @mezoni


So this bug is just tracking the handling of dart-ext imports into a library that has been loaded with a package: scheme in its URL.

You have an interesting approach to what you do defective.
If the error is just not fun for you, you pretend that nothing is happening.

It is interesting to know your opinion.
It is good when the errors found in the virtual machine are discussed in the mail-list?


extensions.cc

Dart_Handle Extensions::LoadExtension(const char* extension_url,
                                      Dart_Handle parent_library) {
  char* library_path = strdup(extension_url);
  if (!library_path || !File::IsAbsolutePath(library_path)) {
    free(library_path);
    return Dart_Error("unexpected error in library path"); // Without newline and uninformative. What if path is not NULL? Where information about that?
  }


return Dart_Error("unexpected error in library path");

May be change this to
return Dart_Error("Do not panic, this is just unexpected error in library path. All the expected errors are tracked.");

Let's discuss this new error message in the mail list?

@madsager
Copy link
Contributor Author

Added Fixed label.

@DartBot
Copy link

DartBot commented Nov 25, 2012

This comment was originally written by @mezoni


I do not agree with the premise that fixed.
Nothing works.
Changed only an error message in "extensions.cc".

cannot find extension library'package:sample/src/sample_extension.dart': Error: line 3

pos 1: library handler failed
import 'dart-ext:sample_extension';

Previously, it was "unexpected error in library path".
It has now become "cannot find extension library".

Tested on on the bleeding edge (15292)

P.S.
This way works - import '../lib/sample.dart';
This not works - import 'package:sample/sample.dart';

@madsager
Copy link
Contributor Author

If it works to import '../lib/sample.dart' the package import should probably be 'package:sample/lib/sample.dart' since the file is in a lib directory?

I haven't been following how pub deals with these. However, I did change more than just the error message. ;-) On the VM, the 'package:' URIs are resolved relative to the package-root given to the VM. As far as I know, put uses symlinks to bind that with the layout of package, but maybe Bob can help more there?

Here is how I tested this patch:

Right after building, copy the test extension to a new directory.

cp xcodebuild/ReleaseIA32/libtest_extension.dylib /tmp/test/extension/
cp tests/standalone/io/test_extension.dart /tmp/test/extension/

Create the file /tmp/test/test.dart with the following contents:

import 'package:test_extension.dart';

main() {
  print(new Cat("kitty"));
}

Now, test it from the command-line passing in the package-root to the VM.

./xcodebuild/ReleaseIA32/dart --package-root=/tmp/test/extension/ /tmp/test/test.dart
cat kitty

So, the basic VM support seems to be working.

@munificent
Copy link
Member

Hey, Mads. When I try your repro steps, I get:

dyld: lazy symbol binding failed: Symbol not found: _Dart_IsError
  Referenced from: /tmp/test/extension/libtest_extension.dylib
  Expected in: flat namespace

dyld: Symbol not found: _Dart_IsError
  Referenced from: /tmp/test/extension/libtest_extension.dylib
  Expected in: flat namespace

Is there something I'm missing?

@madsager
Copy link
Contributor Author

Yes, I think you are building with the wrong target SDK. Are you using the same SDK for building and for target deployment:

{
  'variables': {
    'xcode_gcc_version': 'com.apple.compilers.llvmgcc42',
    'mac_sdk': '10.7',
    'mac_deployment_target': '10.7',
  }
}

You will see that issue if you only set mac_sdk and not mac_deployment_target.

@madsager
Copy link
Contributor Author

Oh, and in any case that means that the system did find the extension and loaded it properly. Something then went wrong with looking up symbols from the Dart C embedding API from the extension code.

@DartBot
Copy link

DartBot commented Nov 27, 2012

This comment was originally written by @mezoni


Here is answers to your questions.
Download, unzip, goto '/test' and follow instructions.


Attachment:
test_dart_ext.zip (248.07 KB)

@DartBot
Copy link

DartBot commented Nov 27, 2012

This comment was originally written by @mezoni


Agree fixed.
But not immediately after the announcement.
In 15292 did not work, it works in 15371.

@madsager
Copy link
Contributor Author

Issue #6924 has been merged into this issue.

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Area-Library, Library-IO labels.

@madsager madsager added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io labels May 14, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io
Projects
None yet
Development

No branches or pull requests

5 participants