Solved shmat() failed invalid argument

Hi forum, I am having problems with running graphics/gimp on a fresh install of FreeBSD 10.2-STABLE release. I have x11-wm/xfce4 installed from pkg(8) as well as graphics/gimp. When I start GIMP from the terminal I get the following error:

Code:
$ gimp

(script-fu:1025): LibGimp-ERROR **: shmat() failed: Invalid argument
Could not attach to gimp shared memory segment

(gimp:1024): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error
GIMP-Error: Plug-in crashed: "script-fu"
(/usr/local/libexec/gimp/2.2/plug-ins/script-fu)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

This is keeping me from exporting images to JPG and PNG. I am not sure where to start debugging this. I was hoping someone could help me with how to start debugging this to fix it.

Thanks
 
I was able to solve this by reinstalling and using 10.2-RELEASE instead of using 10.2-STABLE not sure why but it now works.
 
Same problem here on FreeBSD 10.2-STABLE amd64.
graphics/gimp installed from packages.
I have created PR 204919.


Hi lbol, I am curious if what I did would work for you. download the 10.2-RELEASE not the STABLE then try to install gimp again. For some reason it worked for me. Course the exact steps I did was:
  1. # freebsd-update fetch
  2. # freebsd-update install
  3. # pkg install xorg vim sudo gdm mate mate-desktop gimp nvidia-driver-304 nvidia-settings nvidia-xconfig

After configuring system booted into desktop and ran GIMP and found that I had no problems with it.
 
Hi lbol, I am curious if what I did would work for you. download the 10.2-RELEASE not the STABLE then try to install gimp again. For some reason it worked for me. Course the exact steps I did was
  1. # freebsd-update fetch
  2. # freebsd-update install
  3. # pkg install xorg vim sudo gdm mate mate-desktop gimp nvidia-driver-304 nvidia-settings nvidia-xconfig

After configuring system, I booted into desktop and ran GIMP and found that I had no problems with it.
I have no doubt that downgrading from STABLE to RELEASE resolved your issue. I would rather be interested in seeing if the error persists in HEAD. As I am not using GIMP on a regular basis I can use another system to do my job
 
Code:
uname -a
FreeBSD machine3.example.com 10.2-RELEASE-p7 FreeBSD 10.2-RELEASE-p7 #0: Mon Nov  2 14:19:39 UTC 2015  root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

Starting gimp gives:
Code:
gimp

(script-fu:1143): LibGimp-ERROR **: shmat() failed: Invalid argument
Could not attach to gimp shared memory segment

(gimp:1140): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error
GIMP-Error: Plug-in crashed: "script-fu"
(/usr/local/libexec/gimp/2.2/plug-ins/script-fu)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

This is very similar to a problem described in another post:

https://forums.freebsd.org/threads/shmat-failed-invalid-argument.54090/

He was able to solve the problem "...by reinstalling and using 10.2-RELEASE instead of using 10.2-STABLE..." The difference here is I am using 10.2-RELEASE and gimp hasn't worked for me for about a week. It does start, but if you try to open any image (I have tried png, jpg and pdf) it crashes with this type of information given (using a jpg file as an example):

Code:
Plug-in crashed: "file-jpeg"
Procedure 'file-jpeg-load' returned no return values

There is a bug report started by another poster in the above thread, but it has not been confirmed:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204919#c0

I have tried downgrading to gimp-app-2.8.14_4,1.txz, but the problem persisted.

Would anyone have any other suggestions?
 
Thank you for that suggestion. This problem is happening on two different computers, but I set them both up so the fact that this isn't happening to you made me think it may be (I guess likely is) related to something I did. One thing I did was change users shells to zsh. New things I have tried:

Reinstall gimp-app
Change the shell back to sh (and use the original untouched
~/.shrc
)
Delete the users
.gimp-2.8
directory
Tried starting gimp as root

None of these made any difference.
 
shmat points at S5 IPC problems. Are shm, sem et al in the kernel?
Code:
hopo # kldstat -v|grep sysv
  182 sysvmsg
  183 sysvsem
  184 sysvshm
kldload sysvshm if not there. ipcs -a might reveal leftover crud with problematic permissions.

Does the Xserver support MIT-SHM? This might not be related.
Code:
hopo # xdpyinfo|grep SHM
  MIT-SHM

Juha
 
Just wanted to add that the Gimp suddenly stopped working here as well. Dmesg reports:
Code:
pid 1255 (script-fu), uid 1001: exited on signal 5 (core dumped)
pid 1258 (file-png), uid 1001: exited on signal 5 (core dumped)
pid 1261 (file-jpeg), uid 1001: exited on signal 5 (core dumped)
pid 1262 (file-jpeg), uid 1001: exited on signal 5 (core dumped)
pid 1263 (file-jpeg), uid 1001: exited on signal 5 (core dumped)
Reinstall pkg didn't help. Deleting pkg and installing from ports didn't work either.

What is particularly odd is that I have two machines using FreeBSD 10.1-RELEASE which are updated at the same time. Only one displays this problem.

UPDATE:

I uninstalled the gimp-app package and then installed it from ports instead. That did the trick here.
 
Uninstalling the gimp-app package and installing it from ports worked for me, too. I'm not sure if I should mark this solved since pkg install gimp-app yielded a non-working version. I'll wait for advice.
 
Last edited by a moderator:
I didn't read that you reinstalled gimp itself. Did you? I don't know if gimp-app is a dependency for gimp but, installing gimp-app by itself may not resolve any issues.
 
