10000 After upgrade to 0.22: `atf-check: ERROR: Caught unexpected error: vector` (sometimes) · Issue #76 · freebsd/atf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

After upgrade to 0.22: atf-check: ERROR: Caught unexpected error: vector (sometimes) #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kevemueller opened this issue Dec 2, 2024 · 16 comments · Fixed by #84
Closed
Assignees

Comments

@kevemueller
Copy link

Hi,

after uprading to 0.22 I have spurious (random)

Standard error: 
atf-check: ERROR: Caught unexpected error: vector

test errors in the kyua logs.
Seen on both GitHub MacOS runners as well as on SourceHut FreeBSD runners.
E.g.
https://github.com/kevemueller/pkg/actions/runs/12120407123/job/33789027959

How can I get around these?

@ngie-eign ngie-eign self-assigned this Dec 2, 2024
@ngie-eign
Copy link
Contributor

vector...? Odd.

@kevemueller
Copy link
Author

Here is a FreeBSD example:

https://builds.sr.ht/~bapt/job/1379208#task-test-332

@ngie-eign
Copy link
Contributor

Oh, interesting... it's a UBSAN run, so compiler-rt is likely outputting some error message which isn't getting cleanly relayed to the consumer.

@ngie-eign
Copy link
Contributor
ngie-eign commented Dec 2, 2024

Here is a FreeBSD example:

https://builds.sr.ht/~bapt/job/1379208#task-test-332

This also has UBSAN enabled. Hmmm... I suspect there's something funky with the new release with std::vector that is only exposed when UBSAN is enabled.

CC: @bapt

@ngie-eign ngie-eign changed the title After upgrade to 0.22 -- atf-check: ERROR: Caught unexpected error: vector After upgrade to 0.22: atf-check: ERROR: Caught unexpected error: vector message is sometimes seen with UBSAN enabled Dec 2, 2024
@ngie-eign ngie-eign changed the title After upgrade to 0.22: atf-check: ERROR: Caught unexpected error: vector message is sometimes seen with UBSAN enabled After upgrade to 0.22: atf-check: ERROR: Caught unexpected error: vector message is sometimes seen with ASAN/LSAN/UBSAN enabled Dec 2, 2024
@kevemueller
Copy link
Author

In the FreeBSD example above, UBSAN is just an environment variable. The code itself is compiled without -fsanitize=undefined.

@kevemueller
Copy link
Author

Hi Enji,
is there anything that I can help to get this resolved? This spurious error really messes with automated CI creating a lot of false positive (failures).
As acknowledged by yourself, this has nothing to with UBSAN/ASAN/LSAN.
It is affecting FreeBSD and MacOS, but does not seem to affect Ubuntu.

Cheers,

@bapt
Copy link
Member
bapt commented Dec 23, 2024

for your information it happen all the time on freebsd with or without libasan, it means the pkg testsuite is broken for weeks, now...

@bapt
Copy link
Member
bapt commented Dec 23, 2024

this is the commit that cause the regression: dca2e69

@ngie-eign
Copy link
Contributor

this is the commit that cause the regression: dca2e69

I figured it was likely that issue sigh...

@ngie-eign
Copy link
Contributor
ngie-eign commented Dec 24, 2024

My gut feeling is that most of the issues I've addressed on https://github.com/ngie-eign/atf/tree/fix-scan-build-issues will also handle this. I just haven't fixed the issue with collection_to_argv(..) yet (a previous attempted fix broke the functionality on the branch).

@kevemueller
Copy link
Author

Hi Enji, scanned through your work. I really like thay you are addressing the memory leaks. Looking forward to get that merged and released.
As for the std::vector exception, perhaps you could also add more diagnostics, like is it a length_error or an out_of_range, to improve the information value of the error message.
Keep up the good work!

@ngie-eign
Copy link
Contributor

@bapt : do you have a simple repro you can provide to identify the issue seen here?

@bapt
Copy link
Member
bapt commented Dec 25, 2024

pkg, ./configure ; make check you will see 3 failures all due to this bug

@ngie-eign
Copy link
Contributor

pkg, ./configure ; make check you will see 3 failures all due to this bug

To clarify:

  • Clone the freebsd/pkg git repo (main).
  • Run ./configure, enabling tests if needed on the configure command line.
  • Run make check.

?

@ngie-eign ngie-eign changed the title After upgrade to 0.22: atf-check: ERROR: Caught unexpected error: vector message is sometimes seen with ASAN/LSAN/UBSAN enabled After upgrade to 0.22: atf-check: ERROR: Caught unexpected error: vector (sometimes) Dec 25, 2024
@ngie-eign
Copy link
Contributor

Ok, yeah... I see it.
If I swap out atf-0.22 with my branch, things improve in some ways, and regress in others. I'll try and figure out what commit addressed the underlying issue.

ngie-eign added a commit to ngie-eign/atf that referenced this issue Dec 25, 2024
The previous logic used 2 separate calls to `atf::fs::path::str()` when
constructing a `std::vector<char>` to pass to `mkstemp(..)`. This in
turn caused grief with how data copying is done in atf-c(3), etc, as the
prior code computed the length of the path of an internal buffer in
`atf_dynstr` structs.

Moreover, the code was manually appending a nul char, which was
unnecessary when making the valid assumption that `std::string` is a
nul-terminated string.

The new code convert the path to an `std::string` once, includes the
existing nul char in the buffer, then passes it to mkstemp(3) instead.
The code works properly now.

Closes:	freebsd#76
Signed-off-by: Enji Cooper <ngie@FreeBSD.org>
@ngie-eign
Copy link
Contributor
ngie-eign commented Dec 25, 2024

Found the commit that addressed the issue. The problem found by the freebsd/pkg check tests is fixed on HEAD.

ngie-eign added a commit to ngie-eign/atf that referenced this issue Dec 27, 2024
The previous logic used 2 separate calls to `atf::fs::path::str()` when
constructing a `std::vector<char>` to pass to `mkstemp(..)`. This in
turn caused grief with how data copying is done in atf-c(3), etc, as the
prior code computed the length of the path of an internal buffer in
`atf_dynstr` structs.

Moreover, the code was manually appending a nul char, which was
unnecessary when making the valid assumption that `std::string` is a
nul-terminated string.

The new code convert the path to an `std::string` once, includes the
existing nul char in the buffer, then passes it to mkstemp(3) instead.
The code works properly now.

Closes:	freebsd#76
Signed-off-by: Enji Cooper <ngie@FreeBSD.org>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Jan 12, 2025
This fixes dev-util/pkgconf's tests with atf-0.22.

Bug: freebsd/atf#76
Signed-off-by: Sam James <sam@gentoo.org>
ngie-eign added a commit that referenced this issue Mar 29, 2025
The previous logic used 2 separate calls to `atf::fs::path::str()` when
constructing a `std::vector<char>` to pass to `mkstemp(..)`. This in
turn caused grief with how data copying is done in atf-c(3), etc, as the
prior code computed the length of the path of an internal buffer in
`atf_dynstr` structs.

Moreover, the code was manually appending a nul char, which was
unnecessary when making the valid assumption that `std::string` is a
nul-terminated string.

The new code convert the path to an `std::string` once, includes the
existing nul char in the buffer, then passes it to mkstemp(3) instead.
The code works properly now.

Closes:	#76
Signed-off-by: Enji Cooper <ngie@FreeBSD.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0