libzpool assert vs libc assert

Henri Hennebert hlh at restart.be
Mon Jun 1 16:12:30 UTC 2009


Andriy Gapon wrote:
> on 29/05/2009 15:35 Andriy Gapon said the following:
>> So anyone else feels that this is a bug?
>>
>> on 28/05/2009 16:55 Andriy Gapon said the following:
>>> on 28/05/2009 16:26 Henri Hennebert said the following:
>>>> (gdb) bt
>>>> #0  0x00000008012a6f22 in strlen () from /lib/libc.so.7
>>>> #1  0x00000008012a0feb in open () from /lib/libc.so.7
>>>> #2  0x000000080129ea59 in open () from /lib/libc.so.7
>>>> #3  0x00000008012a1f2e in vfprintf () from /lib/libc.so.7
>>>> #4  0x0000000801291158 in fprintf () from /lib/libc.so.7
>>>> #5  0x0000000801290fb0 in __assert () from /lib/libc.so.7
>>> I find the above part interesting.
>>> Could this be because of the following discrepancy:
>>>
>>> 1)
>>> cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h:
>>> extern void __assert(const char *, const char *, int);
>>> 2)
>>> lib/libc/gen/assert.c:
>>> void
>>> __assert(func, file, line, failedexpr)
>>>         const char *func, *file;
>>>         int line;
>>>         const char *failedexpr;
>>>
>>>> #6  0x0000000800fef120 in zmutex_destroy () from /lib/libzpool.so.1
>>>> #7  0x000000080102e1a0 in dsl_dataset_fast_stat () from /lib/libzpool.so.1
>>>> #8  0x0000000801045ffa in dbuf_find () from /lib/libzpool.so.1
>>>> #9  0x0000000801047bf3 in dmu_buf_rele () from /lib/libzpool.so.1
>>>> #10 0x0000000801027546 in dsl_pool_open () from /lib/libzpool.so.1
>>>> #11 0x000000080101bcec in spa_create () from /lib/libzpool.so.1
>>>> #12 0x000000080101c820 in spa_tryimport () from /lib/libzpool.so.1
> 
> I propose the following patch for this issue.
> It fixes mismatch between __assert extern declaration in zfs code and actual
> signature in libc code.
> I also took liberty of dropping __STDC__ and __STDC_VERSION__ checks. I think that
> those checks are not needed with compilers that can be used to compile FreeBSD.
> Besides, both branches of __STDC_VERSION__ check were exactly the same.
> 
> Henri,
> 
> if you still experience that crash of zpool command, could you please try the
> patch and see if you have a nicer assert message and stacktrace now?
> Sorry, that this is still not a fix for the real issue.
> 
> diff --git a/cddl/contrib/opensolaris/head/assert.h
> b/cddl/contrib/opensolaris/head/assert.h
> index 394820a..c2a4936 100644
> --- a/cddl/contrib/opensolaris/head/assert.h
> +++ b/cddl/contrib/opensolaris/head/assert.h
> @@ -37,15 +37,7 @@
>  extern "C" {
>  #endif
> 
> -#if defined(__STDC__)
> -#if __STDC_VERSION__ - 0 >= 199901L
> -extern void __assert(const char *, const char *, int);
> -#else
> -extern void __assert(const char *, const char *, int);
> -#endif /* __STDC_VERSION__ - 0 >= 199901L */
> -#else
> -extern void _assert();
> -#endif
> +extern void __assert(const char *, const char *, int, const char *);
> 
>  #ifdef	__cplusplus
>  }
> @@ -68,14 +60,6 @@ extern void _assert();
> 
>  #else
> 
> -#if defined(__STDC__)
> -#if __STDC_VERSION__ - 0 >= 199901L
> -#define	assert(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
> -#else
> -#define	assert(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
> -#endif /* __STDC_VERSION__ - 0 >= 199901L */
> -#else
> -#define	assert(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
> -#endif	/* __STDC__ */
> +#define	assert(EX) (void)((EX) || (__assert(__func__, __FILE__, __LINE__, #EX), 0))
> 
>  #endif	/* NDEBUG */
> diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
> b/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
> index 7ae7f9d..631e302 100644
> --- a/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
> +++ b/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
> @@ -120,21 +120,12 @@ extern void vpanic(const char *, __va_list);
>  #define	fm_panic	panic
> 
>  /* This definition is copied from assert.h. */
> -#if defined(__STDC__)
> -#if __STDC_VERSION__ - 0 >= 199901L
> -#define	verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
> -#else
> -#define	verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
> -#endif /* __STDC_VERSION__ - 0 >= 199901L */
> -#else
> -#define	verify(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
> -#endif	/* __STDC__ */
> -
> +#define	verify(EX) (void)((EX) || (__assert(__func__, __FILE__, __LINE__, #EX), 0))
> 
>  #define	VERIFY	verify
>  #define	ASSERT	assert
> 
> -extern void __assert(const char *, const char *, int);
> +extern void __assert(const char *, const char *, int, const char *);
> 
>  #ifdef lint
>  #define	VERIFY3_IMPL(x, y, z, t)	if (x == z) ((void)0)
> @@ -148,7 +139,7 @@ extern void __assert(const char *, const char *, int);
>  		(void) snprintf(__buf, 256, "%s %s %s (0x%llx %s 0x%llx)", \
>  			#LEFT, #OP, #RIGHT, \
>  			(u_longlong_t)__left, #OP, (u_longlong_t)__right); \
> -		__assert(__buf, __FILE__, __LINE__); \
> +		__assert(__func__, __FILE__, __LINE__, __buf); \
>  	} \
>  _NOTE(CONSTCOND) } while (0)
>  /* END CSTYLED */
> 
> 
Here is the new bt after the patch

