Ark icon indicating copy to clipboard operation
Ark copied to clipboard

Segmentation fault (core dumped) on import

Open marwal-88 opened this issue 2 years ago • 6 comments

What happened?

I'm using Manjaro and installed arkscript 3.1.3-1 from repo. It works.. unless I try import.

(import "http.arkm")

This single line is enough to send it into seg-fault. I run it like this: arkscript webtest.ark

So I uninstalled and cloned the latest version. No problems.. but it installed in /usr/local/bin and /usr/local/lib (I used sudo for the final compile (following the instructions))

Now the program has no clue where the libraries are. So I moved everything to /usr/bin and usr/lib. Now it works the same as before. Not a problem unless I try import.

arkscript --version Version 4.0.0

What ArkScript version are you seeing the problem on?

v4.0.0

Relevant code & log output

No response

Documentation

  • [X] I have read existing related documentation before submitting this report
  • [X] I have searched for an existing issue before posting

marwal-88 avatar Aug 21 '23 18:08 marwal-88

Hello

Can you post the full error log when importing a module? Also, did you:

  • recompile the http module for arkscript 4.0? The ABI has been broken
  • test with a .ark file?
  • try running the tests (tests/arkscript/)

SuperFola avatar Aug 22 '23 14:08 SuperFola

I got it working by reverting back to the version in arch repo (AUR 3.1.3-1) and setting ARKSCRIPT_PATH to /usr/lib (because it seems it has to be set to the lib.. not to the 'folder containing the lib-folder')

I can now import without segfault. So this script fetches a page (header):

`(import "http.arkm")

(let cli (http:client:create "skapan.de" 80)) (mut output (http:client:get cli "/"))

(if (nil? output) (print "error") (print output) )`

(ends with segfault.. but that might be me not understanding how to code :) ) (btw: that page returns a 301 .. if that has something to do with it.)

marwal-88 avatar Aug 22 '23 15:08 marwal-88

Thanks for the feedback ; could you try to compile arkscript and the http module, then run your code in gdb so that we can get a stacktrace (just in case: gdb --args ./build/arkscript test.ark, then r, and bt when it fails)?

To compile arkscript and only the http module:

cmake -Bbuild -DARK_BUILD_EXE=On -DARK_BUILD_MODULES=ON -DARK_MOD_HTTP=On
cmake --build build --config Debug --j 10

What kind of compiler are you using? What architecture (I suppose it's amd 64bits) are you on?

I couldn't reproduce the segfault with the version from dev (4.0.0), using clang 14.0.0, arm64 here. Also your code is correct, don't worry about that!

SuperFola avatar Aug 22 '23 19:08 SuperFola

gcc --version gcc (GCC) 13.2.1 20230801 cmake: cmake version 3.27.1 openSSL installed: 3.1.2-1 uname -m : x86_64

inxi: CPU: quad core Intel Core i3-9100F (-MCP-) speed/min/max: 3600/800/4200 MHz Kernel: 6.4.9-1-MANJARO x86_64 Up: 51m Mem: 1.99/15.54 GiB (12.8%) Storage: 2.04 TiB (2.0% used) Procs: 267 Shell: Bash inxi: 3.3.29

steps:

  • removing old (AUR). (using Pamac).

  • using instructions from: https://arkscript-lang.dev/tutorials/building.html#from-a-release

    • (OK) git clone https://github.com/ArkScript-lang/Ark.git
    • (NO ERROR) cd Ark; git submodule update --init --recursive

executing: cmake -Bbuild -DARK_BUILD_EXE=On -DARK_BUILD_MODULES=ON -DARK_MOD_HTTP=On

=> CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found version "3.1.2") Call Stack (most recent call first): /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake/Modules/FindOpenSSL.cmake:668 (find_package_handle_standard_args) lib/modules/http/CMakeLists.txt:17 (find_package)

marwal-88 avatar Aug 22 '23 19:08 marwal-88

The easiest fix would be to export OPENSSL_ROOT_DIR=open ssl dir here (mine was /usr/local/opt/openssl/ for reference)

SuperFola avatar Aug 22 '23 19:08 SuperFola

Since than not a legit command.. I'll skip here. Thx.

marwal-88 avatar Aug 22 '23 19:08 marwal-88