Giter VIP home page Giter VIP logo

pharo-vm's Introduction

Pharo VM

This repository holds the code of the Pharo Virtual Machine. This implementation started as a fork of OpenSmalltalk-vm. The current project could not have been possible with all their previous work.

The current implementation presents the following core features:

  • an indirect threaded bytecode compiler using GNU extensions
  • a generational scavenger garbage collector: semi-space + nursery for the young generation, a mark-compact collecting for the old generation
  • a space for permanent objects that need not to be scanned by the GC
  • a baseline JIT compiler that
    • translates primitive operations using IR templates
    • translates bytecode methods using a simple abstract interpretation approach to reduce memory pressure (less loads/stores)
  • FFI through the well-known libFFI, and support for non-blocking FFI using worker threads

For more details about the whole Pharo VM project refer to our wiki.

Table of Contents

pharo-vm's People

Contributors

akgrant avatar akgrant43 avatar alisu avatar andreasraab avatar bastiendegardins avatar clementbera avatar codefrau avatar eliotmiranda avatar estebanlm avatar fniephaus avatar gettimothy avatar guillep avatar hogoww avatar johnmci avatar jordanmontt avatar krono avatar labsari avatar lwassermann avatar marianopeck avatar nicolas-cellier-aka-nice avatar palumbon avatar privat avatar qducasse avatar rmacnak avatar ronsaldo avatar sig avatar syrel avatar tesonep avatar timfel avatar timrowledge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pharo-vm's Issues

Use -fvisibility=hidden for compiling on Linux and in OS X

On Windows public symbols from a DLL must be exported explictly by using __declspec(dllexport). By default, on Linux and OS X all symbols are public by default, this behavior has the following problems:

  • Introducing compilation errors on the Windows version by mistake when working on the non-windows version.
  • Potential name clashes between the VM symbols and the symbols of a library used by VM through the FFI (on Linux without RTLD_DEEPBIND, not on Mac), or the symbols of an application embedding the VM.

To have this same behavior on Linux and OS X, the VM code should be compiled with -fvisibility=hidden , and public symbols must be tagged with the attribute attribute ((visibility ("default"))) . This attribute can be placed on the EXPORT macro.

Remove the manually generated plugin code

Several of the sources under extracted/plugins are generated from slang and should be removed from that location and be regenerated on each build instead. These files can be identified by looking for a header similar to this one:

static char __buildInfo[] = "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-dtl.66 uuid: a8a2bf10-e7b3-4963-90b3-d69a2bee77bb " __DATE__ ;

These generated code has to be removed in order to fix the gcc compilation warnings that are produced by them.

We need a VM development public Roadmap

Any open source project that is looking for attracting people and contributors needs an explicit development roadmap. We also need it in order to coordinate and know how to prioritize our development efforts, specially when we are working remotely.

Here I am proposing a roadmap for discussion. The result of this discussion should be published on the GitHub wiki of this project.


Wiki link for proposal: https://github.com/ronsaldo/opensmalltalk-vm/wiki/Roadmap
Proposal wiki repo: https://github.com/ronsaldo/opensmalltalk-vm.wiki.git

VM Development roadmap

The VM development roadmap is divided in milestones with features and bug fixes
that are mandated by the release cycle of each new Pharo version. In addition
to these required bug fixes and features, there are parallel features that are
desirable by the community, but they are currently not a development priority.


Pharo 8 VM development roadmap

Usable replacement of the non-headless VM

The headless VM executable must be an usable replacement of the current VM for running Pharo 8 images using SDL2 as the display backend. This involves the following features:

  • Drag an drop of an image file to the VM executable program (OS X and Windows).
  • Parse the same command line options as the headfull VM. Command line options removed or deprecated should be silently ignore to support seamlessly the usage of this VM in a CI environment for the image (e.g: SmalltalkCI).
  • Allow specifying an image file that is always executed for deploying a final program.
  • Automatically selection of an image file when there is a single image.
  • Selecting the image file with a dialog when double clicked, and there is no image to load, or multiple ambiguous image (OS X and Windows).

Stability

The headless VM for Pharo 8 should be stable and reliable in terms of being
usable for everyday work with a Pharo image. This VM should have at least the
same level of stability as current headfull VM. This requirement may be
difficult to achieve for the given deadlines, so some compromises should be
expected.


Pharo 9 and beyond VM development roadmap

Here goes a list with bug fixes and feature that are required for the VM for
future version of the VM.

Remove the heartbeat and use a Global Interpreter Lock (GIL)

The VM is constantly polling events and the scheduling through the usage of a
heartbeat thread for interrupting the VM. The usage of polling makes the VM
hard to integrate in some platforms, specially in mobile platforms (Android,
iOS), where the operating system events are delivered only through callbacks.
This constant polling also has a negative impact on battery consumption on
laptops, and excess CPU usage in cloud environments (increased cost). For this
reasons, we would like to remove the heartbeat and introduce a global
interpreter lock for having a single OS thread owning the VM at the time.

This refactoring introduces several technical difficulties that need to be solved, such as the following problems:

  • How to schedule delays without a hearbeat?
  • How and when to preempt Pharo processes?

Desirable VM features/bug fixes, and community wish list.

Coding style cleanup of existing code

The coding style of the existent VM code is not clearly defined and there are
several programming inconsistencies in the VM code. This inconsistencies are
mostly cosmetic, but there are also inconsistencies and the lack of guidelines
in important issues such as how to handle newly allocated memory, handling
strings in a safe way to avoid buffer overflows and security issues, how the C
code of the VM should be factored and tested. This cleanup is not a priority
because of the small current workforce working on the VM itself. In addition to
cleanup the coding style of the manually written C code, the coding style of
the generated Slang code should also be cleaned.

However, newly written code should start following some set of guidelines. A VM
is a core piece of software whose programming requires a strict discipline.

Embeddable VM

An embeddable VM is a desirable feature calling Pharo from in betwee

Support for compiling with Microsoft Visual C compiler (MSVC) in Windows

The standard way for compiling for Windows is to use the Microsoft
toolchain. With CMake we should be able to generate Visual Studio solutions
for compiling in Windows easily. Since Visual Studio 2017 there is direct
support for using CMake in the Microsoft IDE.

Supporting MSVC requires doing the following changes:

  • Make the usage of Cygwin optional on the CMake script.
  • Fix Slang code generation issues for MSVC.
  • Debug and fix compilation

In terms of the external dependencies, dependencies that are loaded through
the FFI do not need to be compiled with MSVC. This is possible because each DLL
in Windows have an isolated symbol table, so incompatibilities between
compilers are not a big of an issue on Window.

Doxygen generated documentation

The public and internal code of the VM should be documented. Using doxygen for
documenting in C/C++ projects is a standard way for doing this.

libgit2 load error on *nix - segfaults after fixing it (libssl)

