468,277 Members | 1,522 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,277 developers. It's quick & easy.

Strange bug doesn't occur in Pydb

kj

I'm running into a strange seg fault with the module cjson. The
strange part is that it does not occur when I run the code under
Emacs' Pydb.

Here's an example:
import sys, cjson

d1 = {'a': 1, 'b': 2, 'c': 3}
print sys.version
j1 = cjson.encode(d1)
print j1 # should print the string '{"a": 1, "c": 3, "b": 2}'

The code above runs fine under Pydb, but segfaults at the call to
cjson.encode when I run it from the command line in a standard
Linux shell interaction. In the printed version strings are
identical.

I figure this must be a bug in cjson. I'd love to find a workaround
for it, and hope that this strange difference between Pydb and the
shell command line may be a clue to that.

Any thoughts?

TIA!

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jun 27 '08 #1
4 1014
kj schrieb:
I'm running into a strange seg fault with the module cjson. The
strange part is that it does not occur when I run the code under
Emacs' Pydb.

Here's an example:
import sys, cjson

d1 = {'a': 1, 'b': 2, 'c': 3}
print sys.version
j1 = cjson.encode(d1)
print j1 # should print the string '{"a": 1, "c": 3, "b": 2}'

The code above runs fine under Pydb, but segfaults at the call to
cjson.encode when I run it from the command line in a standard
Linux shell interaction. In the printed version strings are
identical.

I figure this must be a bug in cjson. I'd love to find a workaround
for it, and hope that this strange difference between Pydb and the
shell command line may be a clue to that.

Any thoughts?
Are you sure you actually run the same interpreter in emacs as you do on
the commandline?

Diez
Jun 27 '08 #2
kj
In <6b*************@mid.uni-berlin.de"Diez B. Roggisch" <de***@nospam.web.dewrites:
>kj schrieb:
>I'm running into a strange seg fault with the module cjson. The
strange part is that it does not occur when I run the code under
Emacs' Pydb.

Here's an example:
import sys, cjson

d1 = {'a': 1, 'b': 2, 'c': 3}
print sys.version
j1 = cjson.encode(d1)
print j1 # should print the string '{"a": 1, "c": 3, "b": 2}'

The code above runs fine under Pydb, but segfaults at the call to
cjson.encode when I run it from the command line in a standard
Linux shell interaction. In the printed version strings are
identical.

I figure this must be a bug in cjson. I'd love to find a workaround
for it, and hope that this strange difference between Pydb and the
shell command line may be a clue to that.

Any thoughts?
>Are you sure you actually run the same interpreter in emacs as you do on
the commandline?
No, I'm not. All I know is that both Emacs and the commandline
are running on the same machine, and that the version string that
the program prints is the same in both conditions. How can I verify
that that the same interpreter is running in both cases?

Kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jun 27 '08 #3
kj wrote:
In <6b*************@mid.uni-berlin.de"Diez B. Roggisch"
<de***@nospam.web.dewrites:
>>kj schrieb:
>>I'm running into a strange seg fault with the module cjson. The
strange part is that it does not occur when I run the code under
Emacs' Pydb.

Here's an example:
import sys, cjson

d1 = {'a': 1, 'b': 2, 'c': 3}
print sys.version
j1 = cjson.encode(d1)
print j1 # should print the string '{"a": 1, "c": 3, "b": 2}'

The code above runs fine under Pydb, but segfaults at the call to
cjson.encode when I run it from the command line in a standard
Linux shell interaction. In the printed version strings are
identical.

I figure this must be a bug in cjson. I'd love to find a workaround
for it, and hope that this strange difference between Pydb and the
shell command line may be a clue to that.

Any thoughts?
>>Are you sure you actually run the same interpreter in emacs as you do on
the commandline?

No, I'm not. All I know is that both Emacs and the commandline
are running on the same machine, and that the version string that
the program prints is the same in both conditions. How can I verify
that that the same interpreter is running in both cases?
By e.g.

import sys
print sys.prefix

Additionally, you should compare what

sys.path

contains and if it's the same - otherwise it might be that cjson is picked
up from somewhere else.

If all that's the case, I'd invoke python through gdb and see where the
segfault happens.

BTW: I've been using (and even patching) cjson - without any troubles
whatsoever.

Diez
Jun 27 '08 #4
kj

[Note: I changed the subject line to make it more informative.]

In <6b*************@mid.uni-berlin.de"Diez B. Roggisch" <de***@nospam.web.dewrites:
>kj wrote:
>In <6b*************@mid.uni-berlin.de"Diez B. Roggisch"
<de***@nospam.web.dewrites:
>>>kj schrieb:
I'm running into a strange seg fault with the module cjson. The
strange part is that it does not occur when I run the code under
Emacs' Pydb.

Here's an example:
import sys, cjson

d1 = {'a': 1, 'b': 2, 'c': 3}
print sys.version
j1 = cjson.encode(d1)
print j1 # should print the string '{"a": 1, "c": 3, "b": 2}'

The code above runs fine under Pydb, but segfaults at the call to
cjson.encode when I run it from the command line in a standard
Linux shell interaction. In the printed version strings are
identical.

I figure this must be a bug in cjson. I'd love to find a workaround
for it, and hope that this strange difference between Pydb and the
shell command line may be a clue to that.

Any thoughts?
>>>Are you sure you actually run the same interpreter in emacs as you do on
the commandline?

No, I'm not. All I know is that both Emacs and the commandline
are running on the same machine, and that the version string that
the program prints is the same in both conditions. How can I verify
that that the same interpreter is running in both cases?
>By e.g.
>import sys
print sys.prefix
>Additionally, you should compare what
>sys.path
>contains and if it's the same - otherwise it might be that cjson is picked
up from somewhere else.
>If all that's the case, I'd invoke python through gdb and see where the
segfault happens.

Thanks for that suggestion. I did so, and this is gdb's output at
the time failure:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47622454277872 (LWP 14555)]
encode_object (object=0x777390) at cjson.c:946
946 temp = PyList_GET_ITEM(pieces, 0);

In my experience, however, the root cause of a segfault is often
quite far away in the code from where it is triggered...

Anyway, thanks for your help.

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rick Brandt | last post: by
25 posts views Thread by Neil Ginsberg | last post: by
11 posts views Thread by Marlene Stebbins | last post: by
7 posts views Thread by Tyler Foreman | last post: by
reply views Thread by R. Bernstein | last post: by
2 posts views Thread by Diez B. Roggisch | last post: by
1 post views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.