Page 1 of 1

"Jump is too far" error in a complex Select-Case

Posted: Wednesday 26th September 2018 11:49am
by Godzilla
Hello! I'm new to the forum and I'm glad to find it. I'm a former VB programmer, been missing it with all my heart and soul for years. DotNet is an insult. Discovering Gambas was a gift from the Almighty.

I've written a fairly complex Select-Case procedure. Its always worked great and without issue until today. I modified it so that each case performs an additional task, each slightly different, depending on the case.

I didn't consider it would be a problem. But now when I try to run the program in IDE or compile, I get the strange error that appears at the "End Select" line, which states "Jump is too far in FMain.class:7326."

This error doesn't appear to be documented on the Gambas site. From my searches, I believe this is an assembly language error. Any suggestions on how to fix?

Thanks for reading and thanks for any help.


[System]
Gambas=3.11.4
OperatingSystem=Linux
Kernel=4.15.0-34-generic
Architecture=x86_64
Distribution=Linux Mint 18.3 Sylvia
Desktop=MATE
Theme=Gtk
Language=en_US.UTF-8
Memory=15939M

[Libraries]
Cairo=libcairo.so.2.11400.6
Curl=libcurl.so.4.4.0
DBus=libdbus-1.so.3.14.6
GStreamer=libgstreamer-0.10.so.0.30.0
GStreamer=libgstreamer-1.0.so.0.803.0
GTK+2=libgtk-x11-2.0.so.0.2400.30
GTK+3=libgtk-3.so.0.1800.9
OpenGL=libGL.so.1.2.0
OpenGL=libGL.so.1.7.0
Poppler=libpoppler.so.58.0.0
QT4=libQtCore.so.4.8.7
QT5=libQt5Core.so.5.5.1
SDL=libSDL-1.2.so.0.11.4
SQLite=libsqlite3.so.0.8.6

[Environment]
CLUTTER_BACKEND=x11
COMPIZ_CONFIG_PROFILE=mate
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-tlAruYdKjA,guid=6fb8b2fb22a5fa0fb1da7cf85baa7a18
DEFAULTS_PATH=/usr/share/gconf/mate.default.path
DESKTOP_SESSION=mate
DISPLAY=:0
GB_GUI=gb.qt4
GDMSESSION=mate
GDM_XSERVER_LOCATION=local
GTK_MODULES=gail:atk-bridge
GTK_OVERLAY_SCROLLING=0
HOME=<home>
LANG=en_US.UTF-8
LOGNAME=<user>
MANDATORY_PATH=/usr/share/gconf/mate.mandatory.path
MATE_DESKTOP_SESSION_ID=this-is-deprecated
MDMSESSION=mate
MDM_LANG=en_US.UTF-8
MDM_XSERVER_LOCATION=local
PATH=~/.local/bin:<home>/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD=<home>
QT_ACCESSIBILITY=1
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
QT_STYLE_OVERRIDE=gtk
SESSION_MANAGER=local/<hostname>:@/tmp/.ICE-unix/2128,unix/<hostname>:/tmp/.ICE-unix/2128
SHELL=/bin/bash
SSH_AGENT_PID=2196
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
TZ=:/etc/localtime
USER=<user>
USERNAME=<user>
WINDOWPATH=8
XAUTHORITY=<home>/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg/xdg-mate:/etc/xdg
XDG_CURRENT_DESKTOP=MATE
XDG_DATA_DIRS=<home>/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share/:/usr/share/mate:<home>/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share/mdm/
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SESSION_COOKIE=4603ef0b0eb640e2836974a04d12e5ab-1537899032.677978-1183103436
XDG_SESSION_DESKTOP=mate
XDG_SESSION_ID=c1
XDG_VTNR=8

Re: "Jump is too far" error in a complex Select-Case

Posted: Wednesday 26th September 2018 3:51pm
by cogier
Hi Godzilla and welcome to the forum. You have found an interesting problem. Can you let us see the code or put something together so we can see the effect.

One thing you could try is changing the Component gb.gui to gb.gui.qt and see if that makes any difference.

Re: "Jump is too far" error in a complex Select-Case

Posted: Wednesday 26th September 2018 6:32pm
by Godzilla
cogier wrote: Wednesday 26th September 2018 3:51pm Hi Godzilla and welcome to the forum. You have found an interesting problem. Can you let us see the code or put something together so we can see the effect.

One thing you could try is changing the Component gb.gui to gb.gui.qt and see if that makes any difference.
Hi cogier thank you for your reply.

The Select-Case in question was 575 lines in length when it was working, with about 280 "case" conditions. Why 280? Because that's just about how many countries there are in the world.

After the modification I added today, the Select-Case has grown to 852 lines in length, with the same amount of "case" conditions. It now gives the "jump is too far" error.

