Public bug reported:

$ lsb_release -rd
Description:    Ubuntu 20.04.6 LTS
Release:        20.04

$ apt-cache policy libjq1 libjq-dev
libjq1:
  Installed: 1.6-1ubuntu0.20.04.1+esm2
  Candidate: 1.6-1ubuntu0.20.04.1+esm2
  Version table:
 *** 1.6-1ubuntu0.20.04.1+esm2 510
        510 https://esm.ubuntu.com/infra/ubuntu focal-infra-security/main amd64 
Packages
        100 /var/lib/dpkg/status
     1.6-1ubuntu0.20.04.1 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
     1.6-1 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
libjq-dev:
  Installed: 1.6-1ubuntu0.20.04.1+esm2
  Candidate: 1.6-1ubuntu0.20.04.1+esm2
  Version table:
 *** 1.6-1ubuntu0.20.04.1+esm2 510
        510 https://esm.ubuntu.com/infra/ubuntu focal-infra-security/main amd64 
Packages
        100 /var/lib/dpkg/status
     1.6-1ubuntu0.20.04.1 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
     1.6-1 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages

Using version 1.6-1ubuntu0.20.04.1+esm2 a simple code like the following
will segfault, while downgrading to version 1.6-1ubuntu0.20.04.1 will
work correctly:

#include <thread>
#include <unistd.h>
#include <vector>
extern "C" {
#include <jq.h>
}

static void entry() {
    jq_state* jq = jq_init();
    jq_compile(jq, ".name}");
    usleep(5000000);
    jq_teardown(&jq);
}

int main()
{
    std::vector<std::thread> threads;
    for (int i = 0; i < 10; ++i)
        threads.emplace_back(&entry);

    for (auto& t : threads)
        t.join();
    
    return 0;
}


//Compile it with: g++ -std=c++11 -Wall -Werror -pthread -g -O0 -o main 
main.cpp -ljq

$ gdb ./main 
core._home_ubuntu_main.1000.54978e03-2050-4546-b1b4-22645999ce29.4782.1526840
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007f4c67d9aa99 in jv_nomem_handler () from 
/lib/x86_64-linux-gnu/libjq.so.1
#2  0x00007f4c67d937dd in jq_compile_args () from 
/lib/x86_64-linux-gnu/libjq.so.1
#3  0x00005575431d43da in entry () at main.cpp:10
#4  0x00005575431d60c4 in std::__invoke_impl<void, void (*)()> 
(__f=@0x557555143478: 0x5575431d43a3 <entry()>) at 
/usr/include/c++/9/bits/invoke.h:60
#5  0x00005575431d605c in std::__invoke<void (*)()> (__fn=@0x557555143478: 
0x5575431d43a3 <entry()>) at /usr/include/c++/9/bits/invoke.h:95
#6  0x00005575431d5fee in std::thread::_Invoker<std::tuple<void (*)()> 
>::_M_invoke<0ul> (this=0x557555143478) at /usr/include/c++/9/thread:244
#7  0x00005575431d5fab in std::thread::_Invoker<std::tuple<void (*)()> 
>::operator() (this=0x557555143478) at /usr/include/c++/9/thread:251
#8  0x00005575431d5f7c in 
std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > 
>::_M_run (this=0x557555143470) at /usr/include/c++/9/thread:195
#9  0x00007f4c67c6fdf4 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#10 0x00007f4c67b63609 in start_thread (arg=<optimized out>) at 
pthread_create.c:477
#11 0x00007f4c67a883a3 in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:95


The workaround is to downgrade libjq packages to the latest non-ESM version:
$ sudo apt install libjq1=1.6-1ubuntu0.20.04.1 libjq-dev=1.6-1ubuntu0.20.04.1

** Affects: jq (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2152052

Title:
  Regression introduced in version 1.6-1ubuntu0.20.04.1+esm2

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/jq/+bug/2152052/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to