v icon indicating copy to clipboard operation
v copied to clipboard

doc: comparison example Fetch HN Stories fails on OpenBSD

Open j-bm opened this issue 2 years ago • 3 comments

Here is doctor output:

OS: openbsd, 7.2, GENERIC.MP#687
Processor: 2 cpus, 64bit, little endian
CC version: OpenBSD clang version 13.0.0

vexe mtime: 2022-08-19 15:38:58
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.0 ea16319.f10ff03

Git version: git version 2.37.2
Git vroot status: weekly.2022.33-26-gf10ff035 (61 commit(s) behind V master)

Note that OpenBSD uses LibreSSL not OpenSSL.

The Clear Linux version is Clear Linux OS Installed version: 36900.

What did you do? Built the sample V code on https://vlang.io/compare for V, adjusted for "text" -> "body".

Ran on OpenBSD 7.1-current, and Clear Linux current. It works consistently on Clear but crashes consistently on OpenBSD:

V panic: http: openssl: BIO_do_connect failed, res: -1 (potential network issue?)
v hash: f10ff03

I get one, two, three or more BIO_do_connect fails.

What did you expect to see?

500 titles of top Hacker News articles. It works on Clear Linux.

What did you see instead?

One to a few titles, then one to a few BIO_do_connect fails as shown above.

j-bm avatar Aug 26 '22 12:08 j-bm

Try examples/news_fetcher.v and see if that works better for you. It may be that the code on vlang.io/compare needs to be updated... they don't currently match.

JalonSolov avatar Aug 26 '22 13:08 JalonSolov

The news_fetcher and fetch programs work, as does the cited code when adjusted for single-threading.

j-bm avatar Aug 26 '22 20:08 j-bm

I tried compiling with -gc none and it magically works, three times in a row.

All the other gc options fail (default, -gc boehm_full, boehm_full_opt, boehm_incr, boehm_incr_opt, boehm_leak).

The boehm_incr_opt seems to be fastest to provoke a fail.

Tried OpenBSD malloc control options which quickly detect any use-after-free or bad pointers:

export MALLOC_OPTIONS="CFGUR<"

does not show any malloc / dealloc issues. (See https://man.openbsd.org/malloc.3 for decoding the flags)

Using GC_PRINT_STATS=1 provides a number of lines of output; the crash is consistent after the fifth (5) garbage collection using boehm_incr_opt:

--> Marking for collection #5 after 149616 allocated bytes
Marked from 26 dirty pages
GC #5 freed 28656 bytes, heap 468 KiB (+ 0 KiB unmapped)
World-stopped marking took 0 msecs (2 in average)
In-use heap: 56% (127 KiB pointers + 138 KiB other)
0 finalization entries; 0/0 short/long disappearing links alive
0 finalization-ready objects; 0/0 short/long links cleared
Finalize plus initiate sweep took 0 + 0 msecs
An Intuition for Lisp Syntax
V panic: http: openssl: BIO_do_connect failed, res: -1 (potential network issue?)
v hash: f10ff03

Using just gc=boehm the crashes are consistent after gc number 3.

I still can't decide if this problem is gc, libatomic, libressl or V runtime...

j-bm avatar Aug 28 '22 19:08 j-bm

Currently, November 2023, this now works on OpenBSD:

OpenBSD 7.4-current (GENERIC.MP) #1441: Fri Nov  3 17:45:32 MDT 2023
$ v -v
V 0.4.3 e9258c2

I tested with default gc, gc=boehm, and gc=boehm_incr_opt.

Aside from V and OpenBSD changes, the Boehm gc was upgraded to 8.2.4 from 8.0.4.

j-bm avatar Nov 16 '23 20:11 j-bm