2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-27 20:08:36 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-6738
|
|
|
|
ISSUE: 6738
|
|
|
|
TITLE: Segfault when gfix requests for database page buffer more memory than available from OS
|
|
|
|
DESCRIPTION:
|
|
|
|
Confirmed crash on 4.0.0.2377 (Windows and Linux)
|
|
|
|
Checked on 4.0.0.2384 - all OK, get STDERR: "unable to allocate memory from operating system"
|
|
|
|
NB: currently acceptable value for '-buffers' is limited from 50 to 2147483646.
|
|
|
|
JIRA: CORE-6509
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_6509
|
2022-09-22 13:20:51 +02:00
|
|
|
NOTES:
|
|
|
|
[22.12.2021] pcisar
|
|
|
|
Crashes v4.0.0.2496 and 4.0.1.2692 64-bit Linux
|
|
|
|
[22.09.2022] pzotov
|
|
|
|
No crashes on Windows and Linux (CentOS 7.9.2009).
|
|
|
|
Returned test to be allowed for performing.
|
|
|
|
In case of crash on other systems dump + debug info will be sent to FB team.
|
2022-01-27 20:08:36 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2021-12-15 22:02:07 +01:00
|
|
|
import re
|
2022-01-27 20:08:36 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
db = db_factory(page_size=32768)
|
2021-12-15 22:02:07 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
act = python_act('db')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
Buffers value was not changed (expected)
|
|
|
|
STDERR in gfix: unable to allocate memory from operating system
|
2021-12-15 22:02:07 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-15 22:02:07 +01:00
|
|
|
pattern_for_page_buffers = re.compile('\\s*Page\\s+buffers\\s+\\d+', re.IGNORECASE)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-15 22:02:07 +01:00
|
|
|
@pytest.mark.version('>=4.0')
|
2022-01-27 20:08:36 +01:00
|
|
|
def test_1(act: Action, capsys):
|
|
|
|
act.gstat(switches=['-h'])
|
|
|
|
print(act.stdout)
|
|
|
|
act.reset()
|
|
|
|
act.expected_stderr = "We expect errors"
|
|
|
|
act.gfix(switches=[act.db.dsn, '-buffers', '2147483646'])
|
|
|
|
gfix_err = act.stderr
|
|
|
|
act.reset()
|
|
|
|
act.gstat(switches=['-h'])
|
|
|
|
print(act.stdout)
|
2021-12-15 22:02:07 +01:00
|
|
|
#
|
|
|
|
buffers_set = set()
|
|
|
|
for line in capsys.readouterr().out.splitlines():
|
|
|
|
if pattern_for_page_buffers.search(line):
|
|
|
|
buffers_set.add(line.split()[2])
|
|
|
|
result = 'not changed (expected)' if len(buffers_set) == 1 else 'UNEXPECTEDLY changed: ' + ', '.join(buffers_set)
|
|
|
|
print(f'Buffers value was {result}')
|
|
|
|
for line in gfix_err.splitlines():
|
|
|
|
print('STDERR in gfix:', line)
|
|
|
|
# Check
|
2022-01-27 20:08:36 +01:00
|
|
|
act.reset()
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.stdout = capsys.readouterr().out
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|