Skip site navigation (1)Skip section navigation (2)
Date:      Sat,  5 Jun 2010 12:27:25 +0530 (IST)
From:      Ashish SHUKLA <wahjava@gmail.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/147492: [PATCH] textproc/scim-bridge segfaults.
Message-ID:  <20100605065725.97FD64AE66@chateau.d.if>
Resent-Message-ID: <201006050700.o5570DqH021625@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         147492
>Category:       ports
>Synopsis:       [PATCH] textproc/scim-bridge segfaults.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 05 07:00:13 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Ashish SHUKLA
>Release:        FreeBSD 8.0-RELEASE-p3 amd64
>Organization:
N/A
>Environment:
System: FreeBSD chateau.d.if 8.0-RELEASE-p3 FreeBSD 8.0-RELEASE-p3 #4: Thu May 27 19:12:08 IST 2010 root@chateau.d.if:/usr/obj/usr/src/sys/CHATEAU amd64


>Description:

When trying to use scim-bridge with Emacs via scim-bridge.el[1], I got the following error:

SCIM: file-error: ("make client process failed" "no such file or directory" :name "scim-bridge" :service "/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0" :buffer " *scim-bridge(:0.0)*" :family local :server nil :noquery t)

On looking in the /tmp directory, I found following socket file created:

/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.

And also it crashes sometimes due to this socket name mismatch
issue. The socket path created by scim-bridge is incomplete according
to other scim-bridge clients (e.g. scim-bridge.el).

After truss-ing, I figured out it is trying to create the socket with correct path name, but fails to create properly:

,---- an excerpt from: truss $(which scim-bridge)
| socket(PF_LOCAL,SOCK_STREAM,0)			 = 3 (0x3)
| connect(3,{ AF_UNIX "/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0" },49) ERR#2 'No such file or directory'
| close(3)					 = 0 (0x0)
| unlink("/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0") ERR#2 'No such file or directory'
| socket(PF_LOCAL,SOCK_STREAM,0)			 = 3 (0x3)
| fcntl(3,F_GETFL,)				 = 2 (0x2)
| fcntl(3,F_SETFL,O_NONBLOCK|0x2)			 = 0 (0x0)
| bind(3,{ AF_UNIX "/tmp/scim-bridge-0.3.0.socket-1001@localhost:0.0" },49) = 0 (0x0)
| listen(0x3,0x40,0x31,0x8080808080808080,0x101010101010101,0x8080808080808080) = 0 (0x0)
`----

The attached diff file fixes the issue. I don't use Qt4, but chances
are that textproc/scim-bridge-qt4 is buggy too, since they share same
distfile. Thus this diff also needs to be applied on
textproc/scim-bridge-qt4 .

I've filed a bug report[2] on their bug tracker.

[1] - https://launchpad.net/scim-bridge.el
[2] - https://sourceforge.net/tracker/?func=detail&aid=3011721&group_id=108454&atid=650539
>How-To-Repeat:
Make sure you're running in X11.

1. Install scim-bridge .

% sudo make -C /usr/ports/textproc/scim-bridge install

2. Execute scim-bridge.

% scim-bridge

3. Check the path name of the socket, iff scim-bridge is not crashed. 

% ls /tmp/scim-bridge*

You'll notice a path name ending with '0.' assuming your X11 DISPLAY is ":0.0".
>Fix:
diff -urN /usr/ports/textproc/scim-bridge/files/patch-agent_scim-bridge-agent-accept-listener.cpp scim-bridge/files/patch-agent_scim-bridge-agent-accept-listener.cpp
--- /usr/ports/textproc/scim-bridge/files/patch-agent_scim-bridge-agent-accept-listener.cpp	1970-01-01 05:30:00.000000000 +0530
+++ scim-bridge/files/patch-agent_scim-bridge-agent-accept-listener.cpp	2010-06-05 11:19:35.000000000 +0530
@@ -0,0 +1,29 @@
+
+$FreeBSD$
+
+--- agent/scim-bridge-agent-accept-listener.cpp.orig
++++ agent/scim-bridge-agent-accept-listener.cpp
+@@ -106,12 +106,12 @@
+     struct sockaddr_un socket_addr;
+     memset (&socket_addr, 0, sizeof (struct sockaddr_un));
+     socket_addr.sun_family = AF_UNIX;
+-    strcpy (socket_addr.sun_path, socket_path);
++    strncpy (socket_addr.sun_path, socket_path, 104); /* 104 is the maximum length of sun_path in FreeBSD */
+     
+     const int MAX_TRIAL = 5;
+     for (int i = 0; i < MAX_TRIAL; ++i) {
+         scim_bridge_pdebugln (8, "Pinging for the another agent process...");
+-        if (connect (socket_fd, (struct sockaddr*)&socket_addr, sizeof (socket_addr.sun_family) + strlen (socket_addr.sun_path))) {
++        if (connect (socket_fd, (struct sockaddr*)&socket_addr, SUN_LEN(&socket_addr))) {
+             if (i == MAX_TRIAL - 1) {
+                 scim_bridge_pdebugln (6, "It seems like there is no other agent for the old socket.");
+                 break;
+@@ -163,7 +163,7 @@
+         return RETVAL_FAILED;
+     }
+     
+-    if (bind (socket_fd, (struct sockaddr*)&socket_addr, strlen (socket_addr.sun_path) + sizeof (socket_addr.sun_family)) != 0) {
++    if (bind (socket_fd, (struct sockaddr*)&socket_addr, SUN_LEN(&socket_addr)) != 0) {
+         scim_bridge_perrorln ("Cannot bind the socket: %s", strerror (errno));
+         close (socket_fd);
+         socket_fd = -1;
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100605065725.97FD64AE66>