[root at avoriaz libzpool]# gdb zdb
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging 
symbols found)...
(gdb) r pool1
Starting program: /usr/sbin/zdb pool1
(no debugging symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)...(no debugging 
symbols found)...[New LWP 100178]
(no debugging symbols found)...(no debugging symbols found)...(no 
debugging symbols found)...(no debugging symbols found)...[New Thread 
0x8018020b0 (LWP 100178)]
[New Thread 0x801802240 (LWP 100345)]
     version=13
     name='pool1'
     state=0
     txg=4
     pool_guid=9156958376606789
     hostid=1133576597
     hostname='unset'
     vdev_tree
         type='root'
         id=0
         guid=9156958376606789
         children[0]
                 type='raidz'
                 id=0
                 guid=8214939615613279020
                 nparity=1
                 metaslab_array=23
                 metaslab_shift=32
                 ashift=9
                 asize=500108886016
                 is_log=0
                 children[0]
                         type='disk'
                         id=0
                         guid=7001907692988243779
                         path='/dev/ad8p2'
                         whole_disk=0
                 children[1]
                         type='disk'
                         id=1
                         guid=1909032920962573263
                         path='/dev/ad10p2'
                         whole_disk=0
[New Thread 0x8018023d0 (LWP 100346)]
[New Thread 0x801802560 (LWP 100347)]
[New Thread 0x8018026f0 (LWP 100348)]
[New Thread 0x801802880 (LWP 100349)]
[New Thread 0x801802a10 (LWP 100350)]
[New Thread 0x801802ba0 (LWP 100351)]
[New Thread 0x801802d30 (LWP 100352)]
[New Thread 0x801802ec0 (LWP 100353)]
[New Thread 0x801803050 (LWP 100354)]
[New Thread 0x8018031e0 (LWP 100355)]
[New Thread 0x801803370 (LWP 100356)]
[New Thread 0x801803500 (LWP 100357)]
[New Thread 0x801803690 (LWP 100358)]
[New Thread 0x801803820 (LWP 100359)]
[New Thread 0x8018039b0 (LWP 100360)]
[New Thread 0x801803b40 (LWP 100361)]
[New Thread 0x801803cd0 (LWP 100362)]
[New Thread 0x801803e60 (LWP 100363)]
[New Thread 0x801803ff0 (LWP 100364)]
[New Thread 0x801804180 (LWP 100365)]
[New Thread 0x801804310 (LWP 100366)]
[New Thread 0x8018044a0 (LWP 100367)]
[New Thread 0x801804630 (LWP 100368)]
[New Thread 0x8018047c0 (LWP 100369)]
[New Thread 0x801804950 (LWP 100370)]
[New Thread 0x801804ae0 (LWP 100371)]
Assertion failed: (mp->m_owner == NULL), function zmutex_destroy, file 
/usr/src/cddl/lib/libzpool/../../../cddl/contrib/opensolaris/lib/libzpool/common/kernel.c, 
line 112.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x8018020b0 (LWP 100178)]
0x000000080121fadc in thr_kill () from /lib/libc.so.7
(gdb) bt
#0  0x000000080121fadc in thr_kill () from /lib/libc.so.7
#1  0x00000008012af06b in abort () from /lib/libc.so.7
#2  0x0000000801296fe5 in __assert () from /lib/libc.so.7
#3  0x0000000800fef42e in zmutex_destroy (mp=0x8018b2cc0) at 
/usr/src/cddl/lib/libzpool/../../../cddl/contrib/opensolaris/lib/libzpool/common/kernel.c:112
#4  0x0000000801030287 in dsl_dataset_evict (db=Variable "db" is not 
available.
) at 
/usr/src/cddl/lib/libzpool/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c:266
#5  0x0000000801048b61 in dbuf_evict_user (db=0x8018ca960) at 
/usr/src/cddl/lib/libzpool/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c:215
#6  0x000000080104a8c3 in dbuf_rele (db=0x8018ca960, tag=Variable "tag" 
is not available.
) at 
/usr/src/cddl/lib/libzpool/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c:1739
#7  0x0000000801029276 in dsl_pool_open (spa=0x8018a2000, txg=Variable 
"txg" is not available.
)
     at 
