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

"procedure entry point CreateFile2 could not be located" when running gluon.exe #777

Closed
Etherian opened this issue Aug 17, 2019 · 5 comments · Fixed by #778 or #797
Closed

"procedure entry point CreateFile2 could not be located" when running gluon.exe #777

Etherian opened this issue Aug 17, 2019 · 5 comments · Fixed by #778 or #797

Comments

@Etherian
Copy link
Contributor

Etherian commented Aug 17, 2019

After pulling the most recent commits on master and updating my Rust toolchain to 1.37.0, building the REPL yields a broken executable. When run from PowerShell it immediately exits with code -1073741511, and when run from cmd.exe (well, actually Clink) an error dialog appears, stating

The procedure entry point CreateFile2 could not be located in the dynamic link library KERNEL32.dll.

It's odd that the binary would be requesting CreateFile2, since I'm building for and on Windows 7 and the CreateFile2 function was added in Windows 8.

This behavior is unlikely to be related to Gluon itself but may be caused by a bug in one of its dependencies, so I thought I should mention it. I'll also be opening an issue in the Rust repository in case there is a bug in the toolchain. [was unnecessary]

@Etherian
Copy link
Contributor Author

Etherian commented Aug 17, 2019

Commits before 95a7edf (master~7) yield a functioning binary while it and later commits continue to yield a broken one, so the errant behavior does appear to be caused by one of Gluon's dependencies and appears to have been introduced in PR #759.

edit: referred to wrong hash

@Marwes
Copy link
Member

Marwes commented Aug 17, 2019

This is most likely due to https://github.com/kkawakam/rustyline being updated. ec1d26d should be the last working commit if that is the case

@Etherian
Copy link
Contributor Author

Yep. ec1d26d yields a functional binary; 10ef8cd does not.

@Etherian
Copy link
Contributor Author

Reverting the RustyLine-related changes made to repl/src/repl.rs in 10ef8cd is enough to build a working binary with the current master ba66854.

That is, the following changes to repl/src/repl.rs fix the issue in ba66854:

diff --git a/repl/src/repl.rs b/repl/src/repl.rs
index be2dac8a..b15dc443 100644
--- a/repl/src/repl.rs
+++ b/repl/src/repl.rs
@@ -1,6 +1,6 @@
 extern crate gluon_completion as completion;

-use std::{borrow::Cow, error::Error as StdError, path::PathBuf, str::FromStr, sync::Mutex};
+use std::{error::Error as StdError, path::PathBuf, str::FromStr, sync::Mutex};

 use futures::{
     future::{self, Either},
@@ -161,55 +161,13 @@ fn complete(thread: &Thread, name: &str, fileinput: &str, pos: usize) -> GluonRe
         .collect())
 }

-struct Completer {
-    thread: RootedThread,
-    hinter: rustyline::hint::HistoryHinter,
-    highlighter: rustyline::highlight::MatchingBracketHighlighter,
-}
+struct Completer(RootedThread);

 impl rustyline::Helper for Completer {}

-impl rustyline::hint::Hinter for Completer {
-    fn hint(&self, line: &str, pos: usize, ctx: &rustyline::Context) -> Option<String> {
-        self.hinter.hint(line, pos, ctx)
-    }
-}
-
-impl rustyline::highlight::Highlighter for Completer {
-    fn highlight<'l>(&self, line: &'l str, pos: usize) -> Cow<'l, str> {
-        self.highlighter.highlight(line, pos)
-    }
-
-    fn highlight_prompt<'b, 's: 'b, 'p: 'b>(
-        &'s self,
-        prompt: &'p str,
-        default: bool,
-    ) -> Cow<'b, str> {
-        self.highlighter.highlight_prompt(prompt, default)
-    }
-
-    fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> {
-        // TODO Detect when windows supports ANSI escapes
-        if cfg!(windows) {
-            Cow::Borrowed(hint)
-        } else {
-            use ansi_term::Style;
-            Cow::Owned(Style::new().dimmed().paint(hint).to_string())
-        }
-    }
-
-    fn highlight_candidate<'c>(
-        &self,
-        candidate: &'c str,
-        completion: rustyline::CompletionType,
-    ) -> Cow<'c, str> {
-        self.highlighter.highlight_candidate(candidate, completion)
-    }
+impl rustyline::hint::Hinter for Completer {}