i was hoping to try out the 'mars-gtk' experiment; but pharo is not behaving well on my system

the behavior is the same with 80/headless-latest, 90/headless-latest, 90/headless-stable, and 90/stable - upon launching pharo, i get this error (referring to libgit2):

$ ./pharo64-linux-headless-latest/pharo ./pharo64/Pharo9.0-SNAPSHOT-64bit-8ce6236.image
External module not found
ExternalLibraryFunction(Object)>>error:
ExternalLibraryFunction(Object)>>externalCallFailed
ExternalLibraryFunction(ExternalFunction)>>invokeWithArguments:
LGitLibrary>>libgit2_init
FFICalloutAPI>>function:library:
LGitLibrary(Object)>>ffiCall:library:options:
LGitLibrary(Object)>>ffiCall:library:
LGitLibrary(Object)>>ffiCall:
LGitLibrary>>libgit2_init

the library file looks fine

$ file lib/libgit2.so.0.25.1
lib/libgit2.so.0.25.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=bca31b8ef88a657faffdaa55c5960250ecbc7b9a, with debug_info, not stripped

i "fixed" that with the "latest" VM, by deleting the libgit2 libraries from the lib/ dir and adding a symlink to the system libgit2 lib - by "fixed", i mean that it allowed pharo to start without the FFI error - this trick worked for all image/VM combinations that i tried

$ rm lib/libgit2.so*
$ ln -s /usr/lib/libgit2.so.1.0.0 lib/libgit2.so.1.0.0

however, upon loading 'mars-gtk' with metacello, the "latest" VM crashed with a segfault; so its not clear that my "fix" was an improvement

after some poking around in the image, i found that metacello was trying to use SSH to download 'mars-gtk' and could not find any credentials - i changed the setting of "iceberg" in its GUI to prefer HTTPS and that allowed the git clone to start - it chugged away for about a minute looking quite normal, presenting several progress-bar widgets to completion - then it eventually crashed with another segfault - the problem seems to be with libssl now - perhaps related to #70 (closed as not-a-bug)

with the stable VM, replacing libgit2 as i described previously, eliminates that initial error also, as with the "latest" VM; but loading a package with metacello, fails immediately with this error, apparently before SSL becomes relevant:

Instance of Array did not understand #(#SqueakFFIPrims #primitiveCalloutWithArgs 4 13)
Array(Object)>>doesNotUnderstand: #(#SqueakFFIPrims #primitiveCalloutWithArgs 4 13)
Array(ExternalFunction)>>invokeWithArguments:
LGitRemote>>remote_fetch:refspecs:opts:reflog_message:
LGitSafeFFICalloutAPI(FFICalloutAPI)>>function:library:
LGitSafeFFICalloutAPI(FFICalloutAPI)>>function:module:
LGitRemote(LGitExternalObject)>>ffiCallSafely:options:
LGitRemote>>remote_fetch:refspecs:opts:reflog_message:

the call stack for "Array(ExternalFunction)>>invokeWithArguments:" show that 'nil' was passed in

maybe it would help if i compiled the VM from source on my system - would the 'headless' branch of this repo be compatible with the 'mars-gtk' package?

[Pharo branch]openssl download url doesn't exists

In ./third-party/openssl,spec, the first line contains a depreacted url (https://www.openssl.org/source/openssl-1.0.2q.tar.gz) that avoid to compile properly the image.

First Execution:

-----------------------------------------------------
if [ ! -d /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64 ]; then mkdir -p /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64; fi
wget -q --no-check-certificate  -O ../../.thirdparty-cache/openssl-1.0.2q.tar.gz https://www.openssl.org/source/openssl-1.0.2q.tar.gz
make[1]: *** [../third-party/Makefile.openssl:20: ../../.thirdparty-cache/openssl-1.0.2q.tar.gz] Error 8
make[1]: Leaving directory '/cygdrive/c/pharo-vm/opensmalltalk-vm/build.win64x64/pharo.cog.spur'
make: *** [../common/Makefile:156: debug] Error 2

Second execution:

-----------------------------------------------------
if [ ! -d /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64 ]; then mkdir -p /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64; fi
ESTEBAN: ENTER
tar x -f ../../.thirdparty-cache/openssl-1.0.2q.tar.gz -C builddbg/third-party
tar: This does not look like a tar archive

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
make[1]: *** [../third-party/Makefile.openssl:24: /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64/bin/ssleay32.dll] Error 2
make[1]: Leaving directory '/cygdrive/c/pharo-vm/opensmalltalk-vm/build.win64x64/pharo.cog.spur'
make: *** [../common/Makefile:156: debug] Error 2

Changing it to: https://www.openssl.org/source/openssl-1.1.1f.tar.gz and updating the version number doesn't fix the issue and more changes seems to be required:

-----------------------------------------------------
if [ ! -d /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64 ]; then mkdir -p /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64; fi
ESTEBAN: ENTER
tar x -f ../../.thirdparty-cache/openssl-1.1.1f.tar.gz -C builddbg/third-party
sed -i 's/symlink/copy/g'  builddbg/third-party/openssl-1.1.1f/util/mklink.pl
sed: can't read builddbg/third-party/openssl-1.1.1f/util/mklink.pl: No such file or directory
make[1]: *** [../third-party/Makefile.openssl:25: /cygdrive/c/pharo-vm/opensmalltalk-vm/.thirdparty-cache/windows/x86_64/bin/ssleay32.dll] Error 2
make[1]: Leaving directory '/cygdrive/c/pharo-vm/opensmalltalk-vm/build.win64x64/pharo.cog.spur'
make: *** [../common/Makefile:156: debug] Error 2

[Headless]Error opening Pharo 9.0 image

With the latest Pharo 9.0 image (build: 229, commit: 944aa46), and the latest version of the main branch of this repo (headless/ 9217edd).

After a successful build, I cannot open the image properly with the following command executed in ./build/dist/:
PharoConsole.exe --logLevel=4 'Pharo 9.0 - 64bit (development version, latest).image'

The error is the following:

[DEBUG] 2020-04-10 16:05:45 logParameters (src/parameters.c:272):Image file name: /cygdrive/c/.../Pharo 9.0 - 64bit (development
 version, latest).image
[DEBUG] 2020-04-10 16:05:45 logParameters (src/parameters.c:273):Is default Image: no
[DEBUG] 2020-04-10 16:05:45 logParameters (src/parameters.c:274):Is interactive session: no
[DEBUG] 2020-04-10 16:05:45 logParameterVector (src/parameters.c:262):vmParameters [count = 3]:
[DEBUG] 2020-04-10 16:05:45 logParameterVector (src/parameters.c:265): C:\pharo-vm\pharo-vm\build\dist\Phar
oConsole.exe
[DEBUG] 2020-04-10 16:05:45 logParameterVector (src/parameters.c:265): --logLevel=4
[DEBUG] 2020-04-10 16:05:45 logParameterVector (src/parameters.c:265): --headless
[DEBUG] 2020-04-10 16:05:45 logParameterVector (src/parameters.c:262):imageParameters [count = 0]:
[INFO ] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:78):Opening Image: /cygdrive/c/.../Pharo 9.0 - 64bit (development version, latest).image
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:95):Working Directory C:\pharo-vm\pharo-vm\build\dist
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:97):sizeof(int): 4
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:98):sizeof(long): 4
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:99):sizeof(long long): 8
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:100):sizeof(void*): 8
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:101):sizeof(sqInt): 8
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:102):sizeof(sqLong): 8
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:103):sizeof(float): 4
[DEBUG] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:104):sizeof(double): 8
[ERROR] 2020-04-10 16:05:45 loadPharoImage (src/client.c:170):Opening Image
[ERROR] 2020-04-10 16:05:45 vm_main_with_parameters (src/client.c:108):Error opening image file: /cygdrive/c/.../Pharo 9.0 - 64bit (development version, latest).image