No I didn't try installing the gimp meta-port but I never have had to do that in the past to getting a working gimp. If I remember correctly it installs a large number of language packs. Some time back I just started installing gimp-app. And in fact building gimp-app from ports is working.
 
Uninstalling and reinstalling the meta port doesn't actually do anything ;)

All the meta-port does is install a couple of dependencies (like graphics/gimp-app). If you uninstall the meta-port nothing is actually being removed, all its dependencies are still in place. And (re)installing the meta-port simply checks if they're installed (which they still are). However, this should work:
Code:
pkg delete gimp
pkg autoremove # This should remove the dependencies
pkg install gimp
 
Same issue here. I've just installed gimp on a fresh 10.2 release with:

pkg install gimp

It throws:
Code:
(script-fu:63420): LibGimp-ERROR **: shmat() failed: Invalid argument
Could not attach to gimp shared memory segment

(gimp:63417): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error
GIMP-Error: Plug-in crashed: "script-fu"
(/usr/local/libexec/gimp/2.2/plug-ins/script-fu)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

ipcs -M
Code:
shminfo:
   shmmax:  536870912   (max shared memory segment size)
   shmmin:  1   (min shared memory segment size)
   shmmni:  192   (max number of shared memory identifiers)
   shmseg:  128   (max shared memory segments per process)
   shmall:  131072   (max amount of shared memory in pages)

sysctl -a | grep shm
Code:
kern.ipc.shm_allow_removed: 0
kern.ipc.shm_use_phys: 0
kern.ipc.shmall: 131072
kern.ipc.shmseg: 128
kern.ipc.shmmni: 192
kern.ipc.shmmin: 1
kern.ipc.shmmax: 536870912
kern.features.posix_shm: 1
kern.features.sysv_shm: 1

UPD: actually it's reproducible on FreeBSD 10.1-RELEASE too, after GIMP upgrade.
 
Last edited by a moderator:
I uninstalled the gimp-app package and then installed it from ports instead. That did the trick here.

Keep in mind if your using packages instead of ports you may run into problems when updating doing this unless your knowledgeable enough to know how to get around the expected issues.
 
There might be a regression here - I had problems trying out x11-wm/enlightenment and found that there were some reports that updating a package called "imlib" on Redhat gave the same problems I had. Recompiling e19 from ports produced a working WM. Since "imlib" looks suspiciously like some graphics related package, this might be a problem here also. Maybe worth some investigation? It's almost 4AM now and my bed looks comfy, so please forgive me for not doing that myself right now ;)
 
Keep in mind if your using packages instead of ports you may run into problems when updating doing this unless your knowledgeable enough to know how to get around the expected issues.

Thanks. Yes, I've been there and appreciate the warning. It just doesn't seem possible to do a packages only system.
 
Hi forum, I am having problems with running graphics/gimp on a fresh install of FreeBSD 10.2-STABLE release. I have x11-wm/xfce4 installed from pkg(8) as well as graphics/gimp. When I start GIMP from the terminal I get the following error:

Code:
$ gimp

(script-fu:1025): LibGimp-ERROR **: shmat() failed: Invalid argument
Could not attach to gimp shared memory segment

(gimp:1024): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error
GIMP-Error: Plug-in crashed: "script-fu"
(/usr/local/libexec/gimp/2.2/plug-ins/script-fu)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

I am seeing this same problem on FreeBSD 10.1-RELEASE, with an up-to-date version of gimp, gimp-app, and gimp-gutenprint (along with their dependencies) installed with "pkg".

"kldload sysvshm.ko" says sysvshm is already loaded.

Yes, I ought to upgrade, and I'm going to soon.

Thanks
 
I have also run into the same problem with gimp, which I noticed after upgrading to FreeBSD 10.2-RELEASE. Running from either the Gnome3 or Lumina desktops on two different machines, I would get the same crash dialog noted above when trying to open a graphics file (.jpeg plugin crash, png plugin crash, etc.). Starting gimp from a terminal command line would generate the same crash messages noted above. It does appear to be related to shared memory, as I have found starting gimp with the "no shared memory" option would avoid the problem.
Code:
jay@UnixBSD2:~ % gimp

(script-fu:6791): LibGimp-ERROR **: shmat() failed: Invalid argument
Could not attach to gimp shared memory segment

(gimp:6790): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error
GIMP-Error: Plug-in crashed: "script-fu"
(/usr/local/libexec/gimp/2.2/plug-ins/script-fu)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.

jay@UnixBSD2:~ % gimp --no-shm

This occurs on both systems, both FreeBSD 10.2-RELEASE, both built from packages. I tried the above suggestion of deleting the gimp package and building from the port (after updating the port trees), but it failed to build. (Error message said it wanted libiconv_1.14_9, but libiconv_1.14.8 was already installed.) I did not pursue this further, as I've been through the problems with mixing ports and packages.
 
ibol, thank you for opening 204919.

I tried the workarounds mentioned in bug comments by Kubilay Kocak and everytrash, and they both worked for me.

I chose to apply the workaround of adding this to /etc/sysctl.conf:

kern.ipc.shm_allow_removed=1

This took place on a Fusion VM and a ThinkPad X230, both all-packages, and both running 10.2-RELEASE-p16 amd64 with gimp-2.8.16,2.
 
robroy, ^ This solved my problem as well on the current: "10.4-RELEASE-p3" ; Thank you kindly!

P.S - Sorry for the lack of quote. I didn't know how to properly correct it!
 
Back
Top