manuel-serrano / bigloo

a practical Scheme compiler
http://www-sop.inria.fr/indes/fp/Bigloo
Other
133 stars 20 forks source link

pregexp test will fail when pcre2 library is configured with JIT feature off #90

Closed Avimitin closed 7 months ago

Avimitin commented 1 year ago

I am trying to build bigloo on Arch Linux RISC-V. The build process is successfully finished, but when I ran make test, the pregexp test fail. I am not familiar with bigloo tests so I came here to ask for help.

Full failure output ```text pregexp.scm: 3.pregexp((pregexp-match-positions needle hay needle stack)) fail: provided [#f], wanted [((4 . 10))] 4.pregexp((pregexp-match-positions needle his hay needle stack -- my hay needle stack -- her hay needle stack 24 43)) fail: provided [#f], wanted [((31 . 37))] 6.pregexp((pregexp-match needle hay needle stack)) fail: provided [#f], wanted [("needle")] 7.pregexp((pregexp-replace te liberte ty)) fail: provided ["liberte"], wanted ["liberty"] 8.pregexp((pregexp-replace* te liberte egalite fraternite ty)) fail: provided ["liberte egalite fraternite"], wanted ["liberty egality fratyrnity"] 10.pregexp((pregexp-match-positions laugh$ laugh laugh laugh laugh)) fail: provided [#f], wanted [((18 . 23))] 11.pregexp((pregexp-match-positions yack\b yackety yack)) fail: provided [#f], wanted [((8 . 12))] 12.pregexp((pregexp-match-positions an\B an analysis)) fail: provided [#f], wanted [((3 . 5))] 13.pregexp((pregexp-match p.t pet)) fail: provided [#f], wanted [("pet")] 14.pregexp((pregexp-match \d\d 0 dear, 1 have to read catch 22 before 9)) fail: provided [#f], wanted [("22")] 15.pregexp((pregexp-match [[:alpha:]_] --x--)) fail: provided [#f], wanted [("x")] 16.pregexp((pregexp-match [[:alpha:]_] --_--)) fail: provided [#f], wanted [("_")] 18.pregexp((pregexp-match [[:alpha:]] --a--)) fail: provided [#f], wanted [("a")] 20.pregexp((pregexp-match-positions c[ad]*r cadaddadddr)) fail: provided [#f], wanted [((0 . 11))] 21.pregexp((pregexp-match-positions c[ad]*r cr)) fail: provided [#f], wanted [((0 . 2))] 22.pregexp((pregexp-match-positions c[ad]+r cadaddadddr)) fail: provided [#f], wanted [((0 . 11))] 25.pregexp((pregexp-match-positions c[ad]?r cr)) fail: provided [#f], wanted [((0 . 2))] 26.pregexp((pregexp-match-positions c[ad]?r car)) fail: provided [#f], wanted [((0 . 3))] 27.pregexp((pregexp-match [aeiou]{3} vacuous)) fail: provided [#f], wanted [("uou")] 30.pregexp((pregexp-match [aeiou]{2,3} zeugma)) fail: provided [#f], wanted [("eu")] 31.pregexp((pregexp-match <.*> )) fail: provided [#f], wanted [(" ")] 32.pregexp((pregexp-match <.*?> )) fail: provided [#f], wanted [("")] 33.pregexp((pregexp-match ([a-z]+) ([0-9]+), ([0-9]+) jan 1, 1970)) fail: provided [#f], wanted [("jan 1, 1970" "jan" "1" "1970")] 34.pregexp((pregexp-match (pregexp ([a-z]+) ([0-9]+), ([0-9]+)) jan 1, 1970)) fail: provided [#f], wanted [("jan 1, 1970" "jan" "1" "1970")] 35.pregexp((pregexp-match (poo )* poo poo platter)) fail: provided [#f], wanted [("poo poo " "poo ")] 36.pregexp((pregexp-match ([a-z ]+;)* lather; rinse; repeat;)) fail: provided [#f], wanted [("lather; rinse; repeat;" " repeat;")] 37.pregexp((pregexp-match date-re jan 1, 1970)) fail: provided [#f], wanted [("jan 1, 1970" "jan" "1," "1970")] 38.pregexp((pregexp-match date-re jan 1970)) fail: provided [#f], wanted [("jan 1970" "jan" #f "1970")] 39.pregexp((pregexp-replace _(.+?)_ the _nina_, the _pinta_, and the _santa maria_ *\1*)) fail: provided ["the _nina_, the _pinta_, and the _santa maria_"], wanted ["the *nina*, the _pinta_, and the _santa maria_"] 40.pregexp((pregexp-replace* _(.+?)_ the _nina_, the _pinta_, and the _santa maria_ *\1*)) fail: provided ["the _nina_, the _pinta_, and the _santa maria_"], wanted ["the *nina*, the *pinta*, and the *santa maria*"] 41.pregexp((pregexp-replace (\S+) (\S+) (\S+) eat to live \3 \2 \1)) fail: provided ["eat to live"], wanted ["live to eat"] 44.pregexp((pregexp-match ([a-z]+) and \1 billions and billions)) fail: provided [#f], wanted [("billions and billions" "billions")] 46.pregexp((pregexp-replace* (\S+) \1 now is the the time for all good men to to come to the aid of of the party \1)) fail: provided ["now is the the time for all good men to to come to the aid of of the party"], wanted ["now is the time for all good men to come to the aid of the party"] 47.pregexp((pregexp-replace* (\d+)\1 123340983242432420980980234 {\1,\1})) fail: provided ["123340983242432420980980234"], wanted ["12{3,3}40983{24,24}3242{098,098}0234"] 48.pregexp((pregexp-match ^(?:[a-z]*/)*([a-z]+)$ /usr/local/bin/mzscheme)) fail: provided [#f], wanted [("/usr/local/bin/mzscheme" "mzscheme")] 49.pregexp((pregexp-match (?i:hearth) HeartH)) fail: provided [#f], wanted [("HeartH")] 50.pregexp((pregexp-match (?x: a lot) alot)) fail: provided [#f], wanted [("alot")] 51.pregexp((pregexp-match (?x: a \ lot) a lot)) fail: provided [#f], wanted [("a lot")] 52.pregexp((pregexp-match (?x: a \ man \; \ # ignore a \ plan \; \ # me a \ canal # completely ) a man; a plan; a canal)) fail: provided [#f], wanted [("a man; a plan; a canal")] 53.pregexp((pregexp-match (?ix: a \ man \; \ # ignore a \ plan \; \ # me a \ canal # completely ) A Man; a Plan; a Canal)) fail: provided [#f], wanted [("A Man; a Plan; a Canal")] 54.pregexp((pregexp-match (?i:the (?-i:TeX)book) The TeXbook)) fail: provided [#f], wanted [("The TeXbook")] 55.pregexp((pregexp-match f(ee|i|o|um) a small, final fee)) fail: provided [#f], wanted [("fi" "i")] 56.pregexp((pregexp-replace* ([yi])s(e[sdr]?|ing|ation) it is energising to analyse an organisation pulsing with noisy organisms \1z\2)) fail: provided ["it is energising to analyse an organisation pulsing with noisy organisms"], wanted ["it is energizing to analyze an organization pulsing with noisy organisms"] 57.pregexp((pregexp-match f(?:ee|i|o|um) fun for all)) fail: provided [#f], wanted [("fo")] 58.pregexp((pregexp-match call|call-with-current-continuation call-with-current-continuation)) fail: provided [#f], wanted [("call")] 59.pregexp((pregexp-match call-with-current-continuation|call call-with-current-continuation)) fail: provided [#f], wanted [("call-with-current-continuation")] 60.pregexp((pregexp-match (?:call|call-with-current-continuation) constrained call-with-current-continuation constrained)) fail: provided [#f], wanted [("call-with-current-continuation constrained")] 62.pregexp((pregexp-match-positions grey(?=hound) i left my grey socks at the greyhound)) fail: provided [#f], wanted [((28 . 32))] 63.pregexp((pregexp-match-positions grey(?!hound) the gray greyhound ate the grey socks)) fail: provided [#f], wanted [((27 . 31))] 64.pregexp((pregexp-match-positions (?<=grey)hound the hound in the picture is not a greyhound)) fail: provided [#f], wanted [((38 . 43))] 65.pregexp((pregexp-match-positions (?
manuel-serrano commented 1 year ago

First of all, thanks for your report. Could you attach the configure.log file so we will see which regexp backend is used. Could you also provide us with the output of the "make test" command. Thank you in advance for your help.

Avimitin commented 1 year ago

Here is the configure.log file. It is using pcre2 as regexp backend

  regexp................................ pcre2

And here is the full log of the make test command: bigloo-4.4c_4-4-riscv64-check.log

manuel-serrano commented 1 year ago

Hi Avimitin,

Thanks for the log file. I have no idea of what could be going wrong. I can only think of two things:

  1. Download the lastest Bigloo version:
wget http://www-sop.inria.fr/indes/fp/Bigloo/download/bigloo-unstable.tar.gz
  1. Configure it and compile it with the embedded custom pcre2 lib
./configure --custompcre2=yes && make && sudo make install
  1. Test it:
make test

Conducting this experiment will be extremelly valuable. If this fails, then we will have investigate deeper, which means debugging the pcre2 binding.

The pcre2 binding is relatively easy to debug (located in runtime/Clib/cpcre2.h) but unfortunately I don't have access to any RiscV machine. Does anyone know if there are publicly available RiscV platforms that I could use for testing? Thanks in advance.

Avimitin commented 1 year ago

Thanks for your guidance.

Does anyone know if there are publicly available RiscV platforms that I could use for testing?

You can follow this article to create a RISC-V QEMU user https://github.com/felixonmars/archriscv-packages/wiki/Setup-Arch-Linux-RISC-V-Development-Environment

Avimitin commented 1 year ago

After adding flag --custompcre2=yes with the unstable source code, the test pass successfully. I am now trying to add this flag to the 4.4c version and test again.

Avimitin commented 1 year ago

Does this related to JIT? After I disabled the JIT feature (it is not available on RISC-V), the pregexp test fail again.

Avimitin commented 1 year ago

I tried to link bigloo against a pcre2 library without JIT feature enabled, the pregexp test is also fail. This error is reproducible on x86_64 platform. So now I can confirm that the root cause of the pregexp test error is related to the pcre2 JIT feature.

Avimitin commented 1 year ago

JIT support for pcre2 is now available for RISC-V platform. This test is all pass now. But I don't know if this is a bug or just because bigloo functionality relies on JIT feature of pcre2.