Each case condition essentially modifies a string, depending on a condition. I've simply added an additional line of code to each case condition which modifies a different, unrelated string. They're only related insofar as being dependent on the condition.

I've also tried changing gb.gui to gb.gui.qt as you've suggested. Doing so had no effect on the error, which was still present, disallowing IDE running and compiling as before.

Perhaps I've reached a size limit that was built into Gamabas? Does Benoît Minisini visit this forum? I know he reads the mailing list. But I don't like mailing lists in general, because my inbox has a small finite space for new e-mails, and a mailing list would fill it up quickly.

cogiere I hope this message may give you or anyone reading insight to a possible solution to this problem. Thank you again for your reply.

Re: "Jump is too far" error in a complex Select-Case

Posted: Thursday 27th September 2018 9:56am
by stevedee
This looks like it may be a fundamental problem, below the level of Gambas.

If you do a net search using the search terms: error "jump is too far"
...you may see what I mean.

Is there another way to do what you want to do?
Could you use an array to look up the alternate text by language that you need?

Another approach may be to put the text in a configuration file. This would allow you to modify the file only when there is a language change/addition, rather than risk modifying the Gambas code, testing it, repackaging, and re-issuing your software to your users.

Re: "Jump is too far" error in a complex Select-Case

Posted: Thursday 27th September 2018 1:29pm
by cogier
I have written a piece of code, attached, with 1000 'Case' options (I got Gambas to write most of it!) and it does not crash. So I don't think that any 'limit' has been exceeded. Will you not let us see your code?
test.tar.gz
(397.58 KiB) Downloaded 497 times

Re: "Jump is too far" error in a complex Select-Case

Posted: Saturday 29th September 2018 6:40am
by Godzilla
stevedee and cogier, thank you for your replies. I'm sorry I wasn't able to respond sooner. I'm happy to say that I've solved the problem, or at least found a workaround.

Yes, definitely a low-level error. I believe its an assembly language error. ASM is way out of my ballpark. I don't know what the error is specifically about, but I have an idea why it occurred. Its the complexity of my program.

The Select-Case which caused the error is very big. After adding to it, its probably half a million characters alone. However, that Select Case just a tiny portion of the complete program. The program as a whole is so complex that in many different points in my code, I have to concatenate up to 8 separate strings into one. Because one line of code simply doesn't allow the space needed for the length of the line required.

So essentially, my program was already pushing the limits before I added to the Select Case.

And cogier, very clever programming! Thanks for trying to recreate this issue. Your test code works fine on my system too. My code is different in the sense that each line of my Select-Case is around 800 characters wide. And if it were standalone code, I'm sure would also perform as expected without errors.

Ok, I'll cut to the chase. I hope this workaround helps the next person who might encounter this error.

I had the idea to split the Select Case into two, at the mid point. I created a flag (boolean) at the beginning the function and initialized it as False. With the Select Case part 1, in the Case Else section, the flag is set to True.

Select Case part 2 is contained within a If Flag=True Then .... EndIf, so its only performed when needed.

After doing this, the program ran happily in IDE and with compiling, as though nothing had ever been wrong.

cogier and stevedee, thank you both again for responding to my call for help. It means a lot. I'll be happy to help anyone else if I can.

Re: "Jump is too far" error in a complex Select-Case

Posted: Monday 10th December 2018 1:20am
by Godzilla
As a follow-up on my original post, to help anyone in the future who may encounter this perplexing error.

In my case, while the size of my code for this particular program may push limits, that was not the root cause of the error. The root cause of the error turned out to be an install of Gambas (stable) that had somehow gotten corrupted. Pushing limits is probably what caused the corruption to manifest itself. While my original assumed solution pushed the limits less and allowed my code to continue to run without errors, the root of the problem was still there.

Eventually this corruption got the the point where clicking the Gambas icon would not even start the program. No error message, Gambas just wouldn't start. A full uninstall

Code: Select all

sudo apt-get purge --auto-remove gambas3
and re-install did not fix the issue.

Attempting to start Gambas from the command line gave the message

Code: Select all

gbr3: unable to load component: gb.net
After some research, "gb.net" is actually "gambas3-gb-net" in Synaptic.

The solution I came up with that worked for me was:

1) In Synaptic, mark gambas3-gb-net for complete removal and apply changes.
This will also remove other components, such as gambas3
2) In Synaptic, mark gambas3-gb-net for install and apply changes.
3) In Synaptic, mark gambas3 for install and apply changes. This automatically installs any prior uninstalled components from step 1

These steps gave me a clean, 100% working install of Gambas, where all my programs run normally without any issues. I hope this helps someone out there. I apologize for not posting this follow-up sooner.