The C Source, Patches and (shudder!) Bugs
Post Reply
ladis
Posts: 5
Joined: 07 Aug 2018, 16:32

dispatcher: jimtcl; corrupted heap

Post by ladis » 07 Aug 2018, 16:50

Hi,

I'm cross-compiling usb-modeswitch-2.5.2 for ARM board and using install-static to get minimal installed size. However service fails with:

Code: Select all

systemd[1]: Starting USB_ModeSwitch_3-1.4.2:1.0...
usb_modeswitch_dispatcher[148]: corrupted size vs. prev_size
systemd[1]: usb_modeswitch@3-1.4.2:1.0.service: Main process exited, code=killed, status=6/ABRT
systemd[1]: usb_modeswitch@3-1.4.2:1.0.service: Failed with result 'signal'.
systemd[1]: Failed to start USB_ModeSwitch_3-1.4.2:1.0.
while running

Code: Select all

/usr/sbin/usb_modeswitch_dispatcher --switch-mode 3-1.4.2:1.0
from command line works as expected. I didn't investigate where exactly problem is, but importing jimtcl-0.78 fixes above issue. Could that be done officially for next version?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: dispatcher: jimtcl; corrupted heap

Post by Josh » 09 Aug 2018, 08:33

Of course I can update jimtcl. Thanks for the report!

ladis
Posts: 5
Joined: 07 Aug 2018, 16:32

Re: dispatcher: jimtcl; corrupted heap

Post by ladis » 07 Sep 2018, 12:17

It there any estimated release date for the next version? I'm not pushing on you to release immediately, just want to know for decision how to fix currently broken PTXdist package. Thank you.

ladis
Posts: 5
Joined: 07 Aug 2018, 16:32

Re: dispatcher: jimtcl; corrupted heap

Post by ladis » 12 Sep 2018, 10:47

Perhaps removing builtin jimtcl would be the most feasible solution after all as:
  • Debian package uses system libjim
  • RPM package uses system libjim
  • Arch is using script and depends on Tcl
  • Gentoo has option to either use system libjim or install Tcl script
Perhaps something like this could be a starting point for discussion.

adrian_007
Posts: 2
Joined: 18 Nov 2018, 01:37

Re: dispatcher: jimtcl; corrupted heap

Post by adrian_007 » 18 Nov 2018, 01:54

First of all - hello from new forum member!

As to problem at hand: I've been working on custom distro (Buildroot) for my own little project that is using a 3G dongle to do networking. Unfortunately usb_modeswitch most of the time crashed due to outdated scripting library.
Now, since I didn't want to wait for upstream to update, I took a little initiative and I've basically ended up with rewriting usb_modeswitch to CMake.
Here's the Git repo: https://bitbucket.org/adrian_007/usb-mo ... rc/master/

What have changed:
- project does not embed jimtcl library source, rather it expect it to be somewhere ready to be linked to, like coming from system. If there is a need for internal jimtcl compilation, it can be done as a dependant CMake project.
- logic of Tcl script embedding inside C/C++ compatible header is now done in CMake itself rather than in Tcl, so Tcl is no longer a build dependency.
- there's a switch CMAKE_USE_LOCAL_TCL_INTERPRETER that can force build to use local Tcl's binary to interpret the scripts (only if executable tclsh is actually found) - AFAIR there's a problem with detecting this executable while cross-compiling (at least on Buildroot env), might need some more tweaking. Works for host target compilation, though.

I've tested it on x86_64 machine (my host) and inside Buildroot with cross-compiler (crosstool-ng) for ARMv7 - in both cases usb_modeswitch compiles and works - without crashes!

If author would like to get it upstreamed, don't hesitate and give it a try.

Thanks!

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: dispatcher: jimtcl; corrupted heap

Post by Josh » 03 Oct 2019, 13:35

Thanks for the suggestions and the code, adrian_007 - even if I'm very late with it ...

I'm not familiar with CMake - what would you say are the specific advantages over "make" with respect to usb_modeswitch?

adrian_007
Posts: 2
Joined: 18 Nov 2018, 01:37

Re: dispatcher: jimtcl; corrupted heap

Post by adrian_007 » 10 Nov 2019, 03:28

Josh wrote:Thanks for the suggestions and the code, adrian_007 - even if I'm very late with it ...

I'm not familiar with CMake - what would you say are the specific advantages over "make" with respect to usb_modeswitch?
In short: tclsh is not a build dependency any more

Longer answer:
Given that compilation of usb_modeswitch is not very complicated, there're not many benefits over plain Makefile. My reasoning for using CMake was as follow:
- extra step that is currently delegated to tcl script (make_string.tcl) was quite easily doable inside a tool at configuration time, this allowed me to get rid of tcl being a build dependency
- it has a good integration with CLion, which I was and am using for C/C++ development
- it deals well with dependency resolving, especially when project is being cross-compiled (you already rely on pkg-config tool to do the resolution of libusb, CMake does it under the hood)

One might argue that although tclsh is no longer a build dependency, CMake is a new one. That's true, but nowadays, CMake became de-facto a standard with modern C/C++ development, so this tool is either already present or easily obtainable. Most, if not all, cross-compilation / distro-bakers - like Buildroot - already have it and support it out of the box, which cannot be said about tclsh (that is CMake is a dependency of a significant number of projects, where tcsh is a rather niche tool).

So, in summary, Makefile solution depends on:
- tclsh
- pkg-config

and CMake solution depends on, well, CMake.

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: dispatcher: jimtcl; corrupted heap

Post by Josh » 10 Nov 2019, 12:36

I see.

I have completed a solution where a bash script replaces the tcl script during build. So the dependency on tclsh is dropped.

Showing consideration for the distro packagers, I will not yet move to cmake though.

Post Reply