OpenSSL 1.0.2 end of support from 1 Jan 2020

As per https://www.openssl.org/policies/releasestrat.html.

For cmake-based Pharo builds based on upstream directory layout, update third-party/openssl.spec URL and version numbers as below. For the headless layout, seems a bit more involved with fetching of cached versions from files.pharo.org.

openssl_spec_download_url:=https://www.openssl.org/source/openssl-1.1.1d.tar.gz
openssl_spec_archive_name:=openssl-1.1.1d.tar.gz
openssl_spec_unpack_dir_name:=openssl-1.1.1d
openssl_spec_product1_name_macOS:=libssl.1.1.dylib
openssl_spec_product2_name_macOS:=libcrypto.1.1.dylib
openssl_spec_product1_name_linux:=libssl.so.1.1
openssl_spec_product2_name_linux:=libcrypto.so.1.1
openssl_spec_product1_name_windows:=ssleay32.dll
openssl_spec_product2_name_windows:=libeay32.dll
openssl_spec_symlinks_macOS:=libssl*.dylib libcrypto*.dylib
openssl_spec_symlinks_linux:=libssl.so* libcrypto.so*

Commandline munging puts --interactive in wrong location

When the VM munges the commandline to insert the --interactive flag,
it is simply appending it which interferes in-Image CommandLineHandl-ing

With shell-only WSL Ubuntu...
./pharo Pharo.image eval 1 + 2
produces expected output...

3

From Windows 10 cmd.exe...
pharoconsole.exe --headless Pharo9.0-SNAPSHOT-64bit-099690e.image eval 1 + 2
works okay...

3

but...
pharoconsole.exe Pharo9.0-SNAPSHOT-64bit-099690e.image eval 1 + 2
produces error...

SmallInteger(Object)>>doesNotUnderstand: #'--'
image
with the GUI opening to show an erroneous "--interactive" has been appended to the command line.

VM info:

