Project

General

Profile

Bug #1399

Updated by Dmitry M. almost 8 years ago

------ 
 test program: 

 ~~~ c 
 ------ 
 #include <errno.h> 
 #include <time.h> 
 #include <stdio.h> 

 static const char NULL_PTR_VALUE[] = "<NULL>"; 

 int main(int argc, char* argv[]) 
 { 
     time_t when; 
     struct tm *local; 

     when = time(NULL); 
     local = gmtime(&when); 
     if (local == NULL) 
     { 
         printf("gmtime() failed, errno=%d\n", errno); 
         return 1; 
     } 

     const char* tm_zone = local->tm_zone; 
     if (tm_zone == NULL) 
        tm_zone = NULL_PTR_VALUE; 

     printf("date: %d.%d.%d, time: %d:%d:%d, zone: %s\n", 
         local->tm_year + 1900, local->tm_mon + 1, local->tm_mday, 
         local->tm_hour, local->tm_min, local->tm_sec, 
         tm_zone); 

     return 0; 
 } 
 ~~~ 

 ------ 
 output: 

 ~~~ 
 ------ 
 [build 824] 
 shell@remix_x86_64:/data/local/tmp $ ./test_gmtime_old 
 date: 2016.5.21, time: 16:9:36, zone: GMT 

 [build 853] 
 shell@remix_x86_64:/data/local/tmp $ ./test_gmtime 
 date: 2016.5.21, time: 16:9:55, zone: <NULL> 

 ------ 
 ~~~ 

 impact - we have crash in python interpreter: 

 ~~~ 
 ------ 
 shell@remix_x86_64:/data/local/tmp $ ./bin/python 
 Python 3.5.1 (default, May 21 2016, 15:14:20)  
 [GCC 5.3 20151204] on linux 
 Type "help", "copyright", "credits" or "license" for more information. 
 >>> import time 
 >>> time.gmtime() 
 Segmentation fault 

 Program received signal SIGSEGV, Segmentation fault. 
 strlen (str=str@entry=0x0) 
     at /home/cislave/workspace/ndk-build-all/HOST/linux/LABEL/ndk-build/platform/ndk/sources/crystax/gen/freebsd/lib/libc/string/mangled-strlen.c:100 
 100 	 in /home/cislave/workspace/ndk-build-all/HOST/linux/LABEL/ndk-build/platform/ndk/sources/crystax/gen/freebsd/lib/libc/string/mangled-strlen.c 
 (gdb) bt 
 #0    strlen (str=str@entry=0x0) 
     at /home/cislave/workspace/ndk-build-all/HOST/linux/LABEL/ndk-build/platform/ndk/sources/crystax/gen/freebsd/lib/libc/string/mangled-strlen.c:100 
 #1    0x00005555556adbe2 in PyUnicode_DecodeLocale (str=0x0, errors=0x555555a3423d "surrogateescape") 
     at /home/vet/me/android/0/externals/python35/Objects/unicodeobject.c:3573 
 #2    0x0000555555797e3b in tmtotuple (p=p@entry=0x7fffffffe230) at /home/vet/me/android/0/externals/python35/Modules/timemodule.c:296 
 #3    0x0000555555798d25 in time_gmtime (self=<optimized out>, args=<optimized out>) at /home/vet/me/android/0/externals/python35/Modules/timemodule.c:351 
 #4    0x0000555555666a09 in PyCFunction_Call (func=func@entry=0x7ffff7d18828, args=args@entry=0x7ffff7df4048, kwds=kwds@entry=0x0) 
     at /home/vet/me/android/0/externals/python35/Objects/methodobject.c:109 
 #5    0x00005555556d9e08 in call_function (oparg=<optimized out>, pp_stack=0x7fffffffe3b0) at /home/vet/me/android/0/externals/python35/Python/ceval.c:4655 
 #6    PyEval_EvalFrameEx (f=f@entry=0x7ffff7df3868, throwflag=throwflag@entry=0) at /home/vet/me/android/0/externals/python35/Python/ceval.c:3185 
 #7    0x00005555556dbd19 in _PyEval_EvalCodeWithName (_co=_co@entry=0x7ffff7d4d420, globals=globals@entry=0x7ffff7d9f5c8,  
     locals=locals@entry=0x7ffff7d9f5c8, args=args@entry=0x0, argcount=argcount@entry=0, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=0x0,  
     defcount=defcount@entry=0, kwdefs=kwdefs@entry=0x0, closure=closure@entry=0x0, name=name@entry=0x0, qualname=qualname@entry=0x0) 
     at /home/vet/me/android/0/externals/python35/Python/ceval.c:3966 
 #8    0x00005555556dbe19 in PyEval_EvalCodeEx (_co=_co@entry=0x7ffff7d4d420, globals=globals@entry=0x7ffff7d9f5c8, locals=locals@entry=0x7ffff7d9f5c8,  
     args=args@entry=0x0, argcount=argcount@entry=0, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=0x0, defcount=defcount@entry=0,  
     kwdefs=kwdefs@entry=0x0, closure=closure@entry=0x0) at /home/vet/me/android/0/externals/python35/Python/ceval.c:3987 
 #9    0x00005555556dbe5c in PyEval_EvalCode (co=co@entry=0x7ffff7d4d420, globals=globals@entry=0x7ffff7d9f5c8, locals=locals@entry=0x7ffff7d9f5c8) 
     at /home/vet/me/android/0/externals/python35/Python/ceval.c:777 
 #10 0x00005555556140a5 in run_mod (mod=mod@entry=0x7ffff6d870e0, filename=filename@entry=0x7ffff7d4c928, globals=0x7ffff7d9f5c8, locals=0x7ffff7d9f5c8,  
     flags=flags@entry=0x7fffffffe6d0, arena=arena@entry=0x7ffff6c17160) at /home/vet/me/android/0/externals/python35/Python/pythonrun.c:970 
 #11 0x0000555555615fe7 in PyRun_InteractiveOneObject (fp=fp@entry=0x555556361980 <__sF>, filename=filename@entry=0x7ffff7d4c928,  
     flags=flags@entry=0x7fffffffe6d0) at /home/vet/me/android/0/externals/python35/Python/pythonrun.c:233 
 #12 0x00005555556162ce in PyRun_InteractiveLoopFlags (fp=fp@entry=0x555556361980 <__sF>, filename_str=filename_str@entry=0x555555a3426f "<stdin>",  
     flags=flags@entry=0x7fffffffe6d0) at /home/vet/me/android/0/externals/python35/Python/pythonrun.c:112 
 #13 0x00005555556169ff in PyRun_AnyFileExFlags (fp=fp@entry=0x555556361980 <__sF>, filename=0x555555a3426f "<stdin>", closeit=0,  
     flags=flags@entry=0x7fffffffe6d0) at /home/vet/me/android/0/externals/python35/Python/pythonrun.c:74 
 #14 0x00005555556c0eaa in run_file (p_cf=0x7fffffffe6d0, filename=0x0, fp=0x555556361980 <__sF>) 
     at /home/vet/me/android/0/externals/python35/Modules/main.c:318 
 #15 Py_Main (argc=<optimized out>, argv=<optimized out>) at /home/vet/me/android/0/externals/python35/Modules/main.c:768 
 #16 0x00005555555fea3f in main (argc=1, argv=<optimized out>) at jni/interpreter.c:55 
 ~~~

Back