/usr/src/cddl/lib/libzpool/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c:139
#8  0x000000080101d503 in spa_load (spa=0x8018a2000, config=Variable 
"config" is not available.
) at 
/usr/src/cddl/lib/libzpool/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c:1134
#9  0x000000080101e060 in spa_open_common (pool=0x7fffffffed6e "pool1", 
spapp=0x7fffffffeb08, tag=0x40b790, config=0x0)
     at 
/usr/src/cddl/lib/libzpool/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c:1474
#10 0x0000000000408b41 in ?? ()
#11 0x00000000004036de in ?? ()
#12 0x0000000800534000 in ?? ()
#13 0x0000000000000000 in ?? ()
#14 0x0000000000000002 in ?? ()
#15 0x00007fffffffed60 in ?? ()
#16 0x00007fffffffed6e in ?? ()
#17 0x0000000000000000 in ?? ()
#18 0x00007fffffffed74 in ?? ()
#19 0x00007fffffffed8a in ?? ()
#20 0x00007fffffffed95 in ?? ()
#21 0x00007fffffffedaf in ?? ()
#22 0x00007fffffffedda in ?? ()
#23 0x00007fffffffedf7 in ?? ()
#24 0x00007fffffffee0a in ?? ()
#25 0x00007fffffffee14 in ?? ()
#26 0x00007fffffffee1f in ?? ()
#27 0x00007fffffffee2b in ?? ()
#28 0x00007fffffffee40 in ?? ()
#29 0x00007fffffffee54 in ?? ()
#30 0x00007fffffffeeae in ?? ()
#31 0x00007fffffffeebd in ?? ()
#32 0x00007fffffffeec9 in ?? ()
#33 0x00007fffffffeee8 in ?? ()
#34 0x00007fffffffeef5 in ?? ()
#35 0x00007fffffffef0a in ?? ()
#36 0x00007fffffffef1c in ?? ()
#37 0x00007fffffffef25 in ?? ()
#38 0x00007fffffffef35 in ?? ()
#39 0x00007fffffffef3d in ?? ()
#40 0x00007fffffffef66 in ?? ()
#41 0x00007fffffffef73 in ?? ()
#42 0x0000000000000000 in ?? ()
#43 0x0000000000000003 in ?? ()
#44 0x0000000000400040 in ?? ()
#45 0x0000000000000004 in ?? ()
#46 0x0000000000000038 in ?? ()
#47 0x0000000000000005 in ?? ()
#48 0x0000000000000007 in ?? ()
#49 0x0000000000000006 in ?? ()
#50 0x0000000000001000 in ?? ()
#51 0x0000000000000008 in ?? ()
#52 0x0000000000000000 in ?? ()
#53 0x0000000000000009 in ?? ()
#54 0x0000000000403650 in ?? ()
#55 0x0000000000000007 in ?? ()
#56 0x000000080050c000 in ?? ()
#57 0x0000000000000000 in ?? ()
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) q
The program is running.  Exit anyway? (y or n) yes
[root at avoriaz libzpool]#


Henri


More information about the freebsd-stable mailing list