Skip to content

Binary file from dart2native can't be used from Linux's path #38912

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
BLeAm opened this issue Oct 16, 2019 · 8 comments
Closed

Binary file from dart2native can't be used from Linux's path #38912

BLeAm opened this issue Oct 16, 2019 · 8 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) vm-native

Comments

@BLeAm
Copy link

BLeAm commented Oct 16, 2019

The single binary files that created with dart2native can't be put and used from Linux's path, it will print the usage message instead, like:

$ dart2native hello.dart
Generated: /home/blahblah/hello.exe

$ ./hello.exe
hello world

$ sudo mv hello.exe /usr/local/bin
$ hello.exe
Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]

I've found this issue with Dart 2.6.0-dev.7.0 on Linux.

@ghost ghost self-assigned this Oct 16, 2019
@ghost
Copy link

ghost commented Oct 16, 2019

Thank you for reporting this issue. I'm investigating.

In the meantime, can I get you to test if you're able to work around the issue by running the binary via a path instead of just the binary name? I.e.:
$ cd /usr/local/ ; bin/hello.exe
or
$ /usr/local/bin/hello.exe
or even

$ `which hello.exe`

@BLeAm
Copy link
Author

BLeAm commented Oct 16, 2019

Both ways of running it, from absolute/relative-path, work correctly.
Thank you for pointing out the workaround.

@srawlins srawlins added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-native type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Oct 16, 2019
dart-bot pushed a commit that referenced this issue Oct 18, 2019
Loading of appended snapshots used to try read the executable itself
via arg[0] which holds the "path" to the executable.
However, when the executable is being invoked via PATH the "path"
can be just the name of the executable with no actual path.
This would cause the file reading to fail to find the file and
therefore fail to read.
This in turn caused standalone executables to fail to run when invoked
via PATH.

Bug: #38912
Change-Id: I08501661441db90ce6cff96a9337a5770ec3524d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121853
Commit-Queue: Clement Skau <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
dart-bot pushed a commit that referenced this issue Oct 21, 2019
Loading of appended snapshots used to try read the executable itself
via arg[0] which holds the "path" to the executable.
However, when the executable is being invoked via PATH the "path"
can be just the name of the executable with no actual path.
This would cause the file reading to fail to find the file and
therefore fail to read.
This in turn caused standalone executables to fail to run when invoked
via PATH.

Bug: #38912
Change-Id: I08501661441db90ce6cff96a9337a5770ec3524d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121853
Commit-Queue: Clement Skau <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
@ghost
Copy link

ghost commented Oct 22, 2019

This should now have been fixed at HEAD so I'll go ahead and close this issue.
Note that it might still be a short while before the fix lands in dev and stable releases.

@ghost ghost closed this as completed Oct 22, 2019
@Ephenodrom
Copy link

Does someone know if version 2.7.0 already includes this fix ? I think i have the same problem after generating an executable on Ubuntu and uploading it via SCP to a Debian machine. I try to run the executable on the Debian machine and it prints out the usage message.

@Ephenodrom
Copy link

@cskau-g Do you have any information about my question ?

@Ephenodrom
Copy link

Ephenodrom commented Jan 30, 2020

@cskau-g I tried it again with version 2.7.1 but still the same problem.

Does someone know if version 2.7.0 already includes this fix ? I think i have the same problem after generating an executable on Ubuntu and uploading it via SCP to a Debian machine. I try to run the executable on the Debian machine and it prints out the usage message.

@ghost
Copy link

ghost commented Jan 31, 2020

@Ephenodrom, It should work in 2.7.1, yes. Testing it locally confirms this as well.

It is of course possible you're running into a separate problem.
Are both systems X64? Perhaps there are some significant differences between the libc/kernels that cause loading the embedded ELF to fail?

You could try testing dart2native locally on your Debian system and verify you can at least run executables built there.

If you continue to experience issues like this, feel free to start a new issue to track this.
But in that case please include as much information about the systems as possible, to help make debugging a little easier.

Thanks.

@Ephenodrom
Copy link

Hello @cskau-g
I think the problem comes from a different issue and i think it is more of a problem of my webhosting server where i have limited access to the OS it is running on. I opened another issue to make it clear whether is is a bug or a problem from my site.

#40405

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) vm-native
Projects
None yet
Development

No branches or pull requests

3 participants