-    fn highlight_char(&self, line: &str, pos: usize) -> bool {
-        self.highlighter.highlight_char(line, pos)
-    }
-}
+impl rustyline::highlight::Highlighter for Completer {}

 impl rustyline::completion::Completer for Completer {
     type Candidate = String;
@@ -220,7 +178,7 @@ impl rustyline::completion::Completer for Completer {
         pos: usize,
         _: &rustyline::Context,
     ) -> rustyline::Result<(usize, Vec<String>)> {
-        let result = complete(&self.thread, "<repl>", line, pos);
+        let result = complete(&self.0, "<repl>", line, pos);

         // Get the start of the completed identifier
         let ident_start = line[..pos]
@@ -300,11 +258,7 @@ fn new_editor(vm: WithVM<()>) -> IO<Editor> {
     if let Err(err) = history_result {
         warn!("Unable to load history: {}", err);
     }
-    editor.set_helper(Some(Completer {
-        thread: vm.vm.root_thread(),
-        hinter: rustyline::hint::HistoryHinter {},
-        highlighter: rustyline::highlight::MatchingBracketHighlighter::default(),
-    }));
+    editor.set_helper(Some(Completer(vm.vm.root_thread())));
     IO::Value(Editor {
         editor: Mutex::new(editor),
     })

@Marwes
Copy link
Member

Marwes commented Aug 18, 2019

Looks like the issue is in ansi_term then.

ogham/rust-ansi-term@23456d5#diff-0d46108ce4a3c312f023e721b094d40c

Marwes added a commit to Marwes/gluon that referenced this issue Aug 18, 2019
Marwes added a commit to Marwes/gluon that referenced this issue Aug 18, 2019
Marwes added a commit to Marwes/gluon that referenced this issue Aug 18, 2019
bors bot added a commit that referenced this issue Aug 21, 2019
778: fix: Don't depend on ansi_term in windows to make windows 7 work r=Marwes a=Marwes

Fixes #777

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
bors bot added a commit that referenced this issue Aug 21, 2019
776: More performance improvements r=Marwes a=Marwes



778: fix: Don't depend on ansi_term in windows to make windows 7 work r=Marwes a=Marwes

Fixes #777

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
bors bot added a commit that referenced this issue Aug 21, 2019
778: fix: Don't depend on ansi_term in windows to make windows 7 work r=Marwes a=Marwes

Fixes #777

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
bors bot added a commit that referenced this issue Aug 25, 2019
778: fix: Don't depend on ansi_term in windows to make windows 7 work r=Marwes a=Marwes

Fixes #777

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
bors bot added a commit that referenced this issue Aug 30, 2019
778: fix: Don't depend on ansi_term in windows to make windows 7 work r=Marwes a=Marwes

Fixes #777

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
bors bot added a commit that referenced this issue Aug 31, 2019
778: fix: Don't depend on ansi_term in windows to make windows 7 work r=Marwes a=Marwes

Fixes #777

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
bors bot added a commit that referenced this issue Aug 31, 2019
778: fix: Don't depend on ansi_term in windows to make windows 7 work r=Marwes a=Marwes

Fixes #777

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
@bors bors bot closed this as completed in 58e2a8b Aug 31, 2019
Marwes added a commit to Marwes/gluon that referenced this issue Oct 27, 2019
<a name="v0.13.0"></a>
## v0.13.0 (2019-10-27)

#### Performance

*   Only do one hash lookup when creating a Symbol ([a709c71](gluon-lang@a709c71))
*   Shrink Type's size to 48 bytes (from 64) ([178180f](gluon-lang@178180f))
*   Avoid RefCell in Fixed* structurs (-1%) ([de32dbd](gluon-lang@de32dbd))
*   Avoid recursion in implicits.rs ([89eb836](gluon-lang@89eb836))
*   Only mark types with unbound generics as HAS_GENERICS ([3d835a8](gluon-lang@3d835a8))
*   Avoid computing the plain name in name_eq (-3%) ([a7ac9f8](gluon-lang@a7ac9f8))
* **check:**
  *  Use RefCell::get_mut when possible ([1244143](gluon-lang@1244143))
  *  Remove redundant operations in union ([f3d4203](gluon-lang@f3d4203))
  *  No need to lookup the type again before querying the level ([5e4efe3](gluon-lang@5e4efe3))
  *  Remove some branches in the occurs check¨ ([03e7c3b](gluon-lang@03e7c3b))
  *  Only initialize the variable generator when it is necessary (-3%) ([793b658](gluon-lang@793b658))
  *  Only do one lookup/insertion on the implicit definition map ([0ea13ff](gluon-lang@0ea13ff))
  *  Narrow down the implicit parititioning further (-10%) ([a9c965b](gluon-lang@a9c965b))
  *  Avoid looking through metadata when checking for an implicit type ([4a3662e](gluon-lang@4a3662e))
  *  Only add implicit fields if the binding is implicit ([da861eb](gluon-lang@da861eb), breaks [#](https://github.com/gluon-lang/gluon/issues/))
* **optimize:**  Allocate core syntax directly into arenas ([723ec4d](gluon-lang@723ec4d))
* **parser:**
  *  Shrink the Token type and remove it's need to Drop ([3016f25](gluon-lang@3016f25))
  *  Simplify tokenization iterators ([c7061c7](gluon-lang@c7061c7))
* **vm:**
  *  Add function inlining ([5093137](gluon-lang@5093137))
  *  Eliminate redundant match expressions ([945fb83](gluon-lang@945fb83))
  *  Implement inter-module dead code elimination ([ab1b1b8](gluon-lang@ab1b1b8))
  *  Avoid tracing global values unless we are in the root gc (-7%) ([48a5313](gluon-lang@48a5313))
  *  Avoid the bounds check when fetching instructions ([c2778e7](gluon-lang@c2778e7))
  *  Faster updates to the stack frame ([2b94a3a](gluon-lang@2b94a3a))
  *  Cache the frame offset for the stack (-20%) ([0469cb2](gluon-lang@0469cb2))
  *  Copy instead of clone unrooted gc values ([a0396f4](gluon-lang@a0396f4))

#### Breaking Changes

*   Replace Compiler with the ThreadExt trait ([c16132e](gluon-lang@c16132e), breaks [#](https://github.com/gluon-lang/gluon/issues/))
* **check:**  Only add implicit fields if the binding is implicit ([da861eb](gluon-lang@da861eb), breaks [#](https://github.com/gluon-lang/gluon/issues/))

#### Bug Fixes

*   Don't leak implicit bindings into adjacent scopes ([5681ffc](gluon-lang@5681ffc), closes [gluon-lang#783](gluon-lang#783))
*   ignore formatting in std.test due to a bug ([bdccee6](gluon-lang@bdccee6))
*   rerefix formatting ([3116616](gluon-lang@3116616))
*   refix formatting ([fcb7f0b](gluon-lang@fcb7f0b))
*   fix formatting and apply naming suggesions ([6bb0d87](gluon-lang@6bb0d87))
*   Make the behaviour consistent for `Show Char` ([0ff8987](gluon-lang@0ff8987))
*   Avoid infinite loops/extremely slow optimization ([dc7ec72](gluon-lang@dc7ec72))
*   Expand macros inside macros ([5a29433](gluon-lang@5a29433))
*   Invalidate text properly so rexpect tests work ([92e4508](gluon-lang@92e4508))
*   Don't depend on ansi_term in windows to make windows 7 work ([58e2a8b](gluon-lang@58e2a8b), closes [gluon-lang#777](gluon-lang#777))
*   Add tests and fix the regression with clone_userdata ([df07872](gluon-lang@df07872))
*   Ensure that threads are dropped when using child threads ([b9efb51](gluon-lang@b9efb51))
* **check:**  Handle aliases better in `do` ([770e52e](gluon-lang@770e52e), closes [gluon-lang#766](gluon-lang#766))
* **repl:**  make the REPL respect --no-std ([e797470](gluon-lang@e797470))
* **std:**  export missing assertions in std.test ([41f4fc5](gluon-lang@41f4fc5))
* **vm:**
  *  Don't (rust) panic in string.split_at ([50f937b](gluon-lang@50f937b), closes [gluon-lang#757](gluon-lang#757))
  *  Accept trailing comma in record macros ([f35c0b9](gluon-lang@f35c0b9), closes [gluon-lang#770](gluon-lang#770))

#### Features

*   Use implicit Monoids in std.foldable ([295b8c3](gluon-lang@295b8c3))
*   Add a mutable string type to the ST monad ([9ec946b](gluon-lang@9ec946b))
*   Allow attributes to be specified on fields inside types ([fb35db5](gluon-lang@fb35db5))
*   Provide std.effect.io as a mirror of std.io ([66e49b3](gluon-lang@66e49b3))
*   Replace Compiler with the ThreadExt trait ([c16132e](gluon-lang@c16132e), breaks [#](https://github.com/gluon-lang/gluon/issues/))
*   Use salsa for incremental compilation ([7bc8253](gluon-lang@7bc8253))
*   Add history hints and bracket highlight to the REPL ([10ef8cd](gluon-lang@10ef8cd))
*   Use line/column numbers in lambda names ([201fdfb](gluon-lang@201fdfb))
* **codegen:**  Map Rust's struct enums to records in Gluon. ([afb682e](gluon-lang@afb682e))
* **repl:**  add --no-std option to gluon.exe ([f2c1819](gluon-lang@f2c1819))
* **std:**
  *  add ordering assertions ([3efac99](gluon-lang@3efac99))
  *  add a few functions to std.test & std.effect.error ([58e0043](gluon-lang@58e0043))
* **vm:**  Make macro errors implement PartialEq, Eq, Hash and Clone ([039825a](gluon-lang@039825a))
@Marwes Marwes mentioned this issue Oct 27, 2019
bors bot added a commit that referenced this issue Oct 27, 2019
797: Version 0.13.0 r=Marwes a=Marwes

<a name="v0.13.0"></a>
## v0.13.0 (2019-10-27)

This version mostly contains performance improvements, both during compilation and execution. The most notable of which is that gluon now has function inlining and constant folding. This lets simple calls like `1 + 2` be optimized into `3` at compile time and `x + 1` are now compiled as the primitive addition instruction instead of calling `std.int.num.(+)` first. Optimizations is enabled by default but can be disabled via the ´optimize` compiler setting. Together with some other optimizations, the factorial tests have received a 4x speedup. There are still more work to do on optimizing the virtual machine however as lua still comes out ahead by another 4x speedup.

Some breaking changes have occurred, the `gluon::Compiler` struct is no more. Instead, all it's methods are exposed via the `gluon::ThreadExt` trait which are implemented on `Thread/RootedThread` which should make it much easier to use.

```rust
Compiler::new().run_expr(&vm, ...)
// Change to
use gluon::ThreadExt;
vm.run_expr(...)
```

The compilation process has been largely rewritten and is now built on top of https://github.com/salsa-rs/salsa which enables better control over how compilation steps are cached. This may lead to some regressions in memory usage (please report!) but should also allow for less memory usage in the long run for apps that needs it as well.

In the language itself, the most significant addition is the `std.effect.io` module. This is an exact mirror of `std.io` but it uses effects which fixes the annoyance of having to write `lift` to move `IO` actions into `Eff` everywhere.

#### Performance

*   Only do one hash lookup when creating a Symbol ([a709c71](a709c71))
*   Shrink Type's size to 48 bytes (from 64) ([178180f](178180f))
*   Avoid RefCell in Fixed* structurs (-1%) ([de32dbd](de32dbd))
*   Avoid recursion in implicits.rs ([89eb836](89eb836))
*   Only mark types with unbound generics as HAS_GENERICS ([3d835a8](3d835a8))
*   Avoid computing the plain name in name_eq (-3%) ([a7ac9f8](a7ac9f8))
* **check:**
  *  Use RefCell::get_mut when possible ([1244143](1244143))
  *  Remove redundant operations in union ([f3d4203](f3d4203))
  *  No need to lookup the type again before querying the level ([5e4efe3](5e4efe3))
  *  Remove some branches in the occurs check¨ ([03e7c3b](03e7c3b))
  *  Only initialize the variable generator when it is necessary (-3%) ([793b658](793b658))
  *  Only do one lookup/insertion on the implicit definition map ([0ea13ff](0ea13ff))
  *  Narrow down the implicit partitioning further (-10%) ([a9c965b](a9c965b))
  *  Avoid looking through metadata when checking for an implicit type ([4a3662e](4a3662e))
  *  Only add implicit fields if the binding is implicit ([da861eb](da861eb), breaks [#](https://github.com/gluon-lang/gluon/issues/))
* **optimize:**  Allocate core syntax directly into arenas ([723ec4d](723ec4d))
* **parser:**
  *  Shrink the Token type and remove it's need to Drop ([3016f25](3016f25))
  *  Simplify tokenization iterators ([c7061c7](c7061c7))
* **vm:**
  *  Add function inlining ([5093137](5093137))
  *  Eliminate redundant match expressions ([945fb83](945fb83))
  *  Implement inter-module dead code elimination ([ab1b1b8](ab1b1b8))
  *  Avoid tracing global values unless we are in the root gc (-7%) ([48a5313](48a5313))
  *  Avoid the bounds check when fetching instructions ([c2778e7](c2778e7))
  *  Faster updates to the stack frame ([2b94a3a](2b94a3a))
  *  Cache the frame offset for the stack (-20%) ([0469cb2](0469cb2))
  *  Copy instead of clone unrooted gc values ([a0396f4](a0396f4))

#### Breaking Changes

*   Replace Compiler with the ThreadExt trait ([c16132e](c16132e), breaks [#](https://github.com/gluon-lang/gluon/issues/))
* **check:**  Only add implicit fields if the binding is implicit ([da861eb](da861eb), breaks [#](https://github.com/gluon-lang/gluon/issues/))

#### Bug Fixes

*   Don't leak implicit bindings into adjacent scopes ([5681ffc](5681ffc), closes [#783](#783))
*   ignore formatting in std.test due to a bug ([bdccee6](bdccee6))
*   rerefix formatting ([3116616](3116616))
*   refix formatting ([fcb7f0b](fcb7f0b))
*   fix formatting and apply naming suggesions ([6bb0d87](6bb0d87))
*   Make the behaviour consistent for `Show Char` ([0ff8987](0ff8987))
*   Avoid infinite loops/extremely slow optimization ([dc7ec72](dc7ec72))
*   Expand macros inside macros ([5a29433](5a29433))
*   Invalidate text properly so rexpect tests work ([92e4508](92e4508))
*   Don't depend on ansi_term in windows to make windows 7 work ([58e2a8b](58e2a8b), closes [#777](#777))
*   Add tests and fix the regression with clone_userdata ([df07872](df07872))
*   Ensure that threads are dropped when using child threads ([b9efb51](b9efb51))
* **check:**  Handle aliases better in `do` ([770e52e](770e52e), closes [#766](#766))
* **repl:**  make the REPL respect --no-std ([e797470](e797470))
* **std:**  export missing assertions in std.test ([41f4fc5](41f4fc5))
* **vm:**
  *  Don't (rust) panic in string.split_at ([50f937b](50f937b), closes [#757](#757))
  *  Accept trailing comma in record macros ([f35c0b9](f35c0b9), closes [#770](#770))

#### Features

*   Use implicit Monoids in std.foldable ([295b8c3](295b8c3))
*   Add a mutable string type to the ST monad ([9ec946b](9ec946b))
*   Allow attributes to be specified on fields inside types ([fb35db5](fb35db5))
*   Provide std.effect.io as a mirror of std.io ([66e49b3](66e49b3))
*   Replace Compiler with the ThreadExt trait ([c16132e](c16132e), breaks [#](https://github.com/gluon-lang/gluon/issues/))
*   Use salsa for incremental compilation ([7bc8253](7bc8253))
*   Add history hints and bracket highlight to the REPL ([10ef8cd](10ef8cd))
*   Use line/column numbers in lambda names ([201fdfb](201fdfb))
* **codegen:**  Map Rust's struct enums to records in Gluon. ([afb682e](afb682e))
* **repl:**  add --no-std option to gluon.exe ([f2c1819](f2c1819))
* **std:**
  *  add ordering assertions ([3efac99](3efac99))
  *  add a few functions to std.test & std.effect.error ([58e0043](58e0043))
* **vm:**  Make macro errors implement PartialEq, Eq, Hash and Clone ([039825a](039825a))

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants