Giter Site home page Giter Site logo

android-ndk-vsnprintf-issue's Introduction

Description

On some Android devices vsprintf returns -1 with any buffer size inside separated thread for non-english languages.

Steps to reproduce:
  1. Take any format function (i've tried many). For example this one https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.17/cocos/base/ccUTF8.cpp#L43
  2. Call format function in separated thread twice with delay (1-2 sec) with non-english language text.
Example code:
std::thread _thread = std::thread([](){
    std::string test1 = format("Any text here. Language doesn't matter %d", 1);
    // sleep is important. vsnprint stop working (returns -1) after some delay, not immediately
    sleep(2);
    // non-english language is important
    std::string test2 = format("运送%d个乘客!电工、防火员和警察不算", 1);
});
_thread.detach();

Or use this test case

Environment Details

  • NDK Version: staring from r15c (with r14b everything is fine)
  • Build system: cmake/ndk-build
  • Host OS: MacOS 10.13.6/Linux Ubuntu 16.04
  • Compiler: clang
  • ABI: armeabi-v7a
  • STL: c++_static
  • NDK API level: 16
  • Device API level: 24, 26
Non-affected devices (tested)
  • Samsung GT-I9082 (Android 4.2.2, API 17)
  • Xiaomi Mi A1 (Android 8.1.0, API 27)
  • DIGMA VOX S501 3G VS5002PG (Android 5.1, API 22)
  • TCL 5065D (Android 5.1.1, API 22)
  • Sony E5303 (Android 6.0 API 23)
  • Google Pixel XL (Android 9, API 28)
  • Google Pixel 3 XL (Android 9, API 28)
Affected devices (tested):
  • Xiaomi Mi PAD 3 (Android 7.0.0, API 24)
Affected devices (according to top devices from crashlytics issue):
  • TCT (Alcatel) Alcatel 1X (U5A_PLUS_4G), Android 8.1
  • Xiaomi Redmi 6A (cactus), Android 8.1
  • Xiaomi Redmi 6 (cereus), Android 8.1
  • Huawei Honor 7A (HWDUA-M), Android 8.1

Screenshots:

Inside thread Inside format function

android-ndk-vsnprintf-issue's People

Contributors

formatcvt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.