> pharoconsole.exe Pharo9.0-SNAPSHOT-64bit-099690e.image --version
Image: Pharo-9.0.0+build.839.sha.099690e06c28b1d6836db93c8e724a7044c69844 (64 Bit)๏ฟฝ[
VM:    CoInterpreterWithQueueFFI VMMaker-tonel.1 uuid: be795315-f06d-0d00-aab5-813a0e395221 Oct 13 2020
StackToRegisterMappingCogit VMMaker-tonel.1 uuid: be795315-f06d-0d00-aab5-813a0e395221 Oct 13 2020
e829a1da - Commit: e829a1da - Date: 2020-10-13 15:43:09 +0200

There seem three options:

  1. The "--interactive" flag needs to be inserted after the executable rather than appended to the arguments
  2. The in-image CommandLineHandler needs to be able to handle executable appended flags at end of commandline
  3. VM passes its determination of headless/interactive status to the Image viaVirtualMachine>>getSystemAttribute: so that it doesn't need to munge the commandline at all.

We need a coding standard

Open source projects tipically follow a set of coding standard guidelines the involves cosmetical and technical guidelines that must be followed. The current VM does not have a proper coding standard, so we need to decided on something to adopt that we and new contributors must follow. Since fixing the codebase to follow a proper coding standard may involve a lot of work, the coding standard resulting from this discussion must be adopted at least for all the new code that we write, and for all the new public C interfaces that we expose to the public. The existent

For starting this discussion, here I am proposing a coding standard document with some specific details that needs to be discussed. The result of this discussion should be hosted at least in the GitHub wiki of this project. Unfortunately, GitHub does not support pull request of wiki pages, so we have to conduct this discussion manually.



VM Coding Style Guidelines

We need to define a coding convention standard for the new VM code.
The results of this discussion should be located on the wiki or in a new version of the CONTRIBUTING.md document.

Conding style guidelines include cosmetic, functional and quality aspects.
From a quality standpoint what is really important on this aspect is to be as
consistent as possible on the codebase (i.e. use the same coding style
everywhere).

I suggest keeping the following original guidelines from the original
VM source code, but this is clearly not enough:


Original VM coding guidelines from CONTRIBUTING.md

C Source Code Formatting

When editing an existing file, please be polite and first follow the
guidelines below, and secondly follow the general rule of keeping to the
same formatting conventions as exist in the file.

C Function Declarations

C function declarations should have the type on the same line as the
function name and parameters, e.g.:

static int convertCopy(char *from, int fromLen, char *to, int toLen, int term)

C Function Definitions

C function definitions should have the type on one line and the
function name and parameters on the following line, e.g.:

static int
convertCopy(char *from, int fromLen, char *to, int toLen, int term)

This facilitates searching for function definitions by searching for the
name at the beginning of the line.

Tab stops are 4 spaces

In this case the first rule is to keep the existing formatting within a
file - we don't want to polute the code history with space changes.

The goal is to use tabs set to 4 spaces.


Additional coding guidelines

Checking existing coding guidelines

The following are some popular coding style that used in the industry
and open source/free software projects:

We should take and adapt some of the guidelines that are used by these
coding standards.

Indentation style

A coding standard is not the same as an indentation and formatting
standard. A coding standard may have some .

For a list of indentation styles check:
https://en.wikipedia.org/wiki/Indentation_style . For my own projects
I typically use the Allman "BSD style" from that list. Another popular
indentation style is to use a variant from the Kernighan and Ritchie style
from that list. The K&R styles are more similar to the indentation style
that is typically used in Java.

An indentation style must be selected explicitly for the whole VM
source code project (excluding third party libraries). The selection
of this indentation style must be specified with the command line
parameters that have to be passed to the indent Unix utility.
New code should be written by following that indentation style,
and existing code should be converted by running the indent
utility on them. The indentation style typically can be specified on
IDEs such as Eclipse, and text editors such as Emacs so that they
automatically help on writing code following the indentation.

Specific guidelines

Single line comments

Single line comments using // were not a part of the C standard until C99.
These comments are supported by the important compilers (gcc, clang, msvc).
The advantage of using these comment is that they facilitate using /**/ for
comment large blocks of code for debugging purposes. These same large blocks
of code can also be commented by #if 0 ... #endif. Since these
comments are supported by the important compilers, then there is no reason for
not using them.

Include guards and #pragma once

The #pragma once preprocessor directive is not part of the C standard.
However, mainstream C compilers such as gcc, clang and msvc do
support this pragma. The C standard does also mandates that
a #pragma that is not understood by a compiler must be ignore.
The intention of this pragma is to improve compilation
speed, but because of its non-standard nature it should be used in
conjunction with include guards, in the following way:

#ifndef HEADERFOLDER_NAME_H_
#define HEADERFOLDER_NAME_H_
#pragma once

/**
 Here goes the C header content.
*/
#endif //HEADERFOLDER_NAME_H_

Cast from void* to specific type

In C, casting implicitly from void* is an allowed operation, but this
is not allowed in C++. For example, the following is valid code in C,
but not in C++:

int *array = malloc(sizeof(int)*8);

The following version of the same code is valid in C and in C++:

int *array = (int*)malloc(sizeof(int)*8);

Since the second version is more explicit, I recommend that
we use that version just for the sake of being more explicit.

Order of includes in headers

According to the Google C++ coding standard, header files should be self contained and they should compile by it self. To facilitate this, the order of the includes should be the following:

  • Project specific headers should come first.
  • System provided headers should come after.

The intention of this ordering is to produce a compilation error
if a project specific header is missing the inclusion of a dependency.

Standard headers that are always present

The C language has the following two compilation modes:

  • Free standing mode (-ffreestanding): this mode is typically used for embedded system or for constructing an operating system kernel.
  • Hosted mode: the default mode with an operating system.

The following headers are mandated by the language standard to
be provided by the compiler on free standing mode, so it can be
assumed that they are always going to be present even if there is
no operating system:

  • <float.h> (C99)
  • <iso646.h> (C99)
  • <limits.h> (C99)
  • <stdalign.h> (C11)
  • <stdarg.h> (C99)
  • <stdbool.h> (C99)
  • <stddef.h> (C99)
  • <stdint.h> (C99)
  • <stdnoreturn.h> (C11)
  • <stdatomic.h> (C11)

From this list, the most important are <stddef.h>, <stdarg.h> and <stdint.h>.
stddef defines ptrdiff_t, size_t, wchar_t, NULL and offsetof. stdarg
defines macros for implementing functions with variable arguments such as
printf. stdint defines integer types with fixed size such as int32_t and
uint32_t. Since these headers are standard and they have to be always
provided by the compiler, then there is no reason to not use them.

Clang and GCC go for full C11 compatibility. MSVC implements only the
subsets of C99 and C11 that it also needs to implement a corresponding C++
standard (https://herbsutter.com/2012/05/03/reader-qa-what-about-vc-and-c99/).

Prefixes for namespacing

The lack of namespaces in C, and the usage of a single global symbol
table (specially on Linux. DLLs on Windows have their own symbol table.
OS X uses something similar to RTLD_DEEPBIND by default) has a huge potential
for producing name clashes. New code for the VM should use a prefix for
simulating namespaces in C which is a standard practice in C libraries.
This prefix could be realized by separating with an underscore:

int
pharovm_parseArgument(int argc, const char **argv)
{
    //...
    return 0;
}

Or by juxtaposition by using CamelCase:

int
pharoVMParseArgument(int argc, const char **argv)
{
    //...
    return 0;
}

I suggest using the version with underscores because it allows to have multiple namespaces, and we could use a different one for VM internals that should not be exposed to the public:

int
pharovm_internal_interpreter_pushOop(sqInt oop)
{
    //...
}

We should decide what is this prefix going to be. The following are
some suggestions:

  • pharo
  • pharovm
  • osvm (OpenSmalltalkVM)

Memory management hygiene

The explicit memory management in C is the source of several reliability
and security issues. For this reason we need some guidelines
when allocating memory, working with them, and disposing it.

alloca should not be used

alloca is a built-in primitive from the C compiler for allocating memory
on the stack. The implementation of alloca is done by decrementing the
stack pointer. On Linux only the memory for the stack of the main thread
can dynamically grow. The memory for threads different to the main
thread is allocated on thread creation time and it is fixed for
the whole lifetime of the thread. Since alloca can be used with large
sizes, there is no guarantee on having enough memory on the stack
for fullfilling the alloca, there is a strong potential for
provocating a stack underflow and an almost guaranteed segmentation fault
or memory corruption. For this reason the usage alloca is typically
forbidden by coding standards used in the industry.

In case where alloca is absolutely required, the size of the allocation
should be really small (no more than 100s of bytes). A local array with
the maximum size should always be preferred to alloca.

alloca should not be used for MAX_PATH for the same reason that a local
variable should not be used for MAX_PATH. The two idioms are equivalent.

malloced memory should be always fully inititialized

malloc returns uninitialized memory which can contain random garbage, but in
many cases it may look like zeroed memory. Some of this garbage may never be
initialized explicitly and could be interpreted in different random ways that
vary with the execution of the program. This usage of uninitialized memory may
be very hard to replicate and to debug. In some cases this uninitialized
memory may introduce subtle security bugs and leak sensitive information like
in the case of the infamous hearbleed bug in openssl. For this reason it is
recommended to do a memset after a malloc. For example:

#define BufferSize 4096
char *buffer = (char*)malloc(BufferSize);
memset(buffer, 0, BufferSize);

calloc should preferred over malloc

calloc always zeroes the allocated memory by doing an implicit memset. For this reason, calloc should be preferred to a raw malloc.

Initialization of structures

Structure should be always fully initialized. Most of the time it is
recommended to fully zero initialize structures by using the following idiom:

#include <stdlib.h> // For malloc and family
#include <string.h> // For memset

typedef struct some_struct_s
{
    char firstField;
    int secondField;
} some_struct_t;

// Global variables are always zero initialized.
some_struct_t globalVariable;

// In C, but not in C++, we can also initialize structures
// in the following way:
some_struct_t globalVariable2 = {
    .firstField = 'A',
    .secondField = 42
};

void someFunction()
{
    // ...

    // Local structure variable definition.
    some_struct_t localVariable = {};

    // DO NOT USE the following:
    //struct some_struct localVariable = {0};
    // Some compiler may only initialize the first field with this variant.


    // Use memset with malloc
    some_struct_t *pointer = (some_struct_t*)malloc(sizeof(some_struct_t));
    memset(pointer, 0, sizeof(some_struct_t));

    // Or use calloc
    some_struct_t *otherPointer = (some_struct_t*)calloc(1, sizeof(some_struct_t));

    // ...
}

String handling safeness

The usage of null terminated string literals in C is one of its greatest
design errors. This design has performance problems. Another problem with
string handling is that the string functions provided by the standard C
library are prone to produce buffer overflows (e.g: strcpy, strcat).

Common operations on strings require knowing the length of a
string for allocating memory to hold the result, which requires doing a
linear iteration per string just for asking for its size. The correct way of
fixing this is to prefix a string with its size (a la Pascal), but this
introduces a strong penalty on the code. Instead we are going to accept this
performance penalty, but we still need to use functions that operates on
strings and take care doing a correct allocation of the result buffer, and
provide safeness, security and reliability correctness when manipulating
string.

The basic operations that should be provided by this library are the
followings:

  • String duplication.
  • String concatenation.
  • String formatting (wrapper on snprintf, but properly allocating the result buffer).

String functions from the standard library that do not receive the size of the
target should not be used (e.g: strcpy, strcat, sprintf). Instead versions, of
these functions that receive the size of the target buffer must be used
(strncat, snprintf). In the case of strncpy, it must be avoided because it
is designed for fixed sized strings without a null terminator, and strncpy
may not insert the required null terminator at the end location.

Pointers to constants

Functions that receive string arguments that are not mutated must have
pointer to constant values type. These types can be written in the following two equivalent ways:

void functionReceivingStringLiteral(const char *string);
void functionReceivingStringLiteral(char const *string);

For reasons of consistency, only one of these two ways of writing this type
must be used. The first way of defining this type is the most commonly used
way, but the second way may be easier to understand, and some files are
currently using it.

In C++ unlike C, there is no implicit cast from string literals to char*,
so for example the following code is legal in C, but not in C++:

int executeImage(char *imageFileName);


int main()
{
    return executeImage("Pharo.image");
}

Using const as much as possible it is recommended because allows using the
compiler to detect some errors. In the case of functions that belong to public
interface that is exposed to plugins or applications that are embedding the
VM, these headers should be usable from C++ code.

Operating system naming convention

The following naming prefixes should be used when writing operating system
specific code:

  • For generic Unixes (Linux, FreeBSD, and to some extent OS X), they should be referred as Unix or abbreviated as unix. When using specific APIs from an Unix such as epoll in Linux vs kqueue in BSDs (including OS X), Unix specific variant naming and abbreviations should be used.
  • Generic BSDs should be abbreviated as just bsd.
  • OS X specific code should use osx. (Maybe we should use macos?)
  • For Windows, windows in full, or win32, or w32 should be used. In some communities, using win for Windows is advised against (GNU coding standard: https://www.gnu.org/prep/standards/html_node/System-Portability.html#System-Portability https://www.gnu.org/prep/standards/html_node/Trademarks.html#Trademarks ). Even on 64 bits mode the API is still called win32.
  • For the Windows App Store, the API is called UWP (Universal Windows Platform). This API is completely different from the Win32 API (except for a supported subset of Win), and it is only necessary to support it for some ARM devices, the Hololens and the Xbox One. On desktop the Win32 API is preferred.

C programming language standards

For reference, here are the draft versions of the current standards of the
C language:

These language standards should be used mostly as guidelines for
separating platforms independent features from platform specific features. GCC
and clang tend to follow the language standard closely, but MSVC tend to only
implement the standard partially. C99 features tend to be more widely
supported. From C11, the support for atomic operation seems to be the most
relevant feature for the VM.

The VM crashes on image selection dialog

When you open the headless VM in a directory that does not contain the Pharo.image file but an image with a different name, the VM tries to open the file dialog but crashes during that operation

Adding tests for snapshot

Who holds the contexts for garbage collect ? (processor suspended context and semaphores ?)
Snapshot embedded.

HeadlessVM has troubles with SSL downloading on Linux

Unlike the standard vm, the headless vm crashes when trying to download and install Tonel into the minimal image:

curl https://get.pharo.org/64/90+vmHeadlessLatest | bash
wget http://files.pharo.org/get-files/90/pharo64-minimal.zip
unzip pharo64-minimal.zip
./pharo  Pharo9.0-SNAPSHOT-metacello-64bit-3fe3649.image  eval --save "Metacello new baseline: 'Tonel';repository: 'github://pharo-vcs/tonel:v1.0.16'; load: 'core'"

It crashes on this stack state:

    0x7ffcbfcaf780 I ZdcPluginSSLSession>connect:from:to:into: 0x7f18e3faa230: a(n) ZdcPluginSSLSession
    0x7ffcbfcaf7f0 I ZdcSecureSocketStream>connect 0x7f18e3f9f140: a(n) ZdcSecureSocketStream
    0x7ffcbfcaf838 I ZnClient>setupTLSTo: 0x7f18e3f93af8: a(n) ZnClient
    0x7ffcbfcaf888 I ZnClient>newConnectionTo: 0x7f18e3f93af8: a(n) ZnClient

Pharo (VM) not able to run as a (headless) Windows service anymore

Moved from pharo-project/pharo#2352

The VM for Squeak (and initial Pharo) was able to run headless as a Windows Service.
This is not only useful but often necessary for deploying Pharo (web) services on Windows
platforms. Running as a service allows for easy maintenance (start, stop, backup services,
remote administration, ...).

Usually one would see the Services running on a machine in the Windows Service manager:

click on Windows Start and enter "services.msc"
(http://www.thewindowsclub.com/open-windows-services)
Unfortunately with current Pharo this deployment option. The "-service" option on the command
line of the Pharo VM as described in

http://wiki.squeak.org/squeak/105

seems lost. Maybe also the others like "-log", "-memory" and "-browserWindow"

Scenario to reproduce:
Download latest Pharo Windows VM version

1.1. Download http://files.pharo.org/get-files/70/pharo-win-latest.zip
1.2. Extract contents to c:\myservice

Download latest Pharo image version

2.1. Download http://files.pharo.org/get-files/70/pharo.zip
2.2. Extract contents to c:\myservice
at the time of this writing this was

  • Pharo7.0-32bit-52a28a8.image
  • Pharo7.0-32bit-52a28a8.sources
  • Pharo7.0-32bit-52a28a8.changes

Start Pharo image the first time

3.1. Drag the "Pharo7.0-32bit-52a28a8.image" to the VM executable "Pharo.exe" to start Pharo
3.2. Open a Playground and enter

(ZnServer startDefaultOn: 9091)
onRequestRespond: [:request | ZnResponse ok: (ZnEntity text: Time now asString )]

3.3. Point your browser to http://localhost:9091/ to verify that the server is running.
Hit refresh in the brower to see the time change.

3.4. Click on "Save and Quit" in the world menu to save and close the image

Start Pharo image a second time

4.1. Drag the "Pharo7.0-32bit-52a28a8.image" to the VM executable "Pharo.exe" to start Pharo
4.2. Point your browser to http://localhost:9091/ to verify that the server is running.
Hit refresh in the brower to see the time change.
4.3. Close the image using "Quit" from the world menu
This step is just to verify that the image starts/runs the webserver when it is started.

Try to install as a Windows service

5.1. On Windows click "Start" and enter cmd.exe to open the Windows DOS Console
5.2. Change the directory using "cd c:\myservice"
5.3. Run

Pharo.exe -service "PharoService" c:\myservice\Pharo7.0-32bit-52a28a8.image
on the command line. This brings you into an: "Command line handler failed 1"
error.

I guess this is due to the restructuring of Pharo command line handling that this
parameter is not passed to the VM.

But also the command line with -headless

Pharo.exe -headless -service "PharoService" c:\myservice\Pharo7.0-32bit-52a28a8.image

does not work and install Pharo in the Windows Service manager (services.msc).
Just to confirm that it was once working in Squeak:

One can download and take the old Squeak Swiki Server and run it with the "-service" option
easily: http://wiki.squeak.org/swiki/uploads/10/Winterlong.zip without any problem as Windows service.

Improve the VM capabilities detection from the image

We need to have a better way of talking with the VM to query about its capabilities and how it is running.

Ex: Do we have console? Are we running headless? Is the VM embedded? What is the path of the image? What are the parameters?

This requires:

  • A nice API in the image side.
  • A reification of some of the attributes
  • A nice API in the VM side
  • An extensible solution in both the VM and the image
  • Have it as a plugin that is outside the main vm DLL

Today there is a VM object in the image but its interface is not intuitive nor extensible.

Discuss CMakeSetting.json version control

CMakeSetting.json is touched anytime each developer changes a flag from the Visual Studio GUI.
We don't really want this polluting the version history.
Possibly CMakeSetting.json should be git-ignored, and we version control a CMakeSetting.json.template file.

There may be another option CMakePresets.json & CMakeUserPresets.json being developed...

btw, here is a good starting point for VS ignore... https://www.toptal.com/developers/gitignore/api/visualstudio

MiscPrimitivePlugin doesn't generate on pharo

Works on squeak, probably a problem in the compatibility layer.

The failing method is #encodeInt:in:at: and doesn't declare a return type.
The returnType variable of TMethod seem to not be set (as we can see in the method calling the failing one : #propagateReturmIm: )

Pierre

"stable" Windows Pharo 8 VM crashes when Iceberg is used

VM downloadable from http://files.pharo.org/get-files/80/pharo64-win-stable.zip causes crash of VM whenever git is used.
Steps to reproduce:

  1. Download this VM and fresh Pharo 8 64bit image
  2. Download anything from git, for example:
Metacello new
  repository: 'github://svenvc/NeoJSON/repository';
  baseline: 'NeoJSON';
  load.

Result: VM crashes without showing any popup or saving any debug info.
The window just closes when used normally, I get absolutely no output when using PharoConsole.exe in Windows cmd or Segmentation fault in git bash.

That VM is the one Pharo Launcher downloads for Pharo 8 64bit image.
It happens on both my Windows 10 PCs and all Windows 10 PCs at our university.
Following VM (Pharo 9 one) works fine: http://files.pharo.org/vm/pharo-spur64/win/stable-20200212.zip
The Pharo 8 one is over 1 year old.

EDIT: Problem is in libssh2-1.dll. If I take the Pharo 8 VM and replace libssh2-1.dll by the one from Pharo 9 VM, everything works

We don't create TSwitchStmtNode for caseOf:

I'm not sure wether that is indeed a problem though, since it seems to generate the VM correctly.

If I understand correctly, a caseOf: messageNode should be parsed as a TSwitchStmtNode.

VM version strings are an absolute disaster for end users

VM version strings are an absolute disaster for end users, it is simply impossible to talk about a specific version.

$ ./pharo-ui --version
5.0 5.0.201901051900 Mac OS X built on Jan  5 2019 19:11:02 UTC Compiler: 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31) [Production Spur 64-bit VM]
CoInterpreter VMMaker.oscog-eem.2504 uuid: a00b0fad-c04c-47a6-8a11-5dbff110ac11 Jan  5 2019
StackToRegisterMappingCogit VMMaker.oscog-eem.2504 uuid: a00b0fad-c04c-47a6-8a11-5dbff110ac11 Jan  5 2019
VM: 201901051900 https://github.com/OpenSmalltalk/opensmalltalk-vm.git
Date: Sat Jan 5 20:00:11 2019 CommitHash: 7a3c6b6
Plugins: 201901051900 https://github.com/OpenSmalltalk/opensmalltalk-vm.git

Halos Broken - P9 Headless

Morphic halos don't seem to be working with the Pharo 9 headless VM. They
seem fine with headful.

Still a bug as of Pharo-9.0.0+build.572.sha.308d3ba56ee06f02c3d3f916da5636d04ceca15b (64 Bit)
Mac OS 10.14.6

We need an Unit Testing framework for C code

We need to choose and select a framework for writing unit test for the pure C code of the core VM library, support libraries, and plugins. Since this code is independent of the Slang generated we cannot rely on the Smalltalk specific testing tools for this.

Do not use zip files for thirdparty dependencies on Linux and Mac

In the headless branch, zip files should not be used for handling thirdparty dependencies such as shared libraries in Linux and Mac because they do not respect symlinks. Not respecting symlinks may introduce several bugs related with name clashes and undefined behavior.

Tarballs such .tar.gz or .tar.bz2 should be used instead.

This same problem applies to distributing VM build artifacts.

Cmake cross platform VM download for code generation

A VM is required to runimage to generate C sources from Slang code.
Currently this has done for LInux is shell calls to wget, but this doesn't work for windows without installing additional software like Cygwin.
Instead of wget, Cmake's own cross platform file operations should be used, i.e "file()".

Would be good to centralize the dependent packages

"Dependencies from other repositories"
spec
package: 'SharedPool-Speech' with: [
spec repository: 'http://www.squeaksource.com/Speech' ];
package: 'MethodMassage' with: [
spec repository: 'http://ss3.gemstone.com/ss/MethodMassage' ];
package: 'MethodMassageCompatibility' with: [
spec repository: 'http://ss3.gemstone.com/ss/MethodMassage' ];
package: 'Printf' with: [
spec repository: 'http://www.squeaksource.com/Printf' ].

Adding test for context return

Returning from a context not in the stack
Returning to a context not in the same page
Returning to a context already dead
What happen when you change the sender of a context (divorce ?)

Check that the compilation flags that are passed in Windows make sense

On Windows the following compilations flags are passed in CMake:

set(COMMON_FLAGS "-fwrapv -fdeclspec -msse2 -ggdb2 -m64 -mno-rtd -mms-bitfields -O2 -momit-leaf-frame-pointer -funroll-loops -D_MT -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf -Wall -Wno-unused-variable -fno-optimize-sibling-calls")

What does -fdeclspec do?
The -msse2 is a flag for using vectorial instructions instead of the old x87 fpu instruction, which make sense on 32 bits x86, not in 64 bits. In 64 bits x86 these instructions are always available and the old fpu is completely deprecated so this flag seems to be useless in this.

Support for OpenSUSE and Fedora

On OpenSUSE and Fedora, whenever any image (including Pharo Launcher) is opened or FFI call to libgit2 is done, system cannot find required libcurl library and FFI call ends with error:
ioLoadModule(/home/honza/Downloads/pharolauncher/pharo-vm/lib/pharo/5.0-201901051900/libgit2.so): libcurl-gnutls.so.4: cannot open shared object file: No such file or directory tryLoading(/home/honza/Downloads/pharolauncher/pharo-vm/lib/pharo/5.0-201901051900/libgit2.so/.libs/,libgit2.so): stat(/home/honza/Downloads/pharolauncher/pharo-vm/lib/pharo/5.0-201901051900/libgit2.so/.libs/) Not a directory External module not found ExternalLibraryFunction(Object)>>error: ExternalLibraryFunction(Object)>>externalCallFailed ExternalLibraryFunction(ExternalFunction)>>invokeWithArguments: LGitLibrary>>libgit2_init FFICalloutAPI>>function:module: LGitLibrary(Object)>>ffiCall: LGitLibrary>>libgit2_init [ self libgit2_init. self recordInitializationSuccess ] in LGitLibrary>>initializeLibGit2 in Block: [ self libgit2_init.... BlockClosure>>on:do: LGitLibrary>>initializeLibGit2
...(etc)...

It has quite simple (yet not fully working) workaround: ln -s /usr/lib64/libcurl.so.4 (path to pharo vm)/lib/pharo/(version)/libcurl-gnutls.so.4 (which any user can do, but has to be done for each VM) - path to your libcurl.so.4 may differ
or: ln -s /usr/lib64/libcurl.so.4 /usr/lib64/libcurl-gnutls.so.4 (which can be done only by root/sudoer, but only once)..
However, this workaround is not enough for 2 reasons:

  1. It causes segfault for some usage of SSL library. For example:
    (ZdcSecureSocketStream openConnectionToHostNamed: 'www.google.com' port: 443) connect crashes the vm then.
    This is especially problematic because Pharo Launcher does something similar, so it crashes immediately after start.
  2. It either has to be done for every downloaded VM (manually or by Launcher itself) OR it has to be done by root

Because of that, I am having problems promoting Pharo to our students, because university PCs use OpenSUSE Leap 15 and students are not sudoers and they would like to use Pharo Launcher.

Would it be, please, possible to officialy support these distros so it would work as well as it does for Ubuntu/Debian based distros?

"Too many open files" error or image lockup when deleting directories on Pharo80-x64

The following snippet triggers an error when executed in a workspace on a freshly loaded Pharo80 x64 images on Mac OS. I suspect 'primitiveOpendir' to open directories but not close them when returning 'nil' (see further). The error only happens on 64 bit and not on 32 bit.

| workingdir maxNumberOfOpenFiles |
workingdir := FileSystem workingDirectory.
"Number below should be higher than the max open files limit on your system. On Mac, it is 256."
maxNumberOfOpenFiles := 300.
1 to: maxNumberOfOpenFiles do: [ :i | (workingdir / ('test-' , i asString)) ensureCreateDirectory ].
1 to: maxNumberOfOpenFiles do: [ :i | 
	(workingdir / ('test-' , i asString)) delete ].

I got this error when committing to a large filetree-based package in Iceberg. Once the error is triggered once, the image becomes useless since you always get a 'Too many open files' error. At some point, the image even freezes up trying to trigger the error and you need to recreate the entire image to trigger the error again.

Diving a little further, I suspect the error is in the 'primitiveOpendir' primitive that seems to open directories but not close them when returning 'nil'. You can check this by removing the call to that primitive by changing the implementation of FileReference>>delete to the one below (commenting out the call to hasChildren) :

delete
	"Deletes the referenced file or directory. If the directory is not empty, 
	raises an error. Use #deleteAll to delete with the children."

	(self isDirectory and:[false"self hasChildren"]) 
		ifTrue:[DirectoryIsNotEmpty signalWith: self].
	filesystem delete: path

Alternatively, trigger the error directly and mind the halt will never occur because the primitive returns 'nil'.

| workingdir maxNumberOfOpenFiles |
workingdir := FileSystem workingDirectory.
"Number below should be higher than the max open files limit on your system. On Mac, it is 256."
maxNumberOfOpenFiles := 300.
1 to: maxNumberOfOpenFiles do: [ :i | (workingdir / ('test-' , i asString)) ensureCreateDirectory ].
1 to: maxNumberOfOpenFiles do: [ :i | 
	(File primOpendir: (File encodePathString: ((workingdir / ('test-' , i asString)) fullName))) ifNotNil:[:x | x halt ] ].

Because the primitive returns nil, but seems to open the file descriptor, the file is never closed in the call to hasChildren which eventually calls the method DiskStore>>directoryAt:nodesDo:, which only closes the file descriptor if the result of the primitive was not nil.

System details:

  • Mac OS Mojave 10.14.6
  • Pharo 8.0.0
  • Build information: Pharo-8.0.0+build.1124.sha.0932da82f08175e906b0e2a8052120c823374e9f (64 Bit)
  • VM version
CoInterpreter VMMaker.oscog-eem.2504 uuid: a00b0fad-c04c-47a6-8a11-5dbff110ac11 Jan  5 2019
StackToRegisterMappingCogit VMMaker.oscog-eem.2504 uuid: a00b0fad-c04c-47a6-8a11-5dbff110ac11 Jan  5 2019
VM: 201901051900 https://github.com/OpenSmalltalk/opensmalltalk-vm.git Date: Sat Jan 5 20:00:11 2019 CommitHash: 7a3c6b6 Plugins: 201901051900 https://github.com/OpenSmalltalk/opensmalltalk-vm.git

Adding tests for lookup

Does not found the method does the lookup of DNU
MethodDictionary isNil lookup of cannot interpret
Lookup in superclass
Super send
Cache Invalidation

Process for building and updating third-party dependencies

I am trying to build the VM on a non-ubuntu machine it is failing. It seems there is no process in place to

  1. Re-build the system libraries we use in a clean and predictable way.
  2. Update them in a timely manner as security issues are found

The first matters as there are new Linux distributions and new architectures (e.g. ARMv8 is now mainstream and a good target for AWS EC2, also RISC-V is up and coming...). The latter matters as many users run Webservers and OpenSSL is a target of frequent issues.

Slightly related to this is the bootstrap problem. I am trying to build the VM on OpenSUSE tumbleweed and GENERATE_SOURCES=0 is broken and I don't see a way to build the libraries.

As long as we don't directly run on a hypervisor we should be good citizens with the compute platform we run on. I think it requires a process that is setup to make it work.

I ran into this while trying to debug IPv4 multicast on the VM and switched from Macos to Linux. Now my problems increased and I can't do what I initially intended to do.

pharo x64 libssh2 crashes on Windows 1903

Already reported here OpenSmalltalk/opensmalltalk-vm#416

but maybe it is faster to address it for Pharo-only and then push back to opensmalltalk-vm


original report (with links updated for pharo-project/opensmalltalk-vm)

Since Windows 1903 update (which is now being rolled out), Pharo VM crashes on libssh2-1.dll.

Tested on P7 and P8 64bit with their respective VMs.
32bit seems to work.

Easiest way to reproduce is to try to fetch git repository over ssh, e.g.

Metacello new
	baseline: 'FileDialog';
	repository: 'github://pharo-contributions/file-dialog/repository';
	load.

This issue makes it impossible to use git over ssh. (Switching to https does work as a temporary workaround.)

Windows crash log event:

Faulting application name: Pharo.exe, version: 5.0.0.0, time stamp: 0x00000000
Faulting module name: libssh2-1.dll, version: 0.0.0.0, time stamp: 0xaec0ae70
Exception code: 0xc0000005
Fault offset: 0x000000000001e6cb
Faulting process id: 0x2c8
Faulting application start time: 0x01d5577ece35e5f5
Faulting application path: C:\Users\uhnak\Documents\Pharo\vms\80-x64\Pharo.exe
Faulting module path: C:\Users\uhnak\Documents\Pharo\vms\80-x64\libssh2-1.dll
Report Id: 60cbf9ad-b7a2-4f48-9831-e2cbc80e7734
Faulting package full name: 
Faulting package-relative application ID: 

Is there a particular reason why we still use libssh2 1.7.0 (released 3 years ago), instead of a more recent one? https://github.com/pharo-project/opensmalltalk-vm/blob/Cog/third-party/libssh2.spec

Dtto for libgit2 (0.25.1 released Jan 2017)
https://github.com/pharo-project/opensmalltalk-vm/blob/Cog/third-party/libgit2.spec

Likely OpenSSL will also need to be updated as it is dependency of libssh2 https://github.com/pharo-project/opensmalltalk-vm/blob/Cog/third-party/openssl.spec
Note that the current 1.0.2 LTS ends at the end of the year and is replaced by 1.1.1 LTS (until 2023 - https://www.openssl.org/policies/releasestrat.html )

I have also noticed that the Windows libssh Makefile doesn't contain code to download/unpack sources, unlike Linux and Mac


https://github.com/pharo-project/opensmalltalk-vm/blob/Cog/build.linux64x64/third-party/Makefile.libssh2
https://github.com/pharo-project/opensmalltalk-vm/blob/Cog/build.macos64x64/third-party/Makefile.libssh2

Starting the headless vm on Windows running in Parallels by double-clicking on Pharo.exe leads to a crash

When opening the headless vm for windows (http://files.pharo.org/get-files/80/pharo64-win-headless-stable.zip) in a Parallels installation having Windows 10 Pro latest update, after double clicking on the Pharo.exe when the window for selecting an image opens, the vm crashes directly. The normal pharo vm works ok. Also the headless vm work ok when stating it from the command line using PharoConsole.exe.

I get this in the crash.dmp:

EXCEPTION_ACCESS_VIOLATION(-1073741819) at 0x000000006fb75837 - 2019-08-16 18:07:43.080

C:\gt\pharo64-win-headless-latest\Pharo.exe
Pharo VM version: 5.0-Pharo 8.1.0 built on Aug 14 2019 11:45:29 Compiler: 4.2.1 Compatible Clang 5.0.1 (tags/RELEASE_501/final) 4.2.1 Compatible Clang 5.0.1 (tags/RELEASE_501/final) [Production Spur 64-bit VM]
Built from: CoInterpreterWithQueueFFI VMMaker-CompatibleUserName.1565775651 uuid: ca6d0992-92c5-5054-99a4-9efc2f749249 Aug 14 2019
 With:StackToRegisterMappingCogit * VMMaker-CompatibleUserName.1565775651 uuid: ca6d0992-92c5-5054-99a4-9efc2f749249 Aug 14 2019
 Revision: 0aa4db58 - Commit: 0aa4db58 - Date: 2019-08-14 11:40:51 +0200

C stack backtrace & registers:
Registers:
ContextFlags: 0x000000000010000f
    rax 0x000000000000001f rbx 0x0000000005f49570 rcx 0x0000000005f48e30 rdx 0x00007ffccaebfa00
    rdi 0x000000006fbbc330 rsi 0x000000006fbbc330 rbp 0x0000000000771b10 rsp 0x0000000005f48d90
    r8  0x0000000005f48a0a r9  0x000000006fbb407a r10 0xffffffffffffffff r11 0x0000000000000000
    r12 0x0000000000000000 r13 0x00000000002a6000 r14 0x0000000005f48e30 r15 0x0000000000771b00
    rip 0x000000006fba1559 

C Callstack:

[0x000000006FB75837] primitiveEventProcessingControl
[0x000000006FBA1AF4] printMachineCallStack
[0x000000006FBA161F] installErrorHandlers
[0x000000006FBA1433] printCrashDebugInformation
[0x000000006FBA1379] customExceptionHandler
[0x00007FFCCBB36B26] RtlInitializeCriticalSectionAndSpinCount
[0x00007FFCCBAD4849] RtlWalkFrameChain
[0x00007FFCCBB734EE] KiUserExceptionDispatcher
[0x000000006FB75837] primitiveEventProcessingControl
[0x000000006FBA1AF4] printMachineCallStack
[0x000000006FBA161F] installErrorHandlers
[0x000000006FBA1433] printCrashDebugInformation
[0x000000006FBA1379] customExceptionHandler
[0x00007FFCCBB36B26] RtlInitializeCriticalSectionAndSpinCount
[0x00007FFCCBAD4849] RtlWalkFrameChain
[0x00007FFCCBB734EE] KiUserExceptionDispatcher
[0x000000006FB75837] primitiveEventProcessingControl
[0x000000006FBA1AF4] printMachineCallStack
[0x000000006FBA161F] installErrorHandlers
[0x000000006FBA1433] printCrashDebugInformation

listBuiltInModules might crash the VM when there's too much plugin

We're going one step too far in the memory
As long as there's not enough plugins to fill the array, this should be fine, but it can be a cause of segfault in the future

VirtualMachine >> listBuiltinModules/listLoadedModule
| modules index tname |
modules := Array new writeStream.
index := 1.
[ true ]
whileTrue: [
tname := self listBuiltinModule: index.
tname ifNil: [ ^ modules contents ].
modules nextPut: tname.
index := index + 1 ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.