Hide Forgot
Description of problem: Using an RDN object results in a segfault: $ gdb python GNU gdb (GDB) Fedora (7.2-26.fc14) Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /usr/bin/python...(no debugging symbols found)...done. Missing separate debuginfos, use: debuginfo-install python-2.7-8.fc14.1.x86_64 (gdb) run Starting program: /usr/bin/python [Thread debugging using libthread_db enabled] Python 2.7 (r27:82500, Sep 16 2010, 18:02:00) [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from nss import nss >>> rdn = nss.RDN(nss.AVA('OU', 'engineering')) >>> print rdn Program received signal SIGSEGV, Segmentation fault. 0x0000003374201b47 in PL_HashTableLookupConst () from /lib64/libplds4.so (gdb) where #0 0x0000003374201b47 in PL_HashTableLookupConst () from /lib64/libplds4.so #1 0x00007ffff176fcd0 in SECOID_FindOID_Util () from /usr/lib64/libnssutil3.so #2 0x0000003373265502 in CERT_GetAVATag () from /usr/lib64/libnss3.so #3 0x00007ffff1bd7689 in ?? () from /usr/lib64/python2.7/site-packages/nss/nss.so #4 0x00007ffff1be3f82 in ?? () from /usr/lib64/python2.7/site-packages/nss/nss.so #5 0x0000003373a89067 in _PyObject_Str () from /usr/lib64/libpython2.7.so.1.0 #6 0x0000003373a8912a in PyObject_Str () from /usr/lib64/libpython2.7.so.1.0 #7 0x0000003373a892c2 in ?? () from /usr/lib64/libpython2.7.so.1.0 #8 0x0000003373a69d3d in PyFile_WriteObject () from /usr/lib64/libpython2.7.so.1.0 #9 0x0000003373ae7b67 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0 #10 0x0000003373aeb04d in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0 #11 0x0000003373aeb162 in PyEval_EvalCode () from /usr/lib64/libpython2.7.so.1.0 #12 0x0000003373b0639c in ?? () from /usr/lib64/libpython2.7.so.1.0 #13 0x0000003373b0813b in PyRun_InteractiveOneFlags () from /usr/lib64/libpython2.7.so.1.0 #14 0x0000003373b0831e in PyRun_InteractiveLoopFlags () from /usr/lib64/libpython2.7.so.1.0 ---Type <return> to continue, or q <return> to quit--- #15 0x0000003373b0892c in PyRun_AnyFileExFlags () from /usr/lib64/libpython2.7.so.1.0 #16 0x0000003373b198ce in Py_Main () from /usr/lib64/libpython2.7.so.1.0 #17 0x0000003370a1ee7d in __libc_start_main () from /lib64/libc.so.6 #18 0x0000000000400649 in _start () Version-Release number of selected component (if applicable): python-nss-0.11-1.fc14.x86_64
Did you call one of the nss init functions? This looks a lot like what happens if you haven't initialized nss. The nss internal hash tables are initialized by the nss init routines, it looks like they haven't been set up.
Gah, no I didn't. That fixed it, closing as invalid.
O.K. good, that was easy. Guess how I instantly recognized it? I've done the same thing more than once myself :-) FWIW, it's very easy to make NSS segfault, it's not a very friendly library. Failing to initialize is just one way, so is failing to call some required SSL functions when doing SSL. :-( I've pondered how python-nss might automatically initialize nss for you when python loads the python-nss module but my attempts were fraught with problems and I gave up.
My suggestion would be to do the reverse: if it isn't initialized throw a NotInitialized() exception. It would just require a slew of extra checking everywhere.